Clang API Reference
Clang._cxstring_to_string — Method
Free and convert a CXString to String. Note this function will free the given CXString so ensure it is not called twice.
Clang.annotateTokens — Method
annotateTokens(tu::TranslationUnit, tokens, token_num, cursors)Annotate the given set of tokens by providing cursors for each token that can be mapped to a specific entity within the abstract syntax tree.
Clang.ast_file — Method
ast_file(mod::CLModule) -> CLFileGiven a module, return the module file where the provided module object came from.
Clang.children — Method
children(cursor::CXCursor) -> Vector{CXCursor}
children(cursor::CLCursor) -> Vector{CLCursor}Return immediate cursors of the given cursor.
Clang.fields — Method
fields(ty::CXType) -> Vector{CXCursor}
fields(ty::CLType) -> Vector{CLCursor}Return a child cursor vector of the given cursor.
Clang.file — Method
file(c::CLCursor) -> CLFileReturn the file referenced by the input cursor.
Clang.file_line_column — Method
file_line_column(CLCursor) -> (CLFile, Int, Int)Return file, line and column number.
Clang.full_name — Method
full_name(mod::CLModule)Given a module, return the full name of the module, e.g. "std.vector".
Clang.getAddressSpace — Method
getAddressSpace(t::Union{CXType,CLType})Returns the address space of the given type. Wrapper for libclang's clang_getAddressSpace.
Clang.getAlignOf — Method
getAlignOf(t::CXType) -> Int
getAlignOf(t::CLType) -> IntReturn the alignment of a type in bytes as per C++[expr.alignof] standard.
It returns a minus number for layout errors, please convert the result to a CXTypeLayoutError to see what the error is.
Clang.getArgType — Method
getArgType(t::CXType, i::Unsigned) -> CXType
getArgType(t::Union{CLFunctionNoProto,CLFunctionProto}, i::Integer) -> CLTypeReturn the type of a parameter of a function type. Wrapper for libclang's clang_getArgType.
Clang.getArgument — Method
getArgument(c::CXCursor, i::Integer) -> CXCursor
getArgument(c::Union{CLFunctionDecl,CLCXXMethod,CLConstructor,CLFunctionTemplate}, i::Integer) -> CLCursorReturn the argument cursor of a function or method.
Clang.getArguments — Method
getArguments(c::Union{BlockCommand, InlineCommand}) -> Vector{String}Return the arguments of a command.
Clang.getAsHTML — Method
getAsHTML(c::Union{CXComment, FullComment})Convert a comment into an HTML fragment. Check libclang's documentation for more details.
Clang.getAsString — Method
getAsString(c::Union{CXComment, HTMLStartTag, HTMLEndTag})Convert an HTML tag to its string representation.
Clang.getAsXML — Method
getAsXML(c::Union{CXComment, FullComment})Convert a comment into an XML document.
Clang.getAttributes — Method
getAttributes(c::Union{CXComment, HTMLStartTag}) -> Vector{Pair{String, String}}Return the attributes of an HTML tag.
Clang.getCanonicalCursor — Method
getCanonicalCursor(c::CXCursor) -> CXCursor
getCanonicalCursor(c::CLCursor) -> CLCursorReturn the getCanonicalCursor cursor corresponding to the given cursor.
Clang.getCanonicalType — Method
getCanonicalType(t::CXType) -> CXType
getCanonicalType(t::CLType) -> CLTypeReturn the canonical type for a CXType.
Clang's type system explicitly models typedefs and all the ways a specific type can be represented. The canonical type is the underlying type with all the "sugar" removed. For example, if 'T' is a typedef for 'int', the canonical type for 'T' would be 'int'. Wrapper for libclang's clang_getCanonicalType.
Clang.getCommandName — Method
getCommandName(c::InlineCommand) -> String
getCommandName(c::BlockCommand) -> StringReturn the command name of a command, e.g. "brief" for \brief blah.
Clang.getCompileCommands — Method
getCompileCommands(db::CLCompilationDatabase, file::AbstractString)Get all compile commands for a file given its complete path.
Clang.getCompileCommands — Method
getCompileCommands(db::CLCompilationDatabase)Get all compile commands from a compilation database.
Clang.getCursorDefinition — Method
getCursorDefinition(c::CXCursor) -> CXCursor
getCursorDefinition(c::CLCursor) -> CLCursorFor a cursor that is either a reference to or a declaration of some entity, retrieve a cursor that describes the definition of that entity.
Clang.getCursorExtent — Method
getCursorExtent(c::Union{CXCursor,CLCursor}) -> CXSourceRangeReturn the physical extent of the source construct referenced by the given cursor.
The extent of a cursor starts with the file/line/column pointing at the first character within the source construct that the cursor refers to and ends with the last character within that source construct. For a declaration, the extent covers the declaration itself. For a reference, the extent covers the location of the reference (e.g., where the referenced entity was actually used).
Clang.getCursorLanguage — Method
getCursorLanguage(c::Union{CXCursor,CLCursor}) -> CXLanguageKindReturn the language of the entity referred to by a given cursor. Return CXLanguage_Invalid if the input cursor is not a decl. Note that, this function has limitations, for example, it cannot distinguish C++ structs from C structs, in both cases, it returns CXLanguage_C.
Clang.getCursorLexicalParent — Method
getCursorLexicalParent(c::CXCursor) -> CXCursor
getCursorLexicalParent(c::CLCursor) -> CLCursorReturn the lexical parent of the given cursor. Please checkout libclang's doc to know more.
Clang.getCursorLinkage — Method
getCursorLinkage(c::Union{CXCursor,CLCursor}) -> CXLinkageKindReturn the linkage of the entity referred to by a given cursor.
Clang.getCursorLocation — Method
getCursorLocation(c::Union{CXCursor,CLCursor}) -> CXSourceLocationReturn the physical location of the source constructor referenced by the given cursor.
Clang.getCursorReferenced — Method
getCursorReferenced(c::CXCursor) -> CXCursor
getCursorReferenced(c::CLCursor) -> CLCursorFor a cursor that is a reference, retrieve a cursor representing the entity that it references.
Clang.getCursorResultType — Method
getCursorResultType(c::CXCursor) -> CXType
getCursorResultType(c::Union{CLFunctionDecl,CLCXXMethod}) -> CLTypeReturn the return type associated with a given cursor. This only returns a valid type if the cursor refers to a function or method.
Clang.getCursorResultType — Method
getCursorResultType(t::CXType) -> CXType
getCursorResultType(t::Union{CLFunctionNoProto,CLFunctionProto}) -> CLTypeReturn the return type associated with a function type. Wrapper for libclang's clang_getResultType.
Clang.getCursorSemanticParent — Method
getCursorSemanticParent(c::CXCursor) -> CXCursor
getCursorSemanticParent(c::CLCursor) -> CLCursorReturn the semantic parent of the given cursor. Please checkout libclang's doc to know more.
Clang.getCursorType — Method
getCursorType(c::CXCursor) -> CXType
getCursorType(c::CLCursor) -> CLTypeReturn the type of a CXCursor (if any). To get the cursor from a type, see getTypeDeclaration.
Clang.getDeclObjCTypeEncoding — Method
getDeclObjCTypeEncoding(C::CXCursor)::CXString
getDeclObjCTypeEncoding(C::CLCursor)::StringReturns the Objective-C type encoding for the specified declaration. Wrapper for libclang's clang_getDeclObjCTypeEncoding.
Clang.getDirection — Method
getDirection(c::Union{CXComment, ParamCommand})Return the parameter passing direction ([in], [out], [in,out]) or missing if the direction is not specified.
Clang.getElementType — Method
getElementType(t::CXType) -> CXType
getElementType(t::Union{CLVector,CLConstantArray,CLIncompleteArray,CLVariableArray,CLDependentSizedArray,CLComplex}) -> CLTypeReturn the element type of an array, complex, or vector type. Wrapper for libclang's clang_getElementType.
Clang.getEnumDeclIntegerType — Method
getEnumDeclIntegerType(c::CLEnumDecl) -> CLTypeRetrieve the integer type of an enum declaration.
Clang.getFieldDeclBitWidth — Method
getFieldDeclBitWidth(c::CLFieldDecl) -> IntReturn the bit width of a bit field declaration as an integer.
Clang.getFunctionTypeCallingConv — Method
getFunctionTypeCallingConv(t::Union{CXType,CLFunctionNoProto,CLFunctionProto}) -> CXCallingConvReturn the calling convention associated with a function type. Wrapper for libclang's clang_getFunctionTypeCallingConv.
Clang.getIncludedFile — Method
getIncludedFile(c::Union{CXCursor,CLCursor}) -> CXFileReturn the file that is included by the given inclusion directive cursor.
Clang.getIndex — Method
getIndex(c::Union{CXComment, ParamCommand})Return zero-based parameter index in function prototype or missing if the parameter is invalid.
Clang.getNamedType — Method
getNamedType(t::CXType) -> CXType
getNamedType(t::CLElaborated) -> CLTypeReturn the type named by the qualified-id. Wrapper for libclang's clang_Type_getNamedType.
Clang.getNullCursor — Method
getNullCursor() -> CXCursorReturn the "NULL" CXCursor.
Clang.getNumArguments — Method
getNumArguments(t::Union{CXType,CLFunctionNoProto,CLFunctionProto}) -> IntReturn the number of non-variadic parameters associated with a function type. Wrapper for libclang's clang_getNumArgTypes.
Clang.getNumArguments — Method
getNumArguments(c::Union{CXCursor,CLCursor}) -> IntReturn the number of non-variadic arguments associated with a given cursor.
Clang.getNumElements — Method
getNumElements(t::Union{CXType,CLVector,CLConstantArray,CLIncompleteArray,CLVariableArray,CLDependentSizedArray}) -> IntReturn the number of elements of an array or vector type. Wrapper for libclang's clang_getNumElements.
Clang.getNumObjCProtocolRefs — Method
getNumObjCProtocolRefs(T::Union{CXType, CLType})::CuintRetrieve the number of protocol references associated with an ObjC object/id.
If the type is not an ObjC object, 0 is returned.
Clang.getNumObjCTypeArgs — Method
getNumObjCTypeArgs(T::Union{CXType, CLType})::CuintRetrieve the number of type arguments associated with an ObjC object.
If the type is not an ObjC object, 0 is returned.
Clang.getObjCEncoding — Method
getObjCEncoding(T::CXType) -> String
getObjCEncoding(T::CLType) -> StringReturns the Objective-C type encoding for the specified Type. Wrapper for libclang's clang_Type_getObjCEncoding.
Clang.getObjCObjectBaseType — Method
getObjCObjectBaseType(T::CXType) -> CXType
getObjCObjectBaseType(T::CLType) -> CLTypeRetrieves the base type of the ObjCObjectType. If the type is not an ObjC object, an invalid type is returned. Wrapper for libclang's clang_Type_getObjCObjectBaseType.
Clang.getObjCPropertyAttributes — Function
getObjCPropertyAttributes(c, reserved)::CuintGiven a cursor that represents a property declaration, return the associated property attributes. The bits are formed from CXObjCPropertyAttrKind.
Arguments
reserved: Reserved for future use, pass 0.
Clang.getObjCPropertyGetterName — Method
getObjCPropertyGetterName(C)::StringGiven a cursor that represents a property declaration, return the name of the method that implements the getter.
Clang.getObjCPropertySetterName — Method
getObjCPropertySetterName(c)::StringGiven a cursor that represents a property declaration, return the name of the method that implements the setter, if any.
Clang.getObjCProtocolDecl — Method
getObjCProtocolDecl(T::CXType, i) -> CLCursor
getObjCProtocolDecl(T::CLType, i) -> CXCursorRetrieve the decl for a protocol reference for an ObjC object/id.
If the type is not an ObjC object or there are not enough protocol references, an invalid cursor is returned.
Clang.getObjCTypeArg — Method
getObjCTypeArg(T::CXType, i) -> CXType
getObjCTypeArg(T::CLType, i) -> CLTypeRetrieve a type argument associated with an ObjC object.
If the type is not an ObjC or the index is not valid, an invalid type is returned.
Clang.getOffsetOf — Method
getOffsetOf(t::CXType, s) -> Int
getOffsetOf(t::CLType, s::AbstractString) -> IntReturn the offset of a field named S in a record of type T in bits as it would be returned by offsetof as per C++11[18.2p4].
It returns a minus number for layout errors, please convert the result to a CXTypeLayoutError to see what the error is.
Clang.getOffsetOfField — Method
getOffsetOfField(c::Union{CXCursor,CLCursor}) -> IntReturn the offset of the field represented by the cursor in bits as it would be returned by offsetof as per C++11[18.2p4]. It returns a minus number for layout errors, please convert the result to a CXTypeLayoutError to see what the error is.
Clang.getParagraph — Method
getParagraph(c::CXComment)
getParagraph(c::BlockCommand)Return the paragraph argument of a given command.
Clang.getParamName — Method
getParamName(c::ParamCommand) -> StringReturn the name of a parameter.
Clang.getParsedComment — Method
getParsedComment(c::CXCursor) -> CXComment
getParsedComment(c::CLCursor) -> CLCommentReturn the parsed AST of doxygen comment associated with the given node.
Clang.getPointeeType — Method
getPointeeType(t::CXType) -> CXType
getPointeeType(t::CLType) -> CLTypeReturn the type of the pointee for pointer types. Wrapper for libclang's clang_getPointeeType.
Clang.getRenderKind — Method
getRenderKind(c::Union{CXComment, InlineCommand}) -> CXCommentInlineCommandRenderKindReturn the most appropriate rendering mode, chosen on command semantics in Doxygen.
Clang.getSizeOf — Method
getSizeOf(t::CXType) -> Int
getSizeOf(t::CLType) -> IntReturn the size of a type in bytes as per C++[expr.sizeof] standard,
It returns a minus number for layout errors, please convert the result to a CXTypeLayoutError to see what the error is.
Clang.getSourceCode — Method
getSourceCode(cursor::Union{CXCursor, CLCursor}) -> StringGet source code for the cursor.
Clang.getTagName — Method
getTagName(c::Union{CXComment, HTMLStartTag, HTMLEndTag})Return the tag name of a HTML tag.
Clang.getText — Method
getText(c::Text) -> String
getText(c::VerbatimBlockLine) -> String
getText(c::VerbatimLine) -> StringGet the text content assiciated with the node.
Clang.getTokenExtent — Method
getTokenExtent(tu::Union{CXTranslationUnit,TranslationUnit}, t::Union{CXToken,CLToken}) -> CXSourceRangeReturn a source range that covers the given token.
Clang.getTokenLocation — Method
getTokenLocation(tu::Union{CXTranslationUnit,TranslationUnit}, t::Union{CXToken,CLToken}) -> CXSourceLocationReturn the source location of the given token.
Clang.getTranslationUnit — Method
getTranslationUnit(c::Union{CXCursor,CLCursor}) -> CXTranslationUnitReturns the translation unit that a cursor originated from.
Clang.getTranslationUnitCursor — Method
getTranslationUnitCursor(tu::TranslationUnit) -> CLCursor
getTranslationUnitCursor(tu::CXTranslationUnit) -> CXCursorReturn the cursor that represents the given translation unit.
Clang.getTypeDeclaration — Method
getTypeDeclaration(t::CXType) -> CXCursor
getTypeDeclaration(t::CLType) -> CLCursorReturn the cursor for the declaration of the given type. To get the type of the cursor, see getCursorType. Wrapper for libclang's clang_getTypeDeclaration.
Clang.getTypedefDeclUnderlyingType — Method
getTypedefDeclUnderlyingType(c::CLTypedefDecl) -> CLTypeReturn the underlying type of a typedef declaration.
Clang.getTypedefName — Method
getTypedefName(t::Union{CXType,CLType}) -> StringReturn the typedef name of the given type. Wrapper for libclang's clang_getTypedefName.
Clang.get_elaborated_cursor — Method
get_elaborated_cursor(ty::CLType) -> CLCursor
get_elaborated_cursor(ty::CXType) -> CXCursorReturn the cursor of the elaborated type that is referenced by the input type. The input type can be a pointer/array. This function returns clang_getNullCursor if the input type is not refer to an elaborated type.
Clang.get_file_line_column — Method
get_file_line_column(c::Union{CXCursor,CLCursor}) -> (String, Int, Int)Return file name, line and column number.
Clang.get_filename — Method
get_filename(file::CXFile) -> StringReturn the complete file and path name of the given file.
Clang.get_filename — Method
get_filename(c::Union{CXCursor,CLCursor}) -> StringReturn the complete file and path name of the given file referenced by the input cursor.
Clang.get_function_args — Method
get_function_args(cursor::CLCursor) -> Vector{CLCursor}Return function arguments for a given cursor.
Clang.get_module — Method
get_module(tu::TranslationUnit, file::CLFile) -> CLModuleGiven a CLFile header file, return the module that contains it, if one exists.
Clang.hasAttrs — Method
hasAttrs(c::Union{CXCursor,CLCursor}) -> BoolDetermine whether the given cursor has any attributes.
Clang.has_elaborated_reference — Method
has_elaborated_reference(ty::CLType) -> Bool
has_elaborated_reference(ty::CXType) -> BoolReturn true if the type is an elaborated type or the type indirectly refers to an elaborated type.
Clang.has_elaborated_tag_reference — Method
has_elaborated_tag_reference(ty::CLType) -> Bool
has_elaborated_tag_reference(ty::CXType) -> BoolReturn true if the type is an elaborated tag type or the type indirectly refers to an elaborated tag type.
Clang.has_function_reference — Method
has_function_reference(ty::CLType) -> Bool
has_function_reference(ty::CXType) -> BoolReturn true if the type is a function or the type indirectly refers to a function.
Clang.isAnonymous — Method
isAnonymous(c::Union{CXCursor,CLCursor}) -> BoolReturn true if the given cursor represents an anonymous record declaration(C++).
Clang.isAttribute — Method
isAttribute(k::CXcursorKind) -> Bool
isAttribute(c::CLCursor) -> BoolReturn true if the given cursor kind represents an attribute.
Clang.isBitField — Method
isBitField(c::Union{CXCursor,CLCursor}) -> BoolReturn true if the cursor specifies a Record member that is a bitfield.
Clang.isConstQualifiedType — Method
isConstQualifiedType(t::Union{CXType,CLType}) -> BoolDetermine whether a CXType has the "const" qualifier set, without looking through typedefs that may have added "const" at a different level. Wrapper for libclang's clang_isConstQualifiedType.
Clang.isCursorDefinition — Method
isCursorDefinition(c::Union{CXCursor,CLCursor}) -> BoolReturn true if the declaration pointed to by this cursor is also a definition of that entity.
Clang.isDeclaration — Method
isDeclaration(k::CXcursorKind) -> Bool
isDeclaration(c::CLCursor) -> BoolReturn true if the given cursor kind represents a declaration.
Clang.isExpression — Method
isExpression(k::CXcursorKind) -> Bool
isExpression(c::CLCursor) -> BoolReturn true if the given cursor kind represents an expression.
Clang.isFunctionInlined — Method
isFunctionInlined(c::Union{CXCursor,CLCursor}) -> BoolDetermine whether a CXCursor that is a function declaration, is an inline declaration.
Clang.isInvalid — Method
isInvalid(k::CXcursorKind) -> Bool
isInvalid(c::CLCursor) -> BoolReturn true if the given cursor kind represents an valid cursor.
Clang.isInvalid — Method
isInvalid(t::CXType) -> Bool
isInvalid(t::CLType) -> BoolReturn true if the type is a valid type.
Clang.isInvalidDeclaration — Method
isInvalidDeclaration(x::CXcursorKind) -> BoolReturn true if the given declaration is invalid. A declaration is invalid if it could not be parsed successfully.
Clang.isMacroBuiltin — Method
isMacroBuiltin(c::Union{CXCursor,CLCursor}) -> BoolDetermine whether a CXCursor that is a macro, is a builtin one.
Clang.isMacroFunctionLike — Method
isMacroFunctionLike(c::Union{CXCursor,CLCursor}) -> BoolDetermine whether a CXCursor that is a macro, is function like.
Clang.isNull — Method
isNull(c::Union{CXCursor,CLCursor}) -> BoolReturn true if cursor is null.
Clang.isPODType — Method
isPODType(t::Union{CXType,CLType}) -> BoolReturn true if the CXType is a plain old data type. Wrapper for libclang's clang_isPODType.
Clang.isPreprocessing — Method
isPreprocessing(k::CXcursorKind) -> Bool
isPreprocessing(c::CLCursor) -> BoolReturn true if the given cursor kind represents a preprocessing element, such as a preprocessor directive or macro instantiation.
Clang.isReference — Method
isReference(k::CXcursorKind) -> Bool
isReference(c::CLCursor) -> BoolReturn true if the given cursor kind represents a simple reference. Note that other kinds of cursors (such as expressions) can also refer to other cursors. Use getCursorReferenced to determine whether a particular cursor refers to another entity.
Clang.isRestrictQualifiedType — Method
isRestrictQualifiedType(t::Union{CXType,CLType}) -> BoolDetermine whether a CXType has the "restrict" qualifier set, without looking through typedefs that may have added "restrict" at a different level. Wrapper for libclang's clang_isRestrictQualifiedType.
Clang.isSelfClosing — Method
isSelfClosing(c::Union{CXComment, HTMLStartTag})Return whether a tag is self-closing (for example, <br />).
Clang.isStatement — Method
isStatement(k::CXcursorKind) -> Bool
isStatement(c::CLCursor) -> BoolReturn true if the given cursor kind represents a statement.
Clang.isTranslationUnit — Method
isTranslationUnit(k::CXcursorKind) -> Bool
isTranslationUnit(c::CLCursor) -> BoolReturn true if the given cursor kind represents a translation unit.
Clang.isUnexposed — Method
isUnexposed(k::CXcursorKind) -> BoolReturn true if the given cursor kind represents a currently unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
Clang.isVariadic — Method
isVariadic(c::Union{CXCursor,CLCursor}) -> BoolReturn true if the given cursor is a variadic function or method.
Clang.isVariadic — Method
isVariadic(t::Union{CXType,CLType}) -> BoolReturn true if the CXType is a variadic function type. Wrapper for libclang's clang_isFunctionTypeVariadic.
Clang.isVirtualBase — Method
isVirtualBase(c::Union{CXCursor,CLCursor}) -> BoolReturn true if the base class specified by the cursor with kind CX_CXXBaseSpecifier is virtual.
Clang.isVolatileQualifiedType — Method
isVolatileQualifiedType(t::Union{CXType,CLType}) -> BoolDetermine whether a CXType has the "volatile" qualifier set, without looking through typedefs that may have added "volatile" at a different level. Wrapper for libclang's clang_isVolatileQualifiedType.
Clang.isWhiteSpace — Method
isWhiteSpace(c::Union{CXComment, CLComment}) -> BoolReturn whether a CXParagraph or CXText is contains only white space. Return false for other kinds of comment.
Clang.is_forward_declaration — Method
is_forward_declaration(x::CLCursor) -> BoolReturn true if the cursor is a forward declaration. Reference: https://joshpeterson.github.io/identifying-a-forward-declaration-with-libclang
Clang.is_inclusion_directive — Method
is_inclusion_directive(x::CLCursor) -> BoolReturn true if the cursor is an inclusion directive.
Clang.is_system — Method
is_system(mod::CLModule)Given a module, return whether it is a system one.
Clang.is_typedef_anon — Method
is_typedef_anon(current::CLCursor, next::CLCursor) -> BoolReturn true if the current cursor is a typedef anonymous struct/enum.
Clang.kind — Method
kind(c::CLCursor) -> CXCursorKindReturn the kind of the given cursor. Note this method directly reads CXCursor's kind field, which won't invoke additional clang_getCursorKind function calls.
Clang.kind — Method
kind(c::Union{CXComment, CXComment}) -> CXCommentKindReturn the kind of a comment.
Clang.kind — Method
kind(c::CXCursor) -> CXCursorKindReturn the kind of the given cursor.
Clang.kind — Method
kind(t::CXToken) -> CXTokenKind
kind(t::CLToken) -> CXTokenKindReturn the kind of the given token.
Clang.kind — Method
kind(t::CXType) -> CXTypeKind
kind(t::CLType) -> CXTypeKindReturn the kind of the given type.
Clang.name — Method
name(file::CLFile) -> StringReturn the complete file and path name of the given file.
Clang.name — Method
name(mod::CLModule)Given a module, return the name of the module, e.g. for the 'std.vector' sub-module it will return "vector".
Clang.name — Method
name(c::Union{CXCursor,CLCursor}) -> StringReturn the display name for the entity referenced by this cursor.
Clang.parent_module — Method
parent_module(mod::CLModule) -> CLModuleGiven a module, return the parent of a sub-module or NULL if the given module is top-level, e.g. for 'std.vector' it will return the 'std' module.
Clang.parse_header — Function
parse_header(
index::Index,
header::AbstractString,
args::Vector{String}=[],
flags=CXTranslationUnit_None,
) -> TranslationUnitReturn the TranslationUnit for a given header. This is the main entry point for parsing.
Arguments
header::AbstractString: the header file to parse.index::Index: CXIndex pointer (pass to avoid re-allocation).args::Vector{String}: compiler switches as string array, eg: ["-x", "c++", "-fno-elide-type"].flags: bitwise OR of CXTranslationUnit_Flags.
Consider using parse_header(::Function) to ensure that the TranslationUnit is kept alive while in use.
See also parse_headers.
Clang.parse_header — Method
parse_header(f::Function, ...)Do-method wrapper around parse_header(::Index) that will ensure that the TranslationUnit object stays alive while f() is running, e.g.:
index = Index()
parse_header(index, "foo.h") do tu
@show length(children(tu))
endClang.parse_headers — Function
parse_headers(
index::Index,
headers::Vector{String},
args::Vector{String}=[],
flags=CXTranslationUnit_None,
) -> Vector{TranslationUnit}Return a TranslationUnit vector for the given headers.
Consider using parse_headers(::Function) to ensure that the TranslationUnit's are kept alive while in use.
See also parse_header.
Clang.parse_headers — Method
parse_headers(f::Function, ...)Do-method wrapper around parse_headers(::Index) that will ensure that all the TranslationUnit objects stays alive while f() is running, e.g.:
index = Index()
parse_headers(index, ["foo.h", "bar.h"]) do tus
@show length(tus)
endClang.remove_ranges — Method
Remove FirstXX and LastXX from enumerations.
Clang.search — Method
search(cursors::Vector{CLCursor}, ismatch::Function) -> Vector{CLCursor}Return vector of CLCursors that match predicate. ismatch is a function that accepts a CLCursor argument.
Clang.spelling — Method
spelling(kind::CXTypeKind) -> StringReturn the spelling of a given CXTypeKind.
Clang.spelling — Method
spelling(tu::TranslationUnit, t::CLToken) -> String
spelling(tu::TranslationUnit, t::CXToken) -> String
spelling(tu::CXTranslationUnit, t::CXToken) -> StringReturn the spelling of the given token. The spelling of a token is the textual representation of that token, e.g., the text of an identifier or keyword.
Clang.spelling — Method
spelling(tu::TranslationUnit) -> StringReturn the original translation unit source file name.
Clang.spelling — Method
spelling(c::Union{CXCursor,CLCursor}) -> StringReturn a name for the entity referenced by this cursor.
Clang.spelling — Method
spelling(t::Union{CXType,CLType}) -> StringPretty-print the underlying type using the rules of the language of the translation unit from which it came. If the type is invalid, an empty string is returned. Wrapper for libclang's clang_getTypeSpelling.
Clang.tokenize — Method
tokenize(c::Union{CXCursor,CLCursor}) -> TokenListReturn a TokenList from the given cursor.
Clang.toplevel_headers — Method
toplevel_headers(tu::TranslationUnit, mod::CLModule)Given a module, return all top level headers associated with the module.
Clang.unique_id — Method
unique_id(file::CLFile) -> CXFileUniqueIDReturn the unique id of the given file.
Clang.value — Method
value(c::CLCursor) -> IntegerReturn the integer value of an enum constant declaration.
Clang.CLCompilationDatabase — Method
CLCompilationDatabase(path::AbstractString)Creates a compilation database from the database found in directory path.
Clang.CLCompileCommand — Type
CLCompileCommandRepresents a command to compile the specific file. Call getDirection, getArguments and getArguments to get its attributes.
Clang.Index — Type
Index(exclude_decls_from_PCH, display_diagnostics)Provide a shared context for creating translation units.
Arguments
exclude_decls_from_PCH: whether we only want to see "local" declarations (that did not come from a previous precompiled header). If false, we want to see all declarations.display_diagnostics: whether to display diagnostics.
Clang.TokenList — Type
TokenListTokenizer accessor.
Clang.TranslationUnit — Type
TranslationUnit(idx, source, args)
TranslationUnit(idx, source, args, unsavedFiles, options)
TranslationUnit(f::Function, ...)Parse the given source file and the translation unit corresponding to that file. The function argument f for the do-constructor will be passed a single TranslationUnit object that will not be GC'd while f() runs.