Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions for manipulating SourceLocation
s, which map a location in a
translation unit to a location in on-disk or in-memory files.
This module is intended to be imported qualified.
- create :: ClangBase m => TranslationUnit s' -> File s'' -> Int -> Int -> ClangT s m (SourceLocation s)
- createForOffset :: ClangBase m => TranslationUnit s' -> File s'' -> Int -> ClangT s m (SourceLocation s)
- createInvalid :: ClangBase m => ClangT s m (SourceLocation s)
- getExpansionLocation :: ClangBase m => SourceLocation s' -> ClangT s m (Maybe (File s), Int, Int, Int)
- getPresumedLocation :: ClangBase m => SourceLocation s' -> ClangT s m (ClangString s, Int, Int)
- getSpellingLocation :: ClangBase m => SourceLocation s' -> ClangT s m (Maybe (File s), Int, Int, Int)
- getFileLocation :: ClangBase m => SourceLocation s' -> ClangT s m (Maybe (File s), Int, Int, Int)
- getCursor :: ClangBase m => TranslationUnit s' -> SourceLocation s'' -> ClangT s m (Cursor s)
- isInSystemHeader :: SourceLocation s' -> Bool
- isFromMainFile :: SourceLocation s' -> Bool
Creating locations
:: ClangBase m | |
=> TranslationUnit s' | The translation unit. |
-> File s'' | The file. |
-> Int | The line. |
-> Int | The column. |
-> ClangT s m (SourceLocation s) | A |
Retrieves a SourceLocation
representing the given location in the source code.
:: ClangBase m | |
=> TranslationUnit s' | The translation unit. |
-> File s'' | The file. |
-> Int | The offset. |
-> ClangT s m (SourceLocation s) | A |
Like create
, but uses an offset instead of a line and column.
createInvalid :: ClangBase m => ClangT s m (SourceLocation s) Source
Creates an invalid SourceLocation
.
Mapping locations to files
getExpansionLocation :: ClangBase m => SourceLocation s' -> ClangT s m (Maybe (File s), Int, Int, Int) Source
Retrieves the File
, line, column, and offset associated with the given location.
If the location points into a macro expansion, retrieves the location of the macro expansion. This may be a position that doesn't exist in the original source.
getPresumedLocation :: ClangBase m => SourceLocation s' -> ClangT s m (ClangString s, Int, Int) Source
Retrieves the File
, line, and column associated with the given location, as
interpreted by the C preprocessor.
This may differ from the results given by getExpansionLocation
because it takes '#line'
directives into account, which getExpansionLocation
ignores.
getSpellingLocation :: ClangBase m => SourceLocation s' -> ClangT s m (Maybe (File s), Int, Int, Int) Source
Retrieves the File
, line, column, and offset associated with the given location.
If the location points into a macro expansion, returns the corresponding position in the original source. This may be where the macro was defined or where it was instantiated, depending on what exactly the location points to.
getFileLocation :: ClangBase m => SourceLocation s' -> ClangT s m (Maybe (File s), Int, Int, Int) Source
Retrieves the File
, line, column, and offset associated with the given location.
If the location points into a macro expansion, returns the position where the macro was expanded or the position of the macro argument, if the cursor points at a macro argument.
Analyzing locations
getCursor :: ClangBase m => TranslationUnit s' -> SourceLocation s'' -> ClangT s m (Cursor s) Source
Retrieves an AST cursor at the given source location.
The cursor can be traversed using the functions in Clang.Cursor.
isInSystemHeader :: SourceLocation s' -> Bool Source
Returns True
if the given location is inside a system header.
isFromMainFile :: SourceLocation s' -> Bool Source
Returns True
if the given location is from the main file of the associated translation
unit.