clang

package
Version: v0.0.0-...-bd0b661 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2012 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

clang provides naive bindings to the CLang C-API.

typical usage follows:

const excludeDeclarationsFromPCH = 1
const displayDiagnostics = 1
idx := clang.NewIndex(excludeDeclarationsFromPCH, displayDiagnostics)
defer idx.Dispose()

args := []string{}
tu := idx.Parse("somefile.cxx", args)
defer tu.Dispose()
fmt.Printf("translation unit: %s\n", tu.Spelling())

Index

Constants

View Source
const (
	/**
	 * \brief Used to indicate that no special translation-unit options are
	 * needed.
	 */
	TU_None = C.CXTranslationUnit_None

	/**
	 * \brief Used to indicate that the parser should construct a "detailed"
	 * preprocessing record, including all macro definitions and instantiations.
	 *
	 * Constructing a detailed preprocessing record requires more memory
	 * and time to parse, since the information contained in the record
	 * is usually not retained. However, it can be useful for
	 * applications that require more detailed information about the
	 * behavior of the preprocessor.
	 */
	TU_DetailedPreprocessingRecord = C.CXTranslationUnit_DetailedPreprocessingRecord

	/**
	 * \brief Used to indicate that the translation unit is incomplete.
	 *
	 * When a translation unit is considered "incomplete", semantic
	 * analysis that is typically performed at the end of the
	 * translation unit will be suppressed. For example, this suppresses
	 * the completion of tentative declarations in C and of
	 * instantiation of implicitly-instantiation function templates in
	 * C++. This option is typically used when parsing a header with the
	 * intent of producing a precompiled header.
	 */
	TU_Incomplete = C.CXTranslationUnit_Incomplete

	/**
	 * \brief Used to indicate that the translation unit should be built with an
	 * implicit precompiled header for the preamble.
	 *
	 * An implicit precompiled header is used as an optimization when a
	 * particular translation unit is likely to be reparsed many times
	 * when the sources aren't changing that often. In this case, an
	 * implicit precompiled header will be built containing all of the
	 * initial includes at the top of the main file (what we refer to as
	 * the "preamble" of the file). In subsequent parses, if the
	 * preamble or the files in it have not changed, \c
	 * clang_reparseTranslationUnit() will re-use the implicit
	 * precompiled header to improve parsing performance.
	 */
	TU_PrecompiledPreamble = C.CXTranslationUnit_PrecompiledPreamble

	/**
	 * \brief Used to indicate that the translation unit should cache some
	 * code-completion results with each reparse of the source file.
	 *
	 * Caching of code-completion results is a performance optimization that
	 * introduces some overhead to reparsing but improves the performance of
	 * code-completion operations.
	 */
	TU_CacheCompletionResults = C.CXTranslationUnit_CacheCompletionResults

	/**
	 * \brief DEPRECATED: Enable precompiled preambles in C++.
	 *
	 * Note: this is a *temporary* option that is available only while
	 * we are testing C++ precompiled preamble support. It is deprecated.
	 */
	TU_CXXPrecompiledPreamble = C.CXTranslationUnit_CXXPrecompiledPreamble

	/**
	 * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
	 *
	 * Note: this is a *temporary* option that is available only while
	 * we are testing C++ precompiled preamble support. It is deprecated.
	 */
	TU_CXXChainedPCH = C.CXTranslationUnit_CXXChainedPCH

	/**
	 * \brief Used to indicate that the "detailed" preprocessing record,
	 * if requested, should also contain nested macro expansions.
	 *
	 * Nested macro expansions (i.e., macro expansions that occur
	 * inside another macro expansion) can, in some code bases, require
	 * a large amount of storage to due preprocessor metaprogramming. Moreover,
	 * its fairly rare that this information is useful for libclang clients.
	 */
	TU_NestedMacroExpansions = C.CXTranslationUnit_NestedMacroExpansions

	/**
	 * \brief Legacy name to indicate that the "detailed" preprocessing record,
	 * if requested, should contain nested macro expansions.
	 *
	 * \see CXTranslationUnit_NestedMacroExpansions for the current name for this
	 * value, and its semantics. This is just an alias.
	 */
	TU_NestedMacroInstantiations = C.CXTranslationUnit_NestedMacroInstantiations
)
View Source
const (
	/** \brief This value indicates that no linkage information is available
	 * for a provided CXCursor. */
	LK_NoLinkage LinkageKind = C.CXLinkage_NoLinkage

	// This is the linkage for static variables and static functions.
	LK_Internal = C.CXLinkage_Internal

	// This is the linkage for entities with external linkage that live
	// in C++ anonymous namespaces.
	LK_UniqueExternal = C.CXLinkage_UniqueExternal

	// This is the linkage for entities with true, external linkage
	LK_External = C.CXLinkage_External
)
View Source
const (
	LanguageInvalid   LanguageKind = C.CXLanguage_Invalid
	LanguageC                      = C.CXLanguage_C
	LanguageObjC                   = C.CXLanguage_ObjC
	LanguageCPlusPlus              = C.CXLanguage_CPlusPlus
)
View Source
const (
	AS_Invalid   AccessSpecifier = C.CX_CXXInvalidAccessSpecifier
	AS_Public                    = C.CX_CXXPublic
	AS_Protected                 = C.CX_CXXProtected
	AS_Private                   = C.CX_CXXPrivate
)
View Source
const (
	/**
	 * \brief Terminates the cursor traversal.
	 */
	CVR_Break ChildVisitResult = C.CXChildVisit_Break

	/**
	 * \brief Continues the cursor traversal with the next sibling of
	 * the cursor just visited, without visiting its children.
	 */
	CVR_Continue = C.CXChildVisit_Continue

	/**
	 * \brief Recursively traverse the children of this cursor, using
	 * the same visitor and client data.
	 */
	CVR_Recurse = C.CXChildVisit_Recurse
)
View Source
const (
	/**
	 * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
	 * range.
	 */
	NR_WantQualifier = C.CXNameRange_WantQualifier

	/**
	 * \brief Include the explicit template arguments, e.g. <int> in x.f<int>, in
	 * the range.
	 */
	NR_WantTemplateArgs = C.CXNameRange_WantTemplateArgs

	/**
	 * \brief If the name is non-contiguous, return the full spanning range.
	 *
	 * Non-contiguous names occur in Objective-C when a selector with two or more
	 * parameters is used, or in C++ when using an operator:
	 * \code
	 * [object doSomething:here withValue:there]; // ObjC
	 * return some_vector[1]; // C++
	 * \endcode
	 */
	NR_WantSinglePiece = C.CXNameRange_WantSinglePiece
)
View Source
const (
	/**
	 * \brief A declaration whose specific kind is not exposed via this
	 * interface.
	 *
	 * Unexposed declarations have the same operations as any other kind
	 * of declaration; one can extract their location information,
	 * spelling, find their definitions, etc. However, the specific kind
	 * of the declaration is not reported.
	 */
	CK_UnexposedDecl CursorKind = C.CXCursor_UnexposedDecl

	// A C or C++ struct.
	CK_StructDecl = C.CXCursor_StructDecl
	// A C or C++ union
	CK_UnionDecl = C.CXCursor_UnionDecl
	// A C++ class
	CK_ClassDecl = C.CXCursor_ClassDecl
	// An enumeration
	CK_EnumDecl = C.CXCursor_EnumDecl
	// A field (in C) or non-static data member (in C++) in a
	// struct, union, or C++ class.
	CK_FieldDecl = C.CXCursor_FieldDecl
	/** \brief An enumerator constant. */
	CK_EnumConstantDecl = C.CXCursor_EnumConstantDecl
	/** \brief A function. */
	CK_FunctionDecl = C.CXCursor_FunctionDecl
	/** \brief A variable. */
	CK_VarDecl = C.CXCursor_VarDecl
	/** \brief A function or method parameter. */
	CK_ParmDecl = C.CXCursor_ParmDecl
	/** \brief An Objective-C @interface. */
	CK_ObjCInterfaceDecl = C.CXCursor_ObjCInterfaceDecl
	/** \brief An Objective-C @interface for a category. */
	CK_ObjCCategoryDecl = C.CXCursor_ObjCCategoryDecl
	/** \brief An Objective-C @protocol declaration. */
	CK_ObjCProtocolDecl = C.CXCursor_ObjCProtocolDecl
	/** \brief An Objective-C @property declaration. */
	CK_ObjCPropertyDecl = C.CXCursor_ObjCPropertyDecl
	/** \brief An Objective-C instance variable. */
	CK_ObjCIvarDecl = C.CXCursor_ObjCIvarDecl
	/** \brief An Objective-C instance method. */
	CK_ObjCInstanceMethodDecl = C.CXCursor_ObjCInstanceMethodDecl
	/** \brief An Objective-C class method. */
	CK_ObjCClassMethodDecl = C.CXCursor_ObjCClassMethodDecl
	/** \brief An Objective-C @implementation. */
	CK_ObjCImplementationDecl = C.CXCursor_ObjCImplementationDecl
	/** \brief An Objective-C @implementation for a category. */
	CK_ObjCCategoryImplDecl = C.CXCursor_ObjCCategoryImplDecl
	/** \brief A typedef */
	CK_TypedefDecl = C.CXCursor_TypedefDecl
	/** \brief A C++ class method. */
	CK_CXXMethod = C.CXCursor_CXXMethod
	/** \brief A C++ namespace. */
	CK_Namespace = C.CXCursor_Namespace
	/** \brief A linkage specification, e.g. 'extern "C"'. */
	CK_LinkageSpec = C.CXCursor_LinkageSpec
	/** \brief A C++ constructor. */
	CK_Constructor = C.CXCursor_Constructor
	/** \brief A C++ destructor. */
	CK_Destructor = C.CXCursor_Destructor
	/** \brief A C++ conversion function. */
	CK_ConversionFunction = C.CXCursor_ConversionFunction
	/** \brief A C++ template type parameter. */
	CK_TemplateTypeParameter = C.CXCursor_TemplateTypeParameter
	/** \brief A C++ non-type template parameter. */
	CK_NonTypeTemplateParameter = C.CXCursor_NonTypeTemplateParameter
	/** \brief A C++ template template parameter. */
	CK_TemplateTemplateParameter = C.CXCursor_TemplateTemplateParameter
	/** \brief A C++ function template. */
	CK_FunctionTemplate = C.CXCursor_FunctionTemplate
	/** \brief A C++ class template. */
	CK_ClassTemplate = C.CXCursor_ClassTemplate
	/** \brief A C++ class template partial specialization. */
	CK_ClassTemplatePartialSpecialization = C.CXCursor_ClassTemplatePartialSpecialization
	/** \brief A C++ namespace alias declaration. */
	CK_NamespaceAlias = C.CXCursor_NamespaceAlias
	/** \brief A C++ using directive. */
	CK_UsingDirective = C.CXCursor_UsingDirective
	/** \brief A C++ using declaration. */
	CK_UsingDeclaration = C.CXCursor_UsingDeclaration
	/** \brief A C++ alias declaration */
	CK_TypeAliasDecl = C.CXCursor_TypeAliasDecl
	/** \brief An Objective-C @synthesize definition. */
	CK_ObjCSynthesizeDecl = C.CXCursor_ObjCSynthesizeDecl
	/** \brief An Objective-C @dynamic definition. */
	CK_ObjCDynamicDecl = C.CXCursor_ObjCDynamicDecl
	/** \brief An access specifier. */
	CK_CXXAccessSpecifier = C.CXCursor_CXXAccessSpecifier

	CK_FirstDecl = C.CXCursor_FirstDecl
	CK_LastDecl  = C.CXCursor_LastDecl

	/* References */
	CK_FirstRef          = C.CXCursor_FirstRef
	CK_ObjCSuperClassRef = C.CXCursor_ObjCSuperClassRef
	CK_ObjCProtocolRef   = C.CXCursor_ObjCProtocolRef
	CK_ObjCClassRef      = C.CXCursor_ObjCClassRef
	/**
	 * \brief A reference to a type declaration.
	 *
	 * A type reference occurs anywhere where a type is named but not
	 * declared. For example, given:
	 *
	 * \code
	 * typedef unsigned size_type;
	 * size_type size;
	 * \endcode
	 *
	 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
	 * while the type of the variable "size" is referenced. The cursor
	 * referenced by the type of size is the typedef for size_type.
	 */
	CK_TypeRef          = C.CXCursor_TypeRef
	CK_CXXBaseSpecifier = C.CXCursor_CXXBaseSpecifier
	/**
	 * \brief A reference to a class template, function template, template
	 * template parameter, or class template partial specialization.
	 */
	CK_TemplateRef = C.CXCursor_TemplateRef
	/**
	 * \brief A reference to a namespace or namespace alias.
	 */
	CK_NamespaceRef = C.CXCursor_NamespaceRef
	/**
	 * \brief A reference to a member of a struct, union, or class that occurs in
	 * some non-expression context, e.g., a designated initializer.
	 */
	CK_MemberRef = C.CXCursor_MemberRef
	/**
	 * \brief A reference to a labeled statement.
	 *
	 * This cursor kind is used to describe the jump to "start_over" in the
	 * goto statement in the following example:
	 *
	 * \code
	 *   start_over:
	 *     ++counter;
	 *
	 *     goto start_over;
	 * \endcode
	 *
	 * A label reference cursor refers to a label statement.
	 */
	CK_LabelRef = C.CXCursor_LabelRef

	/**
	 * \brief A reference to a set of overloaded functions or function templates
	 * that has not yet been resolved to a specific function or function template.
	 *
	 * An overloaded declaration reference cursor occurs in C++ templates where
	 * a dependent name refers to a function. For example:
	 *
	 * \code
	 * template<typename T> void swap(T&, T&);
	 *
	 * struct X { ... };
	 * void swap(X&, X&);
	 *
	 * template<typename T>
	 * void reverse(T* first, T* last) {
	 *   while (first < last - 1) {
	 *     swap(*first, *--last);
	 *     ++first;
	 *   }
	 * }
	 *
	 * struct Y { };
	 * void swap(Y&, Y&);
	 * \endcode
	 *
	 * Here, the identifier "swap" is associated with an overloaded declaration
	 * reference. In the template definition, "swap" refers to either of the two
	 * "swap" functions declared above, so both results will be available. At
	 * instantiation time, "swap" may also refer to other functions found via
	 * argument-dependent lookup (e.g., the "swap" function at the end of the
	 * example).
	 *
	 * The functions \c clang_getNumOverloadedDecls() and
	 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
	 * referenced by this cursor.
	 */
	CK_OverloadedDeclRef = C.CXCursor_OverloadedDeclRef

	CK_LastRef = C.CXCursor_LastRef

	/* Error conditions */
	CK_FirstInvalid   = C.CXCursor_FirstInvalid
	CK_InvalidFile    = C.CXCursor_InvalidFile
	CK_NoDeclFound    = C.CXCursor_NoDeclFound
	CK_NotImplemented = C.CXCursor_NotImplemented
	CK_InvalidCode    = C.CXCursor_InvalidCode
	CK_LastInvalid    = C.CXCursor_LastInvalid

	/* Expressions */
	CK_FirstExpr = C.CXCursor_FirstExpr

	/**
	 * \brief An expression whose specific kind is not exposed via this
	 * interface.
	 *
	 * Unexposed expressions have the same operations as any other kind
	 * of expression; one can extract their location information,
	 * spelling, children, etc. However, the specific kind of the
	 * expression is not reported.
	 */
	CK_UnexposedExpr = C.CXCursor_UnexposedExpr

	/**
	 * \brief An expression that refers to some value declaration, such
	 * as a function, varible, or enumerator.
	 */
	CK_DeclRefExpr = C.CXCursor_DeclRefExpr

	/**
	 * \brief An expression that refers to a member of a struct, union,
	 * class, Objective-C class, etc.
	 */
	CK_MemberRefExpr = C.CXCursor_MemberRefExpr

	/** \brief An expression that calls a function. */
	CK_CallExpr = C.CXCursor_CallExpr

	/** \brief An expression that sends a message to an Objective-C
	  object or class. */
	CK_ObjCMessageExpr = C.CXCursor_ObjCMessageExpr

	/** \brief An expression that represents a block literal. */
	CK_BlockExpr = C.CXCursor_BlockExpr

	/** \brief An integer literal.
	 */
	CK_IntegerLiteral = C.CXCursor_IntegerLiteral

	/** \brief A floating point number literal.
	 */
	CK_FloatingLiteral = C.CXCursor_FloatingLiteral

	/** \brief An imaginary number literal.
	 */
	CK_ImaginaryLiteral = C.CXCursor_ImaginaryLiteral

	/** \brief A string literal.
	 */
	CK_StringLiteral = C.CXCursor_StringLiteral

	/** \brief A character literal.
	 */
	CK_CharacterLiteral = C.CXCursor_CharacterLiteral

	/** \brief A parenthesized expression, e.g. "(1)".
	 *
	 * This AST node is only formed if full location information is requested.
	 */
	CK_ParenExpr = C.CXCursor_ParenExpr

	/** \brief This represents the unary-expression's (except sizeof and
	 * alignof).
	 */
	CK_UnaryOperator = C.CXCursor_UnaryOperator

	/** \brief [C99 6.5.2.1] Array Subscripting.
	 */
	CK_ArraySubscriptExpr = C.CXCursor_ArraySubscriptExpr

	/** \brief A builtin binary operation expression such as "x + y" or
	 * "x <= y".
	 */
	CK_BinaryOperator = C.CXCursor_BinaryOperator

	/** \brief Compound assignment such as "+=".
	 */
	CK_CompoundAssignOperator = C.CXCursor_CompoundAssignOperator

	/** \brief The ?: ternary operator.
	 */
	CK_ConditionalOperator = C.CXCursor_ConditionalOperator

	/** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
	 * (C++ [expr.cast]), which uses the syntax (Type)expr.
	 *
	 * For example: (int)f.
	 */
	CK_CStyleCastExpr = C.CXCursor_CStyleCastExpr

	/** \brief [C99 6.5.2.5]
	 */
	CK_CompoundLiteralExpr = C.CXCursor_CompoundLiteralExpr

	/** \brief Describes an C or C++ initializer list.
	 */
	CK_InitListExpr = C.CXCursor_InitListExpr

	/** \brief The GNU address of label extension, representing &&label.
	 */
	CK_AddrLabelExpr = C.CXCursor_AddrLabelExpr

	/** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
	 */
	CK_StmtExpr = C.CXCursor_StmtExpr

	/** \brief Represents a C1X generic selection.
	 */
	CK_GenericSelectionExpr = C.CXCursor_GenericSelectionExpr

	/** \brief Implements the GNU __null extension, which is a name for a null
	 * pointer constant that has integral type (e.g., int or long) and is the same
	 * size and alignment as a pointer.
	 *
	 * The __null extension is typically only used by system headers, which define
	 * NULL as __null in C++ rather than using 0 (which is an integer that may not
	 * match the size of a pointer).
	 */
	CK_GNUNullExpr = C.CXCursor_GNUNullExpr

	/** \brief C++'s static_cast<> expression.
	 */
	CK_CXXStaticCastExpr = C.CXCursor_CXXStaticCastExpr

	/** \brief C++'s dynamic_cast<> expression.
	 */
	CK_CXXDynamicCastExpr = C.CXCursor_CXXDynamicCastExpr

	/** \brief C++'s reinterpret_cast<> expression.
	 */
	CK_CXXReinterpretCastExpr = C.CXCursor_CXXReinterpretCastExpr

	/** \brief C++'s const_cast<> expression.
	 */
	CK_CXXConstCastExpr = C.CXCursor_CXXConstCastExpr

	/** \brief Represents an explicit C++ type conversion that uses "functional"
	 * notion (C++ [expr.type.conv]).
	 *
	 * Example:
	 * \code
	 *   x = int(0.5);
	 * \endcode
	 */
	CK_CXXFunctionalCastExpr = C.CXCursor_CXXFunctionalCastExpr

	/** \brief A C++ typeid expression (C++ [expr.typeid]).
	 */
	CK_CXXTypeidExpr = C.CXCursor_CXXTypeidExpr

	/** \brief [C++ 2.13.5] C++ Boolean Literal.
	 */
	CK_CXXBoolLiteralExpr = C.CXCursor_CXXBoolLiteralExpr

	/** \brief [C++0x 2.14.7] C++ Pointer Literal.
	 */
	CK_CXXNullPtrLiteralExpr = C.CXCursor_CXXNullPtrLiteralExpr

	/** \brief Represents the "this" expression in C++
	 */
	CK_CXXThisExpr = C.CXCursor_CXXThisExpr

	/** \brief [C++ 15] C++ Throw Expression.
	 *
	 * This handles 'throw' and 'throw' assignment-expression. When
	 * assignment-expression isn't present, Op will be null.
	 */
	CK_CXXThrowExpr = C.CXCursor_CXXThrowExpr

	/** \brief A new expression for memory allocation and constructor calls, e.g:
	 * "new CXXNewExpr(foo)".
	 */
	CK_CXXNewExpr = C.CXCursor_CXXNewExpr

	/** \brief A delete expression for memory deallocation and destructor calls,
	 * e.g. "delete[] pArray".
	 */
	CK_CXXDeleteExpr = C.CXCursor_CXXDeleteExpr

	/** \brief A unary expression.
	 */
	CK_UnaryExpr = C.CXCursor_UnaryExpr

	/** \brief ObjCStringLiteral, used for Objective-C string literals i.e. "foo".
	 */
	CK_ObjCStringLiteral = C.CXCursor_ObjCStringLiteral

	/** \brief ObjCEncodeExpr, used for in Objective-C.
	 */
	CK_ObjCEncodeExpr = C.CXCursor_ObjCEncodeExpr

	/** \brief ObjCSelectorExpr used for in Objective-C.
	 */
	CK_ObjCSelectorExpr = C.CXCursor_ObjCSelectorExpr

	/** \brief Objective-C's protocol expression.
	 */
	CK_ObjCProtocolExpr = C.CXCursor_ObjCProtocolExpr

	/** \brief An Objective-C "bridged" cast expression, which casts between
	 * Objective-C pointers and C pointers, transferring ownership in the process.
	 *
	 * \code
	 *   NSString *str = (__bridge_transfer NSString *)CFCreateString();
	 * \endcode
	 */
	CK_ObjCBridgedCastExpr = C.CXCursor_ObjCBridgedCastExpr

	/** \brief Represents a C++0x pack expansion that produces a sequence of
	 * expressions.
	 *
	 * A pack expansion expression contains a pattern (which itself is an
	 * expression) followed by an ellipsis. For example:
	 *
	 * \code
	 * template<typename F, typename ...Types>
	 * void forward(F f, Types &&...args) {
	 *  f(static_cast<Types&&>(args)...);
	 * }
	 * \endcode
	 */
	CK_PackExpansionExpr = C.CXCursor_PackExpansionExpr

	/** \brief Represents an expression that computes the length of a parameter
	 * pack.
	 *
	 * \code
	 * template<typename ...Types>
	 * struct count {
	 *   static const unsigned value = sizeof...(Types);
	 * };
	 * \endcode
	 */
	CK_SizeOfPackExpr = C.CXCursor_SizeOfPackExpr

	CK_LastExpr = C.CXCursor_LastExpr

	/* Statements */
	CK_FirstStmt = C.CXCursor_FirstStmt
	/**
	 * \brief A statement whose specific kind is not exposed via this
	 * interface.
	 *
	 * Unexposed statements have the same operations as any other kind of
	 * statement; one can extract their location information, spelling,
	 * children, etc. However, the specific kind of the statement is not
	 * reported.
	 */
	CK_UnexposedStmt = C.CXCursor_UnexposedStmt

	/** \brief A labelled statement in a function.
	 *
	 * This cursor kind is used to describe the "start_over:" label statement in
	 * the following example:
	 *
	 * \code
	 *   start_over:
	 *     ++counter;
	 * \endcode
	 *
	 */
	CK_LabelStmt = C.CXCursor_LabelStmt

	/** \brief A group of statements like { stmt stmt }.
	 *
	 * This cursor kind is used to describe compound statements, e.g. function
	 * bodies.
	 */
	CK_CompoundStmt = C.CXCursor_CompoundStmt

	/** \brief A case statment.
	 */
	CK_CaseStmt = C.CXCursor_CaseStmt

	/** \brief A default statement.
	 */
	CK_DefaultStmt = C.CXCursor_DefaultStmt

	/** \brief An if statement
	 */
	CK_IfStmt = C.CXCursor_IfStmt

	/** \brief A switch statement.
	 */
	CK_SwitchStmt = C.CXCursor_SwitchStmt

	/** \brief A while statement.
	 */
	CK_WhileStmt = C.CXCursor_WhileStmt

	/** \brief A do statement.
	 */
	CK_DoStmt = C.CXCursor_DoStmt

	/** \brief A for statement.
	 */
	CK_ForStmt = C.CXCursor_ForStmt

	/** \brief A goto statement.
	 */
	CK_GotoStmt = C.CXCursor_GotoStmt

	/** \brief An indirect goto statement.
	 */
	CK_IndirectGotoStmt = C.CXCursor_IndirectGotoStmt

	/** \brief A continue statement.
	 */
	CK_ContinueStmt = C.CXCursor_ContinueStmt

	/** \brief A break statement.
	 */
	CK_BreakStmt = C.CXCursor_BreakStmt

	/** \brief A return statement.
	 */
	CK_ReturnStmt = C.CXCursor_ReturnStmt

	/** \brief A GNU inline assembly statement extension.
	 */
	CK_AsmStmt = C.CXCursor_AsmStmt

	/** \brief Objective-C's overall @try-@catc-@finall statement.
	 */
	CK_ObjCAtTryStmt = C.CXCursor_ObjCAtTryStmt

	/** \brief Objective-C's @catch statement.
	 */
	CK_ObjCAtCatchStmt = C.CXCursor_ObjCAtCatchStmt

	/** \brief Objective-C's @finally statement.
	 */
	CK_ObjCAtFinallyStmt = C.CXCursor_ObjCAtFinallyStmt

	/** \brief Objective-C's @throw statement.
	 */
	CK_ObjCAtThrowStmt = C.CXCursor_ObjCAtThrowStmt

	/** \brief Objective-C's @synchronized statement.
	 */
	CK_ObjCAtSynchronizedStmt = C.CXCursor_ObjCAtSynchronizedStmt

	/** \brief Objective-C's autorelease pool statement.
	 */
	CK_ObjCAutoreleasePoolStmt = C.CXCursor_ObjCAutoreleasePoolStmt

	/** \brief Objective-C's collection statement.
	 */
	CK_ObjCForCollectionStmt = C.CXCursor_ObjCForCollectionStmt

	/** \brief C++'s catch statement.
	 */
	CK_CXXCatchStmt = C.CXCursor_CXXCatchStmt

	/** \brief C++'s try statement.
	 */
	CK_CXXTryStmt = C.CXCursor_CXXTryStmt

	/** \brief C++'s for (* : *) statement.
	 */
	CK_CXXForRangeStmt = C.CXCursor_CXXForRangeStmt

	/** \brief Windows Structured Exception Handling's try statement.
	 */
	CK_SEHTryStmt = C.CXCursor_SEHTryStmt

	/** \brief Windows Structured Exception Handling's except statement.
	 */
	CK_SEHExceptStmt = C.CXCursor_SEHExceptStmt

	/** \brief Windows Structured Exception Handling's finally statement.
	 */
	CK_SEHFinallyStmt = C.CXCursor_SEHFinallyStmt

	/** \brief The null satement ";": C99 6.8.3p3.
	 *
	 * This cursor kind is used to describe the null statement.
	 */
	CK_NullStmt = C.CXCursor_NullStmt

	/** \brief Adaptor class for mixing declarations with statements and
	 * expressions.
	 */
	CK_DeclStmt = C.CXCursor_DeclStmt

	CK_LastStmt = C.CXCursor_LastStmt

	/**
	 * \brief Cursor that represents the translation unit itself.
	 *
	 * The translation unit cursor exists primarily to act as the root
	 * cursor for traversing the contents of a translation unit.
	 */
	CK_TranslationUnit = C.CXCursor_TranslationUnit

	/* Attributes */
	CK_FirstAttr = C.CXCursor_FirstAttr
	/**
	 * \brief An attribute whose specific kind is not exposed via this
	 * interface.
	 */
	CK_UnexposedAttr = C.CXCursor_UnexposedAttr

	CK_IBActionAttr           = C.CXCursor_IBActionAttr
	CK_IBOutletAttr           = C.CXCursor_IBOutletAttr
	CK_IBOutletCollectionAttr = C.CXCursor_IBOutletCollectionAttr
	CK_CXXFinalAttr           = C.CXCursor_CXXFinalAttr
	CK_CXXOverrideAttr        = C.CXCursor_CXXOverrideAttr
	CK_AnnotateAttr           = C.CXCursor_AnnotateAttr
	CK_LastAttr               = C.CXCursor_LastAttr

	/* Preprocessing */
	CK_PreprocessingDirective = C.CXCursor_PreprocessingDirective
	CK_MacroDefinition        = C.CXCursor_MacroDefinition
	CK_MacroExpansion         = C.CXCursor_MacroExpansion
	CK_MacroInstantiation     = C.CXCursor_MacroInstantiation
	CK_InclusionDirective     = C.CXCursor_InclusionDirective
	CK_FirstPreprocessing     = C.CXCursor_FirstPreprocessing
	CK_LastPreprocessing      = C.CXCursor_LastPreprocessing
)
View Source
const (
	/**
	 * \brief A token that contains some kind of punctuation.
	 */
	TK_Punctuation = C.CXToken_Punctuation

	/**
	 * \brief A language keyword.
	 */
	TK_Keyword = C.CXToken_Keyword

	/**
	 * \brief An identifier (that is not a keyword).
	 */
	TK_Identifier = C.CXToken_Identifier

	/**
	 * \brief A numeric, string, or character literal.
	 */
	TK_Literal = C.CXToken_Literal

	/**
	 * \brief A comment.
	 */
	TK_Comment = C.CXToken_Comment
)
View Source
const (
	// Represents an invalid type (e.g., where no type is available).
	TK_Invalid TypeKind = C.CXType_Invalid

	// A type whose specific kind is not exposed via this interface.
	TK_Unexposed = C.CXType_Unexposed

	TK_Void       = C.CXType_Void
	TK_Bool       = C.CXType_Bool
	TK_Char_U     = C.CXType_Char_U
	TK_UChar      = C.CXType_UChar
	TK_Char16     = C.CXType_Char16
	TK_Char32     = C.CXType_Char32
	TK_UShort     = C.CXType_UShort
	TK_UInt       = C.CXType_UInt
	TK_ULong      = C.CXType_ULong
	TK_ULongLong  = C.CXType_ULongLong
	TK_UInt128    = C.CXType_UInt128
	TK_Char_S     = C.CXType_Char_S
	TK_SChar      = C.CXType_SChar
	TK_WChar      = C.CXType_WChar
	TK_Short      = C.CXType_Short
	TK_Int        = C.CXType_Int
	TK_Long       = C.CXType_Long
	TK_LongLong   = C.CXType_LongLong
	TK_Int128     = C.CXType_Int128
	TK_Float      = C.CXType_Float
	TK_Double     = C.CXType_Double
	TK_LongDouble = C.CXType_LongDouble
	TK_NullPtr    = C.CXType_NullPtr
	TK_Overload   = C.CXType_Overload
	TK_Dependent  = C.CXType_Dependent
	TK_ObjCId     = C.CXType_ObjCId
	TK_ObjCClass  = C.CXType_ObjCClass
	TK_ObjCSel    = C.CXType_ObjCSel

	TK_FirstBuiltin = C.CXType_FirstBuiltin
	TK_LastBuiltin  = C.CXType_LastBuiltin

	TK_Complex           = C.CXType_Complex
	TK_Pointer           = C.CXType_Pointer
	TK_BlockPointer      = C.CXType_BlockPointer
	TK_LValueReference   = C.CXType_LValueReference
	TK_RValueReference   = C.CXType_RValueReference
	TK_Record            = C.CXType_Record
	TK_Enum              = C.CXType_Enum
	TK_Typedef           = C.CXType_Typedef
	TK_ObjCInterface     = C.CXType_ObjCInterface
	TK_ObjCObjectPointer = C.CXType_ObjCObjectPointer
	TK_FunctionNoProto   = C.CXType_FunctionNoProto
	TK_FunctionProto     = C.CXType_FunctionProto
	TK_ConstantArray     = C.CXType_ConstantArray
)

Variables

This section is empty.

Functions

func EqualCursors

func EqualCursors(c1, c2 Cursor) bool

Determine whether two cursors are equivalent

func EqualLocations

func EqualLocations(loc1, loc2 SourceLocation) bool

EqualLocations determines whether two source locations, which must refer into the same translation unit, refer to exactly the same point in the source code. Returns non-zero if the source locations refer to the same location, zero if they refer to different locations.

func EqualRanges

func EqualRanges(r1, r2 SourceRange) bool

EqualRanges determines whether two ranges are equivalent.

func EqualTypes

func EqualTypes(t1, t2 Type) bool

EqualTypes determines whether two Types represent the same type.

Types

type AccessSpecifier

type AccessSpecifier uint32

*

* \brief Represents the C++ access control level to a base class for a
* cursor with kind CX_CXXBaseSpecifier.

type AvailabilityKind

type AvailabilityKind uint32

*

* \brief Describes the availability of a particular entity, which indicates
* whether the use of this entity will result in a warning or error due to
* it being deprecated or unavailable.
const (

	/**
	 * \brief The entity is available.
	 */
	Available AvailabilityKind = C.CXAvailability_Available

	/**
	 * \brief The entity is available, but has been deprecated (and its use is
	 * not recommended).
	 */
	Deprecated AvailabilityKind = C.CXAvailability_Deprecated
	/**
	 * \brief The entity is not available; any use of it will be an error.
	 */
	NotAvailable AvailabilityKind = C.CXAvailability_NotAvailable
	/**
	 * \brief The entity is available, but not accessible; any use of it will be
	 * an error.
	 */
	NotAccessible AvailabilityKind = C.CXAvailability_NotAccessible
)

type ChildVisitResult

type ChildVisitResult uint32

*

* \brief Describes how the traversal of the children of a particular
* cursor should proceed after visiting a particular child cursor.
*
* A value of this enumeration type should be returned by each
* \c CXCursorVisitor to indicate how clang_visitChildren() proceed.

func GoClangCursorVisitor

func GoClangCursorVisitor(cursor, parent C.CXCursor, cfct unsafe.Pointer) (status ChildVisitResult)

export GoClangCursorVisitor

type Cursor

type Cursor struct {
	// contains filtered or unexported fields
}

*

* \brief A cursor representing some element in the abstract syntax tree for
* a translation unit.
*
* The cursor abstraction unifies the different kinds of entities in a
* program--declaration, statements, expressions, references to declarations,
* etc.--under a single "cursor" abstraction with a common set of operations.
* Common operation for a cursor include: getting the physical location in
* a source file where the cursor points, getting the name associated with a
* cursor, and retrieving cursors for any child nodes of a particular cursor.
*
* Cursors can be produced in two specific ways.
* clang_getTranslationUnitCursor() produces a cursor for a translation unit,
* from which one can use clang_visitChildren() to explore the rest of the
* translation unit. clang_getCursor() maps from a physical source location
* to the entity that resides at that location, allowing one to map from the
* source code into the AST.

func NewNullCursor

func NewNullCursor() Cursor

Retrieve the NULL cursor, which represents no entity.

func (Cursor) AccessSpecifier

func (c Cursor) AccessSpecifier() AccessSpecifier

*

* \brief Returns the access control level for the C++ base specifier
* represented by a cursor with kind CXCursor_CXXBaseSpecifier or
* CXCursor_AccessSpecifier.

func (Cursor) Availability

func (c Cursor) Availability() AvailabilityKind

Availability returns the availability of the entity that this cursor refers to

func (Cursor) CXXMethod_IsStatic

func (c Cursor) CXXMethod_IsStatic() bool

*

* \brief Determine if a C++ member function or member function template is
* declared 'static'.

func (Cursor) CXXMethod_IsVirtual

func (c Cursor) CXXMethod_IsVirtual() bool

*

* \brief Determine if a C++ member function or member function template is
* explicitly declared 'virtual' or if it overrides a virtual method from
* one of the base classes.

func (Cursor) CanonicalCursor

func (c Cursor) CanonicalCursor() Cursor

*

* \brief Retrieve the canonical cursor corresponding to the given cursor.
*
* In the C family of languages, many kinds of entities can be declared several
* times within a single translation unit. For example, a structure type can
* be forward-declared (possibly multiple times) and later defined:
*
* \code
* struct X;
* struct X;
* struct X {
*   int member;
* };
* \endcode
*
* The declarations and the definition of \c X are represented by three
* different cursors, all of which are declarations of the same underlying
* entity. One of these cursor is considered the "canonical" cursor, which
* is effectively the representative for the underlying entity. One can
* determine if two cursors are declarations of the same underlying entity by
* comparing their canonical cursors.
*
* \returns The canonical cursor for the entity referred to by the given cursor.

func (Cursor) DeclObjCTypeEncoding

func (c Cursor) DeclObjCTypeEncoding() string

DeclObjCTypeEncoding returns the Objective-C type encoding for the specified declaration.

func (Cursor) DefinitionCursor

func (c Cursor) DefinitionCursor() Cursor

*

*  \brief For a cursor that is either a reference to or a declaration
*  of some entity, retrieve a cursor that describes the definition of
*  that entity.
*
*  Some entities can be declared multiple times within a translation
*  unit, but only one of those declarations can also be a
*  definition. For example, given:
*
*  \code
*  int f(int, int);
*  int g(int x, int y) { return f(x, y); }
*  int f(int a, int b) { return a + b; }
*  int f(int, int);
*  \endcode
*
*  there are three declarations of the function "f", but only the
*  second one is a definition. The clang_getCursorDefinition()
*  function will take any cursor pointing to a declaration of "f"
*  (the first or fourth lines of the example) or a cursor referenced
*  that uses "f" (the call to "f' inside "g") and will return a
*  declaration cursor pointing to the definition (the second "f"
*  declaration).
*
*  If given a cursor for which there is no corresponding definition,
*  e.g., because there is no definition of that entity within this
*  translation unit, returns a NULL cursor.

func (Cursor) DisplayName

func (c Cursor) DisplayName() string

*

* \brief Retrieve the display name for the entity referenced by this cursor.
*
* The display name contains extra information that helps identify the cursor,
* such as the parameters of a function or template or the arguments of a
* class template specialization.

func (Cursor) Extent

func (c Cursor) Extent() SourceRange

*

* \brief Retrieve 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 withinin 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).

func (Cursor) Hash

func (c Cursor) Hash() uint

Hash computes a hash value for the cursor

func (Cursor) IBOutletCollectionType

func (c Cursor) IBOutletCollectionType() Type

*

* \brief For cursors representing an iboutletcollection attribute,
*  this function returns the collection element type.
*

func (Cursor) IncludedFile

func (c Cursor) IncludedFile() File

IncludedFile returns the file that is included by the given inclusion directive

func (Cursor) IsDefinition

func (c Cursor) IsDefinition() bool

*

* \brief Determine whether the declaration pointed to by this cursor
* is also a definition of that entity.

func (Cursor) IsNull

func (c Cursor) IsNull() bool

IsNull returns true if the underlying Cursor is null

func (Cursor) IsVirtualBase

func (c Cursor) IsVirtualBase() bool

*

* \brief Returns 1 if the base class specified by the cursor with kind
*   CX_CXXBaseSpecifier is virtual.

func (Cursor) Kind

func (c Cursor) Kind() CursorKind

Kind returns the cursor's kind.

func (Cursor) Language

func (c Cursor) Language() LanguageKind

Language returns the "language" of the entity referred to by a cursor.

func (Cursor) LexicalParent

func (c Cursor) LexicalParent() Cursor

*

* \brief Determine the lexical parent of the given cursor.
*
* The lexical parent of a cursor is the cursor in which the given \p cursor
* was actually written. For many declarations, the lexical and semantic parents
* are equivalent (the semantic parent is returned by
* \c clang_getCursorSemanticParent()). They diverge when declarations or
* definitions are provided out-of-line. For example:
*
* \code
* class C {
*  void f();
* };
*
* void C::f() { }
* \endcode
*
* In the out-of-line definition of \c C::f, the semantic parent is the
* the class \c C, of which this function is a member. The lexical parent is
* the place where the declaration actually occurs in the source code; in this
* case, the definition occurs in the translation unit. In general, the
* lexical parent for a given entity can change without affecting the semantics
* of the program, and the lexical parent of different declarations of the
* same entity may be different. Changing the semantic parent of a declaration,
* on the other hand, can have a major impact on semantics, and redeclarations
* of a particular entity should all have the same semantic context.
*
* In the example above, both declarations of \c C::f have \c C as their
* semantic context, while the lexical context of the first \c C::f is \c C
* and the lexical context of the second \c C::f is the translation unit.
*
* For declarations written in the global scope, the lexical parent is
* the translation unit.

func (Cursor) Linkage

func (c Cursor) Linkage() LinkageKind

Linkage returns the linkage of the entity referred to by a cursor

func (Cursor) Location

func (c Cursor) Location() SourceLocation

*

* \brief Retrieve the physical location of the source constructor referenced
* by the given cursor.
*
* The location of a declaration is typically the location of the name of that
* declaration, where the name of that declaration would occur if it is
* unnamed, or some keyword that introduces that particular declaration.
* The location of a reference is where that reference occurs within the
* source code.

func (Cursor) NumOverloadedDecls

func (c Cursor) NumOverloadedDecls() int

*

* \brief Determine the number of overloaded declarations referenced by a
* \c CXCursor_OverloadedDeclRef cursor.
*
* \param cursor The cursor whose overloaded declarations are being queried.
*
* \returns The number of overloaded declarations referenced by \c cursor. If it
* is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.

func (Cursor) OverloadedDecl

func (c Cursor) OverloadedDecl(i int) Cursor

*

* \brief Retrieve a cursor for one of the overloaded declarations referenced
* by a \c CXCursor_OverloadedDeclRef cursor.
*
* \param cursor The cursor whose overloaded declarations are being queried.
*
* \param index The zero-based index into the set of overloaded declarations in
* the cursor.
*
* \returns A cursor representing the declaration referenced by the given
* \c cursor at the specified \c index. If the cursor does not have an
* associated set of overloaded declarations, or if the index is out of bounds,
* returns \c clang_getNullCursor();

func (Cursor) OverriddenCursors

func (c Cursor) OverriddenCursors() (o OverriddenCursors)

*

* \brief Determine the set of methods that are overridden by the given
* method.
*
* In both Objective-C and C++, a method (aka virtual member function,
* in C++) can override a virtual method in a base class. For
* Objective-C, a method is said to override any method in the class's
* interface (if we're coming from an implementation), its protocols,
* or its categories, that has the same selector and is of the same
* kind (class or instance). If no such method exists, the search
* continues to the class's superclass, its protocols, and its
* categories, and so on.
*
* For C++, a virtual member function overrides any virtual member
* function with the same signature that occurs in its base
* classes. With multiple inheritance, a virtual member function can
* override several virtual member functions coming from different
* base classes.
*
* In all cases, this function determines the immediate overridden
* method, rather than all of the overridden methods. For example, if
* a method is originally declared in a class A, then overridden in B
* (which in inherits from A) and also in C (which inherited from B),
* then the only overridden method returned from this function when
* invoked on C's method will be B's method. The client may then
* invoke this function again, given the previously-found overridden
* methods, to map out the complete method-override set.
*
* \param cursor A cursor representing an Objective-C or C++
* method. This routine will compute the set of methods that this
* method overrides.
*
* \param overridden A pointer whose pointee will be replaced with a
* pointer to an array of cursors, representing the set of overridden
* methods. If there are no overridden methods, the pointee will be
* set to NULL. The pointee must be freed via a call to
* \c clang_disposeOverriddenCursors().
*
* \param num_overridden A pointer to the number of overridden
* functions, will be set to the number of overridden functions in the
* array pointed to by \p overridden.

func (Cursor) ReferenceNameRange

func (c Cursor) ReferenceNameRange(flags NameRefFlags, pieceIdx uint) SourceRange

*

* \brief Given a cursor that references something else, return the source range
* covering that reference.
*
* \param C A cursor pointing to a member reference, a declaration reference, or
* an operator call.
* \param NameFlags A bitset with three independent flags:
* CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
* CXNameRange_WantSinglePiece.
* \param PieceIndex For contiguous names or when passing the flag
* CXNameRange_WantSinglePiece, only one piece with index 0 is
* available. When the CXNameRange_WantSinglePiece flag is not passed for a
* non-contiguous names, this index can be used to retreive the individual
* pieces of the name. See also CXNameRange_WantSinglePiece.
*
* \returns The piece of the name pointed to by the given cursor. If there is no
* name, or if the PieceIndex is out-of-range, a null-cursor will be returned.

func (Cursor) Referenced

func (c Cursor) Referenced() Cursor

* \brief For a cursor that is a reference, retrieve a cursor representing the

* entity that it references.
*
* Reference cursors refer to other entities in the AST. For example, an
* Objective-C superclass reference cursor refers to an Objective-C class.
* This function produces the cursor for the Objective-C class from the
* cursor for the superclass reference. If the input cursor is a declaration or
* definition, it returns that declaration or definition unchanged.
* Otherwise, returns the NULL cursor.

func (Cursor) ResultType

func (c Cursor) ResultType() Type

*

* \brief Retrieve the result type associated with a given cursor.  This only
*  returns a valid type of the cursor refers to a function or method.

func (Cursor) SemanticParent

func (c Cursor) SemanticParent() Cursor

*

* \brief Determine the semantic parent of the given cursor.
*
* The semantic parent of a cursor is the cursor that semantically contains
* the given \p cursor. For many declarations, the lexical and semantic parents
* are equivalent (the lexical parent is returned by
* \c clang_getCursorLexicalParent()). They diverge when declarations or
* definitions are provided out-of-line. For example:
*
* \code
* class C {
*  void f();
* };
*
* void C::f() { }
* \endcode
*
* In the out-of-line definition of \c C::f, the semantic parent is the
* the class \c C, of which this function is a member. The lexical parent is
* the place where the declaration actually occurs in the source code; in this
* case, the definition occurs in the translation unit. In general, the
* lexical parent for a given entity can change without affecting the semantics
* of the program, and the lexical parent of different declarations of the
* same entity may be different. Changing the semantic parent of a declaration,
* on the other hand, can have a major impact on semantics, and redeclarations
* of a particular entity should all have the same semantic context.
*
* In the example above, both declarations of \c C::f have \c C as their
* semantic context, while the lexical context of the first \c C::f is \c C
* and the lexical context of the second \c C::f is the translation unit.
*
* For global declarations, the semantic parent is the translation unit.

func (Cursor) SpecializedCursorTemplate

func (c Cursor) SpecializedCursorTemplate() Cursor

*

* \brief Given a cursor that may represent a specialization or instantiation
* of a template, retrieve the cursor that represents the template that it
* specializes or from which it was instantiated.
*
* This routine determines the template involved both for explicit
* specializations of templates and for implicit instantiations of the template,
* both of which are referred to as "specializations". For a class template
* specialization (e.g., \c std::vector<bool>), this routine will return
* either the primary template (\c std::vector) or, if the specialization was
* instantiated from a class template partial specialization, the class template
* partial specialization. For a class template partial specialization and a
* function template specialization (including instantiations), this
* this routine will return the specialized template.
*
* For members of a class template (e.g., member functions, member classes, or
* static data members), returns the specialized or instantiated member.
* Although not strictly "templates" in the C++ language, members of class
* templates have the same notions of specializations and instantiations that
* templates do, so this routine treats them similarly.
*
* \param C A cursor that may be a specialization of a template or a member
* of a template.
*
* \returns If the given cursor is a specialization or instantiation of a
* template or a member thereof, the template or member that it specializes or
* from which it was instantiated. Otherwise, returns a NULL cursor.

func (Cursor) Spelling

func (c Cursor) Spelling() string

Spelling returns the name of the entity referenced by this cursor.

func (Cursor) TemplateCursorKind

func (c Cursor) TemplateCursorKind() CursorKind

*

* \brief Given a cursor that represents a template, determine
* the cursor kind of the specializations would be generated by instantiating
* the template.
*
* This routine can be used to determine what flavor of function template,
* class template, or class template partial specialization is stored in the
* cursor. For example, it can describe whether a class template cursor is
* declared with "struct", "class" or "union".
*
* \param C The cursor to query. This cursor should represent a template
* declaration.
*
* \returns The cursor kind of the specializations that would be generated
* by instantiating the template \p C. If \p C is not a template, returns
* \c CXCursor_NoDeclFound.

func (Cursor) TranslationUnit

func (c Cursor) TranslationUnit() TranslationUnit

TranslationUnit returns the translation unit that a cursor originated from

func (Cursor) Type

func (c Cursor) Type() Type

Type retrieves the type of a cursor (if any).

func (Cursor) USR

func (c Cursor) USR() string

*

* \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
* by the given cursor.
*
* A Unified Symbol Resolution (USR) is a string that identifies a particular
* entity (function, class, variable, etc.) within a program. USRs can be
* compared across translation units to determine, e.g., when references in
* one translation refer to an entity defined in another translation unit.

func (Cursor) Visit

func (c Cursor) Visit(visitor CursorVisitor) bool

*

* \brief Visit the children of a particular cursor.
*
* This function visits all the direct children of the given cursor,
* invoking the given \p visitor function with the cursors of each
* visited child. The traversal may be recursive, if the visitor returns
* \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
* the visitor returns \c CXChildVisit_Break.
*
* \param parent the cursor whose child may be visited. All kinds of
* cursors can be visited, including invalid cursors (which, by
* definition, have no children).
*
* \param visitor the visitor function that will be invoked for each
* child of \p parent.
*
* \param client_data pointer data supplied by the client, which will
* be passed to the visitor each time it is invoked.
*
* \returns a non-zero value if the traversal was terminated
* prematurely by the visitor returning \c CXChildVisit_Break.

type CursorKind

type CursorKind uint32 //FIXME: use uint32? int64?

*

* \brief Describes the kind of entity that a cursor refers to.

func (CursorKind) IsAttribute

func (ck CursorKind) IsAttribute() bool

*

* \brief Determine whether the given cursor kind represents an attribute.

func (CursorKind) IsDeclaration

func (ck CursorKind) IsDeclaration() bool

IsDeclaration determines whether the cursor kind represents a declaration

func (CursorKind) IsExpression

func (ck CursorKind) IsExpression() bool

*

* \brief Determine whether the given cursor kind represents an expression.

func (CursorKind) IsInvalid

func (ck CursorKind) IsInvalid() bool

*

* \brief Determine whether the given cursor kind represents an invalid
* cursor.

func (CursorKind) IsPreprocessing

func (ck CursorKind) IsPreprocessing() bool

**

* \brief Determine whether the given cursor represents a preprocessing
* element, such as a preprocessor directive or macro instantiation.

func (CursorKind) IsReference

func (ck CursorKind) IsReference() bool

*

* IsReference determines whether the given cursor kind represents a simple
* reference.
*
* Note that other kinds of cursors (such as expressions) can also refer to
* other cursors. Use clang_getCursorReferenced() to determine whether a
* particular cursor refers to another entity.

func (CursorKind) IsStatement

func (ck CursorKind) IsStatement() bool

*

* \brief Determine whether the given cursor kind represents a statement.

func (CursorKind) IsTranslationUnit

func (ck CursorKind) IsTranslationUnit() bool

*

* \brief Determine whether the given cursor kind represents a translation
* unit.

func (CursorKind) IsUnexposed

func (ck CursorKind) IsUnexposed() bool

**

* \brief Determine whether the given cursor represents a currently
*  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).

func (CursorKind) Spelling

func (c CursorKind) Spelling() string

for debug/testing

type CursorSet

type CursorSet struct {
	// contains filtered or unexported fields
}

CursorSet is a fast container representing a set of Cursors.

func NewCursorSet

func NewCursorSet() CursorSet

NewCursorSet creates an empty CursorSet

func (CursorSet) Contains

func (c CursorSet) Contains(cursor Cursor) bool

Contains queries a CursorSet to see if it contains a specific Cursor

func (CursorSet) Dispose

func (c CursorSet) Dispose()

Dispose releases the memory associated with a CursorSet

func (CursorSet) Insert

func (c CursorSet) Insert(cursor Cursor) bool

Insert inserts a Cursor into the set and returns false if the cursor was already in that set.

type CursorVisitor

type CursorVisitor func(cursor, parent Cursor) (status ChildVisitResult)

*

* \brief Visitor invoked for each cursor found by a traversal.
*
* This visitor function will be invoked for each cursor found by
* clang_visitCursorChildren(). Its first argument is the cursor being
* visited, its second argument is the parent visitor for that cursor,
* and its third argument is the client data provided to
* clang_visitCursorChildren().
*
* The visitor should return one of the \c CXChildVisitResult values
* to direct clang_visitCursorChildren().

type File

type File struct {
	// contains filtered or unexported fields
}

A particular source file that is part of a translation unit.

func (File) ModTime

func (c File) ModTime() time.Time

ModTime retrieves the last modification time of the given file.

func (File) Name

func (c File) Name() string

Name retrieves the complete file and path name of the given file.

type Index

type Index struct {
	// contains filtered or unexported fields
}

An "index" that consists of a set of translation units that would typically be linked together into an executable or library

func NewIndex

func NewIndex(excludeDeclarationsFromPCH, displayDiagnostics int) Index

NewIndex provides a shared context for creating translation units. It provides two options:

- excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" declarations (when loading any new translation units). A "local" declaration is one that belongs in the translation unit itself and not in a precompiled header that was used by the translation unit. If zero, all declarations will be enumerated.

Here is an example:

// excludeDeclsFromPCH = 1, displayDiagnostics=1
Idx = clang_createIndex(1, 1);

// IndexTest.pch was produced with the following command:
// "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
TU = clang_createTranslationUnit(Idx, "IndexTest.pch");

// This will load all the symbols from 'IndexTest.pch'
clang_visitChildren(clang_getTranslationUnitCursor(TU),
                    TranslationUnitVisitor, 0);
clang_disposeTranslationUnit(TU);

// This will load all the symbols from 'IndexTest.c', excluding symbols
// from 'IndexTest.pch'.
char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
                                               0, 0);
clang_visitChildren(clang_getTranslationUnitCursor(TU),
                    TranslationUnitVisitor, 0);
clang_disposeTranslationUnit(TU);

This process of creating the 'pch', loading it separately, and using it (via -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks (which gives the indexer the same performance benefit as the compiler).

func (Index) CreateTranslationUnit

func (idx Index) CreateTranslationUnit(fname string) TranslationUnit

*

* \brief Create a translation unit from an AST file (-emit-ast).

func (Index) CreateTranslationUnitFromSourceFile

func (idx Index) CreateTranslationUnitFromSourceFile(fname string, args []string) TranslationUnit

*

* \brief Return the CXTranslationUnit for a given source file and the provided
* command line arguments one would pass to the compiler.
*
* Note: The 'source_filename' argument is optional.  If the caller provides a
* NULL pointer, the name of the source file is expected to reside in the
* specified command line arguments.
*
* Note: When encountered in 'clang_command_line_args', the following options
* are ignored:
*
*   '-c'
*   '-emit-ast'
*   '-fsyntax-only'
*   '-o <output file>'  (both '-o' and '<output file>' are ignored)
*
* \param CIdx The index object with which the translation unit will be
* associated.
*
* \param source_filename - The name of the source file to load, or NULL if the
* source file is included in \p clang_command_line_args.
*
* \param num_clang_command_line_args The number of command-line arguments in
* \p clang_command_line_args.
*
* \param clang_command_line_args The command-line arguments that would be
* passed to the \c clang executable if it were being invoked out-of-process.
* These command-line options will be parsed and will affect how the translation
* unit is parsed. Note that the following options are ignored: '-c',
* '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
*
* \param num_unsaved_files the number of unsaved file entries in \p
* unsaved_files.
*
* \param unsaved_files the files that have not yet been saved to disk
* but may be required for code completion, including the contents of
* those files.  The contents and name of these files (as specified by
* CXUnsavedFile) are copied when necessary, so the client only needs to
* guarantee their validity until the call to this function returns.

FIXME: handle unsaved-files

func (Index) Dispose

func (idx Index) Dispose()

Dispose destroys the given index.

The index must not be destroyed until all of the translation units created within that index have been destroyed.

func (Index) Parse

func (idx Index) Parse(fname string, args []string, options TranslationUnitFlags) TranslationUnit

*

* \brief Parse the given source file and the translation unit corresponding
* to that file.
*
* This routine is the main entry point for the Clang C API, providing the
* ability to parse a source file into a translation unit that can then be
* queried by other functions in the API. This routine accepts a set of
* command-line arguments so that the compilation can be configured in the same
* way that the compiler is configured on the command line.
*
* \param CIdx The index object with which the translation unit will be
* associated.
*
* \param source_filename The name of the source file to load, or NULL if the
* source file is included in \p command_line_args.
*
* \param command_line_args The command-line arguments that would be
* passed to the \c clang executable if it were being invoked out-of-process.
* These command-line options will be parsed and will affect how the translation
* unit is parsed. Note that the following options are ignored: '-c',
* '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
*
* \param num_command_line_args The number of command-line arguments in
* \p command_line_args.
*
* \param unsaved_files the files that have not yet been saved to disk
* but may be required for parsing, including the contents of
* those files.  The contents and name of these files (as specified by
* CXUnsavedFile) are copied when necessary, so the client only needs to
* guarantee their validity until the call to this function returns.
*
* \param num_unsaved_files the number of unsaved file entries in \p
* unsaved_files.
*
* \param options A bitmask of options that affects how the translation unit
* is managed but not its compilation. This should be a bitwise OR of the
* CXTranslationUnit_XXX flags.
*
* \returns A new translation unit describing the parsed code and containing
* any diagnostics produced by the compiler. If there is a failure from which
* the compiler cannot recover, returns NULL.

FIXME: handle unsaved-files

type LanguageKind

type LanguageKind uint32

LanguageKind describes the "language" of the entity referred to by a cursor.

type LinkageKind

type LinkageKind uint32

*

* \brief Describe the linkage of the entity referred to by a cursor.

type NameRefFlags

type NameRefFlags uint32

type OverriddenCursors

type OverriddenCursors struct {
	// contains filtered or unexported fields
}

func (OverriddenCursors) At

func (c OverriddenCursors) At(i int) Cursor

func (OverriddenCursors) Dispose

func (c OverriddenCursors) Dispose()

Dispose frees the set of overridden cursors

func (OverriddenCursors) Len

func (c OverriddenCursors) Len() int

type SourceLocation

type SourceLocation struct {
	// contains filtered or unexported fields
}

SourceLocation identifies a specific source location within a translation unit.

Use clang_getExpansionLocation() or clang_getSpellingLocation() to map a source location to a particular file, line, and column.

func NewNullLocation

func NewNullLocation() SourceLocation

NewNullLocation creates a NULL (invalid) source location.

func (SourceLocation) ExpansionLocation

func (l SourceLocation) ExpansionLocation() (f File, line, column, offset uint)

ExpansionLocation returns the file, line, column, and offset represented by the given source location.

If the location refers into a macro expansion, retrieves the location of the macro expansion.

file: if non-NULL, will be set to the file to which the given source location points.

line: if non-NULL, will be set to the line to which the given source location points.

column: if non-NULL, will be set to the column to which the given source location points.

offset: if non-NULL, will be set to the offset into the buffer to which the given source location points.

func (SourceLocation) InstantiationLocation

func (l SourceLocation) InstantiationLocation() (file File, line, column, offset uint)

*

* \brief Legacy API to retrieve the file, line, column, and offset represented
* by the given source location.
*
* This interface has been replaced by the newer interface
* \see clang_getExpansionLocation(). See that interface's documentation for
* details.

func (SourceLocation) PresumedLocation

func (l SourceLocation) PresumedLocation() (fname string, line, column uint)

*

* \brief Retrieve the file, line, column, and offset represented by
* the given source location, as specified in a # line directive.
*
* Example: given the following source code in a file somefile.c
*
* #123 "dummy.c" 1
*
* static int func(void)
* {
*     return 0;
* }
*
* the location information returned by this function would be
*
* File: dummy.c Line: 124 Column: 12
*
* whereas clang_getExpansionLocation would have returned
*
* File: somefile.c Line: 3 Column: 12
*
* \param location the location within a source file that will be decomposed
* into its parts.
*
* \param filename [out] if non-NULL, will be set to the filename of the
* source location. Note that filenames returned will be for "virtual" files,
* which don't necessarily exist on the machine running clang - e.g. when
* parsing preprocessed output obtained from a different environment. If
* a non-NULL value is passed in, remember to dispose of the returned value
* using \c clang_disposeString() once you've finished with it. For an invalid
* source location, an empty string is returned.
*
* \param line [out] if non-NULL, will be set to the line number of the
* source location. For an invalid source location, zero is returned.
*
* \param column [out] if non-NULL, will be set to the column number of the
* source location. For an invalid source location, zero is returned.

func (SourceLocation) SpellingLocation

func (l SourceLocation) SpellingLocation() (file File, line, column, offset uint)

*

* \brief Retrieve the file, line, column, and offset represented by
* the given source location.
*
* If the location refers into a macro instantiation, return where the
* location was originally spelled in the source file.
*
* \param location the location within a source file that will be decomposed
* into its parts.
*
* \param file [out] if non-NULL, will be set to the file to which the given
* source location points.
*
* \param line [out] if non-NULL, will be set to the line to which the given
* source location points.
*
* \param column [out] if non-NULL, will be set to the column to which the given
* source location points.
*
* \param offset [out] if non-NULL, will be set to the offset into the
* buffer to which the given source location points.

type SourceRange

type SourceRange struct {
	// contains filtered or unexported fields
}

SourceRange identifies a half-open character range in the source code.

Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the starting and end locations from a source range, respectively.

func NewNullRange

func NewNullRange() SourceRange

NewNullRange creates a NULL (invalid) source range.

func NewRange

func NewRange(beg, end SourceLocation) SourceRange

NewRange creates a source range given the beginning and ending source locations.

func (SourceRange) End

func (s SourceRange) End() SourceLocation

*

* \brief Retrieve a source location representing the last character within a
* source range.

func (SourceRange) IsNull

func (r SourceRange) IsNull() bool

IsNull checks if the underlying source range is null.

func (SourceRange) Start

func (s SourceRange) Start() SourceLocation

*

* \brief Retrieve a source location representing the first character within a
* source range.

type Token

type Token struct {
	// contains filtered or unexported fields
}

Token is a single preprocessing token.

func (Token) Kind

func (t Token) Kind() TokenKind

Kind determines the kind of this token

type TokenKind

type TokenKind uint32

TokenKind describes a kind of token

type Tokens

type Tokens struct {
	// contains filtered or unexported fields
}

an array of tokens

func Tokenize

func Tokenize(tu TranslationUnit, src SourceRange) Tokens

*

* \brief Tokenize the source code described by the given range into raw
* lexical tokens.
*
* \param TU the translation unit whose text is being tokenized.
*
* \param Range the source range in which text should be tokenized. All of the
* tokens produced by tokenization will fall within this source range,
*
* \param Tokens this pointer will be set to point to the array of tokens
* that occur within the given source range. The returned pointer must be
* freed with clang_disposeTokens() before the translation unit is destroyed.
*
* \param NumTokens will be set to the number of tokens in the \c *Tokens
* array.
*

func (Tokens) Annotate

func (t Tokens) Annotate() []Cursor

*

* \brief 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.
*
* This token-annotation routine is equivalent to invoking
* clang_getCursor() for the source locations of each of the
* tokens. The cursors provided are filtered, so that only those
* cursors that have a direct correspondence to the token are
* accepted. For example, given a function call \c f(x),
* clang_getCursor() would provide the following cursors:
*
*   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
*   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
*   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
*
* Only the first and last of these cursors will occur within the
* annotate, since the tokens "f" and "x' directly refer to a function
* and a variable, respectively, but the parentheses are just a small
* part of the full syntax of the function call expression, which is
* not provided as an annotation.
*
* \param TU the translation unit that owns the given tokens.
*
* \param Tokens the set of tokens to annotate.
*
* \param NumTokens the number of tokens in \p Tokens.
*
* \param Cursors an array of \p NumTokens cursors, whose contents will be
* replaced with the cursors corresponding to each token.

func (Tokens) Dispose

func (t Tokens) Dispose()

*

* \brief Free the given set of tokens.

type TranslationUnit

type TranslationUnit struct {
	// contains filtered or unexported fields
}

A single translation unit, which resides in an index

func (TranslationUnit) Cursor

func (tu TranslationUnit) Cursor(loc SourceLocation) Cursor

CursorOf maps a source location to the cursor that describes the entity at that location in the source code.

clang_getCursor() maps an arbitrary source location within a translation unit down to the most specific cursor that describes the entity at that location. For example, given an expression \c x + y, invoking clang_getCursor() with a source location pointing to "x" will return the cursor for "x"; similarly for "y". If the cursor points anywhere between "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() will return a cursor referring to the "+" expression.

Returns a cursor representing the entity at the given source location, or a NULL cursor if no such entity can be found.

func (TranslationUnit) Dispose

func (tu TranslationUnit) Dispose()

*

* \brief Destroy the specified CXTranslationUnit object.

func (TranslationUnit) File

func (tu TranslationUnit) File(file_name string) File

func (TranslationUnit) IsFileMultipleIncludeGuarded

func (tu TranslationUnit) IsFileMultipleIncludeGuarded(file File) bool

IsFileMultipleIncludeGuarded determines whether the given header is guarded against multiple inclusions, either with the conventional #ifndef/#define/#endif macro guards or with #pragma once.

func (TranslationUnit) Location

func (tu TranslationUnit) Location(f File, line, column uint) SourceLocation

Location returns the source location associated with a given file/line/column in a particular translation unit.

func (TranslationUnit) LocationForOffset

func (tu TranslationUnit) LocationForOffset(f File, offset uint) SourceLocation

LocationForOffset returns the source location associated with a given character offset in a particular translation unit.

func (TranslationUnit) Save

func (tu TranslationUnit) Save(fname string, options uint) uint32

*

* \brief Saves a translation unit into a serialized representation of
* that translation unit on disk.
*
* Any translation unit that was parsed without error can be saved
* into a file. The translation unit can then be deserialized into a
* new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
* if it is an incomplete translation unit that corresponds to a
* header, used as a precompiled header when parsing other translation
* units.
*
* \param TU The translation unit to save.
*
* \param FileName The file to which the translation unit will be saved.
*
* \param options A bitmask of options that affects how the translation unit
* is saved. This should be a bitwise OR of the
* CXSaveTranslationUnit_XXX flags.
*
* \returns A value that will match one of the enumerators of the CXSaveError
* enumeration. Zero (CXSaveError_None) indicates that the translation unit was
* saved successfully, while a non-zero value indicates that a problem occurred.

func (TranslationUnit) Spelling

func (tu TranslationUnit) Spelling() string

*

* \brief Get the original translation unit source file name.

func (TranslationUnit) ToCursor

func (tu TranslationUnit) ToCursor() Cursor

*

* \brief Retrieve the cursor that represents the given translation unit.
*
* The translation unit cursor can be used to start traversing the
* various declarations within the given translation unit.

func (TranslationUnit) TokenExtent

func (tu TranslationUnit) TokenExtent(tok Token) SourceRange

*

* \brief Retrieve a source range that covers the given token.

func (TranslationUnit) TokenLocation

func (tu TranslationUnit) TokenLocation(tok Token) SourceLocation

*

* \brief Retrieve the source location of the given token.

func (TranslationUnit) TokenSpelling

func (tu TranslationUnit) TokenSpelling(tok Token) string

*

* \brief Determine 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.

type TranslationUnitFlags

type TranslationUnitFlags uint32

*

* \brief Flags that control the creation of translation units.
*
* The enumerators in this enumeration type are meant to be bitwise
* ORed together to specify which options should be used when
* constructing the translation unit.

type Type

type Type struct {
	// contains filtered or unexported fields
}

Type represents the type of an element in the abstract syntax tree.

func (Type) ArrayElementType

func (t Type) ArrayElementType() Type

*

* \brief Return the element type of an array type.
*
* If a non-array type is passed in, an invalid type is returned.

func (Type) ArraySize

func (t Type) ArraySize() int64

*

* \brief Return the the array size of a constant array.
*
* If a non-array type is passed in, -1 is returned.

func (Type) CanonicalType

func (t Type) CanonicalType() Type

CanonicalType returns the canonical type for a Type.

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'.

func (Type) Declaration

func (t Type) Declaration() Cursor

Declaration returns the cursor for the declaration of the given type.

func (Type) IsConstQualified

func (t Type) IsConstQualified() bool

IsConstQualified determines whether a Type has the "const" qualifier set, without looking through typedefs that may have added "const" at a different level.

func (Type) IsPOD

func (t Type) IsPOD() bool

*

* \brief Return 1 if the CXType is a POD (plain old data) type, and 0
*  otherwise.

func (Type) IsRestrictQualified

func (t Type) IsRestrictQualified() bool

IsRestrictQualified determines whether a Type has the "restrict" qualifier set, without looking through typedefs that may have added "restrict" at a different level.

func (Type) IsVolatileQualified

func (t Type) IsVolatileQualified() bool

IsVolatileQualified determines whether a Type has the "volatile" qualifier set, without looking through typedefs that may have added "volatile" at a different level.

func (Type) PointeeType

func (t Type) PointeeType() Type

PointeeType (for pointer types), returns the type of the pointee.

func (Type) ResultType

func (t Type) ResultType() Type

*

* \brief Retrieve the result type associated with a function type.

type TypeKind

type TypeKind uint32

TypeKind describes the kind of a type

func (TypeKind) Spelling

func (t TypeKind) Spelling() string

Spelling returns the spelling of a given TypeKind.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL