clang

package module
Version: v0.0.0-...-e9ad31c Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2016 License: BSD-2-Clause Imports: 6 Imported by: 5

README

go-clang

Build Status Build Status

Naive Go bindings to the C-API of CLang.

WARNING - DEPRECATED

WARNING: This repository is DEPRECATED. Please use instead one of the clang bindings under github.com/go-clang.


Installation

As there is no pkg-config entry for clang, you may have to tinker a bit the various CFLAGS and LDFLAGS options, or pass them via the shell:

$ CGO_CFLAGS="-I`llvm-config --includedir`" \
  CGO_LDFLAGS="-L`llvm-config --libdir`" \
  go get github.com/sbinet/go-clang

Example

An example on how to use the AST visitor of CLang is provided here:

https://github.com/sbinet/go-clang/blob/master/go-clang-dump/main.go

package main

import (
	"flag"
	"fmt"
	"os"

	"github.com/sbinet/go-clang"
)

var fname *string = flag.String("fname", "", "the file to analyze")

func main() {
	fmt.Printf(":: go-clang-dump...\n")
	flag.Parse()
	fmt.Printf(":: fname: %s\n", *fname)
	fmt.Printf(":: args: %v\n", flag.Args())
	if *fname == "" {
		flag.Usage()
		fmt.Printf("please provide a file name to analyze\n")
		os.Exit(1)
	}
	idx := clang.NewIndex(0, 1)
	defer idx.Dispose()

	nidx := 0
	args := []string{}
	if len(flag.Args()) > 0 && flag.Args()[0] == "-" {
		nidx = 1
		args = make([]string, len(flag.Args()[nidx:]))
		copy(args, flag.Args()[nidx:])
	}

	tu := idx.Parse(*fname, args, nil, 0)

	defer tu.Dispose()

	fmt.Printf("tu: %s\n", tu.Spelling())
	cursor := tu.ToCursor()
	fmt.Printf("cursor-isnull: %v\n", cursor.IsNull())
	fmt.Printf("cursor: %s\n", cursor.Spelling())
	fmt.Printf("cursor-kind: %s\n", cursor.Kind().Spelling())

	tu_fname := tu.File(*fname).Name()
	fmt.Printf("tu-fname: %s\n", tu_fname)

	fct := func(cursor, parent clang.Cursor) clang.ChildVisitResult {
		if cursor.IsNull() {
			fmt.Printf("cursor: <none>\n")
			return clang.CVR_Continue
		}
		fmt.Printf("%s: %s (%s)\n",
			cursor.Kind().Spelling(), cursor.Spelling(), cursor.USR())
		switch cursor.Kind() {
		case clang.CK_ClassDecl, clang.CK_EnumDecl,
			clang.CK_StructDecl, clang.CK_Namespace:
			return clang.CVR_Recurse
		}
		return clang.CVR_Continue
	}

	cursor.Visit(fct)

	fmt.Printf(":: bye.\n")
}

which can be installed like so:

$ go get github.com/sbinet/go-clang/go-clang-dump

Limitations

  • Only a subset of the C-API of CLang has been provided yet. More will come as patches flow in and time goes by.

  • Go-doc documentation is lagging (but the doxygen docs from the C-API of CLang are in the .go files)

Documentation

Is available at godoc:

http://godoc.org/github.com/sbinet/go-clang

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 (
	CallingConv_Default               CallingConv = C.CXCallingConv_Default
	CallingConv_C                                 = C.CXCallingConv_C
	CallingConv_X86StdCall                        = C.CXCallingConv_X86StdCall
	CallingConv_X86FastCall                       = C.CXCallingConv_X86FastCall
	CallingConv_X86ThisCall                       = C.CXCallingConv_X86ThisCall
	CallingConv_X86Pascal                         = C.CXCallingConv_X86Pascal
	CallingConv_CallingConv_AAPCS                 = C.CXCallingConv_AAPCS
	CallingConv_CallingConv_AAPCS_VFP             = C.CXCallingConv_AAPCS_VFP
	CallingConv_PnaclCall                         = C.CXCallingConv_PnaclCall
	CallingConv_IntelOclBicc                      = C.CXCallingConv_IntelOclBicc
	CallingConv_X86_64Win64                       = C.CXCallingConv_X86_64Win64
	CallingConv_X86_64SysV                        = C.CXCallingConv_X86_64SysV

	CallingConv_Invalid   CallingConv = C.CXCallingConv_Invalid
	CallingConv_Unexposed             = C.CXCallingConv_Unexposed
)
View Source
const (
	/**
	 * \brief Null comment.  No AST node is constructed at the requested location
	 * because there is no text or a syntax error.
	 */
	Comment_Null CommentKind = C.CXComment_Null

	/**
	 * \brief Plain text.  Inline content.
	 */
	Comment_Text = C.CXComment_Text

	/**
	 * \brief A command with word-like arguments that is considered inline content.
	 *
	 * For example: \\c command.
	 */
	Comment_InlineCommand = C.CXComment_InlineCommand

	/**
	 * \brief HTML start tag with attributes (name-value pairs).  Considered
	 * inline content.
	 *
	 * For example:
	 * \verbatim
	 * <br> <br /> <a href="http://example.org/">
	 * \endverbatim
	 */
	Comment_HTMLStartTag = C.CXComment_HTMLStartTag

	/**
	 * \brief HTML end tag.  Considered inline content.
	 *
	 * For example:
	 * \verbatim
	 * </a>
	 * \endverbatim
	 */
	Comment_HTMLEndTag = C.CXComment_HTMLEndTag

	/**
	 * \brief A paragraph, contains inline comment.  The paragraph itself is
	 * block content.
	 */
	Comment_Paragraph = C.CXComment_Paragraph

	/**
	 * \brief A command that has zero or more word-like arguments (number of
	 * word-like arguments depends on command name) and a paragraph as an
	 * argument.  Block command is block content.
	 *
	 * Paragraph argument is also a child of the block command.
	 *
	 * For example: \\brief has 0 word-like arguments and a paragraph argument.
	 *
	 * AST nodes of special kinds that parser knows about (e. g., \\param
	 * command) have their own node kinds.
	 */
	Comment_BlockCommand = C.CXComment_BlockCommand

	/**
	 * \brief A \\param or \\arg command that describes the function parameter
	 * (name, passing direction, description).
	 *
	 * For example: \\param [in] ParamName description.
	 */
	Comment_ParamCommand = C.CXComment_ParamCommand

	/**
	 * \brief A \\tparam command that describes a template parameter (name and
	 * description).
	 *
	 * For example: \\tparam T description.
	 */
	Comment_TParamCommand = C.CXComment_TParamCommand

	/**
	 * \brief A verbatim block command (e. g., preformatted code).  Verbatim
	 * block has an opening and a closing command and contains multiple lines of
	 * text (\c CXComment_VerbatimBlockLine child nodes).
	 *
	 * For example:
	 * \\verbatim
	 * aaa
	 * \\endverbatim
	 */
	Comment_VerbatimBlockCommand = C.CXComment_VerbatimBlockCommand

	/**
	 * \brief A line of text that is contained within a
	 * CXComment_VerbatimBlockCommand node.
	 */
	Comment_VerbatimBlockLine = C.CXComment_VerbatimBlockLine

	/**
	 * \brief A verbatim line command.  Verbatim line has an opening command,
	 * a single line of text (up to the newline after the opening command) and
	 * has no closing command.
	 */
	Comment_VerbatimLine = C.CXComment_VerbatimLine

	/**
	 * \brief A full comment attached to a declaration, contains block content.
	 */
	Comment_FullComment = C.CXComment_FullComment
)
View Source
const (
	/**
	 * \brief Command argument should be rendered in a normal font.
	 */
	CommentInlineCommandRenderKind_Normal CommentInlineCommandRenderKind = C.CXCommentInlineCommandRenderKind_Normal

	/**
	 * \brief Command argument should be rendered in a bold font.
	 */
	CommentInlineCommandRenderKind_Bold = C.CXCommentInlineCommandRenderKind_Bold

	/**
	 * \brief Command argument should be rendered in a monospaced font.
	 */
	CommentInlineCommandRenderKind_Monospaced = C.CXCommentInlineCommandRenderKind_Monospaced

	/**
	 * \brief Command argument should be rendered emphasized (typically italic
	 * font).
	 */
	CommentInlineCommandRenderKind_Emphasized = C.CXCommentInlineCommandRenderKind_Emphasized
)
View Source
const (
	/**
	 * \brief The parameter is an input parameter.
	 */
	CommentParamPassDirection_In = C.CXCommentParamPassDirection_In

	/**
	 * \brief The parameter is an output parameter.
	 */
	CommentParamPassDirection_Out = C.CXCommentParamPassDirection_Out

	/**
	 * \brief The parameter is an input and output parameter.
	 */
	CommentParamPassDirection_InOut = C.CXCommentParamPassDirection_InOut
)
View Source
const (
	/**
	 * \brief Whether to include macros within the set of code
	 * completions returned.
	 */
	CodeCompleteFlags_IncludeMacros CodeCompleteFlags = C.CXCodeComplete_IncludeMacros

	/**
	 * \brief Whether to include code patterns for language constructs
	 * within the set of code completions, e.g., for loops.
	 */
	CodeCompleteFlags_IncludeCodePatterns = C.CXCodeComplete_IncludeCodePatterns

	/**
	 * \brief Whether to include brief documentation within the set of code
	 * completions returned.
	 */
	CodeCompleteFlags_IncludeBriefComments = C.CXCodeComplete_IncludeBriefComments
)
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

	/** \brief Represents the "self" expression in a ObjC method.
	 */
	CK_ObjCSelfExpr = C.CXCursor_ObjCSelfExpr

	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 GCC inline assembly statement extension.
	 */
	CK_GCCAsmStmt = C.CXCursor_GCCAsmStmt
	CK_AsmStmt    = CK_GCCAsmStmt

	/** \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 A MS inline assembly statement extension.
	 */
	CK_MSAsmStmt = C.CXCursor_MSAsmStmt

	/** \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

	/** \brief OpenMP parallel directive.
	 */
	CK_OMPParallelDirective = C.CXCursor_OMPParallelDirective

	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

	/* Extra Declarations */
	/**
	 * \brief A module import declaration.
	 */
	CK_ModuleImportDecl = C.CXCursor_ModuleImportDecl
	CK_FirstExtraDecl   = C.CXCursor_FirstExtraDecl
	CK_LastExtraDecl    = C.CXCursor_LastExtraDecl
)
View Source
const (
	/**
	 * \brief A diagnostic that has been suppressed, e.g., by a command-line
	 * option.
	 */
	Diagnostic_Ignored = C.CXDiagnostic_Ignored

	/**
	 * \brief This diagnostic is a note that should be attached to the
	 * previous (non-note) diagnostic.
	 */
	Diagnostic_Note = C.CXDiagnostic_Note

	/**
	 * \brief This diagnostic indicates suspicious code that may not be
	 * wrong.
	 */
	Diagnostic_Warning = C.CXDiagnostic_Warning

	/**
	 * \brief This diagnostic indicates that the code is ill-formed.
	 */
	Diagnostic_Error = C.CXDiagnostic_Error

	/**
	 * \brief This diagnostic indicates that the code is ill-formed such
	 * that future parser recovery is unlikely to produce useful
	 * results.
	 */
	Diagnostic_Fatal = C.CXDiagnostic_Fatal
)
View Source
const (
	/**
	 * \brief Display the source-location information where the
	 * diagnostic was located.
	 *
	 * When set, diagnostics will be prefixed by the file, line, and
	 * (optionally) column to which the diagnostic refers. For example,
	 *
	 * \code
	 * test.c:28: warning: extra tokens at end of #endif directive
	 * \endcode
	 *
	 * This option corresponds to the clang flag \c -fshow-source-location.
	 */
	Diagnostic_DisplaySourceLocation = C.CXDiagnostic_DisplaySourceLocation

	/**
	 * \brief If displaying the source-location information of the
	 * diagnostic, also include the column number.
	 *
	 * This option corresponds to the clang flag \c -fshow-column.
	 */
	Diagnostic_DisplayColumn = C.CXDiagnostic_DisplayColumn

	/**
	 * \brief If displaying the source-location information of the
	 * diagnostic, also include information about source ranges in a
	 * machine-parsable format.
	 *
	 * This option corresponds to the clang flag
	 * \c -fdiagnostics-print-source-range-info.
	 */
	Diagnostic_DisplaySourceRanges = C.CXDiagnostic_DisplaySourceRanges

	/**
	 * \brief Display the option name associated with this diagnostic, if any.
	 *
	 * The option name displayed (e.g., -Wconversion) will be placed in brackets
	 * after the diagnostic text. This option corresponds to the clang flag
	 * \c -fdiagnostics-show-option.
	 */
	Diagnostic_DisplayOption = C.CXDiagnostic_DisplayOption

	/**
	 * \brief Display the category number associated with this diagnostic, if any.
	 *
	 * The category number is displayed within brackets after the diagnostic text.
	 * This option corresponds to the clang flag
	 * \c -fdiagnostics-show-category=id.
	 */
	Diagnostic_DisplayCategoryId = C.CXDiagnostic_DisplayCategoryId

	/**
	 * \brief Display the category name associated with this diagnostic, if any.
	 *
	 * The category name is displayed within brackets after the diagnostic text.
	 * This option corresponds to the clang flag
	 * \c -fdiagnostics-show-category=name.
	 */
	Diagnostic_DisplayCategoryName = C.CXDiagnostic_DisplayCategoryName
)
View Source
const (

	/** \brief No ref-qualifier was provided. */
	RQK_None RefQualifierKind = C.CXRefQualifier_None

	/** \brief An lvalue ref-qualifier was provided (\c &). */
	RQK_LValue = C.CXRefQualifier_LValue
	/** \brief An rvalue ref-qualifier was provided (\c &&). */
	RQK_RValue = C.CXRefQualifier_RValue
)
View Source
const (
	/**
	 * \brief Function returned successfully.
	 */
	Result_Success Result = C.CXResult_Success
	/**
	 * \brief One of the parameters was invalid for the function.
	 */
	Result_Invalid = C.CXResult_Invalid
	/**
	 * \brief The function was terminated by a callback (e.g. it returned
	 * CXVisit_Break)
	 */
	Result_VisitBreak = C.CXResult_VisitBreak
)
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 (
	/**
	 * \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 Used to indicate that the translation unit will be serialized with
	 * \c clang_saveTranslationUnit.
	 *
	 * This option is typically used when parsing a header with the intent of
	 * producing a precompiled header.
	 */
	TU_ForSerialization = C.CXTranslationUnit_ForSerialization

	/**
	 * \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 function/method bodies should be skipped while
	 * parsing.
	 *
	 * This option can be used to search for declarations/definitions while
	 * ignoring the usages.
	 */
	TU_SkipFunctionBodies = C.CXTranslationUnit_SkipFunctionBodies

	/**
	 * \brief Used to indicate that brief documentation comments should be
	 * included into the set of code completions returned from this translation
	 * unit.
	 */
	TU_IncludeBriefCommentsInCodeCompletion = C.CXTranslationUnit_IncludeBriefCommentsInCodeCompletion
)
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
	TK_Vector              = C.CXType_Vector
	TK_IncompleteArray     = C.CXType_IncompleteArray
	TK_VariableArray       = C.CXType_VariableArray
	TK_DependentSizedArray = C.CXType_DependentSizedArray
	TK_MemberPointer       = C.CXType_MemberPointer
)
View Source
const (
	/**
	 * \brief Type is of kind CXType_Invalid.
	 */
	TLE_Invalid TypeLayoutError = C.CXTypeLayoutError_Invalid

	/**
	 * \brief The type is an incomplete Type.
	 */
	TLE_Incomplete = C.CXTypeLayoutError_Incomplete

	/**
	 * \brief The type is a dependent Type.
	 */
	TLE_Dependent = C.CXTypeLayoutError_Dependent

	/**
	 * \brief The type is not a constant size type.
	 */
	TLE_NotConstantSize = C.CXTypeLayoutError_NotConstantSize

	/**
	 * \brief The Field name is not valid for this record.
	 */
	TLE_InvalidFieldName = C.CXTypeLayoutError_InvalidFieldName
)

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
)

func (AvailabilityKind) String

func (ak AvailabilityKind) String() string

type CallingConv

type CallingConv uint32

CallingConv describes the calling convention of a function type

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, callback_id unsafe.Pointer) (status ChildVisitResult)

type CodeCompleteFlags

type CodeCompleteFlags int

*

  • \brief Flags that can be passed to \c clang_codeCompleteAt() to
  • modify its behavior. *
  • The enumerators in this enumeration can be bitwise-OR'd together to
  • provide multiple options to \c clang_codeCompleteAt().

type CodeCompleteResults

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

*

  • \brief Contains the results of code-completion. *
  • This data structure contains the results of code completion, as
  • produced by \c clang_codeCompleteAt(). Its contents must be freed by
  • \c clang_disposeCodeCompleteResults.

func (CodeCompleteResults) Diagnostics

func (ccr CodeCompleteResults) Diagnostics() (ret Diagnostics)

*

  • \brief Retrieve a diagnostic associated with the given code completion. *
  • \param Results the code completion results to query.
  • \param Index the zero-based diagnostic number to retrieve. *
  • \returns the requested diagnostic. This diagnostic must be freed
  • via a call to \c clang_disposeDiagnostic().

func (CodeCompleteResults) Dispose

func (ccr CodeCompleteResults) Dispose()

*

  • \brief Free the given set of code-completion results.

func (CodeCompleteResults) IsValid

func (ccr CodeCompleteResults) IsValid() bool

func (CodeCompleteResults) Results

func (ccr CodeCompleteResults) Results() (ret []CompletionResult)

TODO(): is there a better way to handle this?

func (CodeCompleteResults) Sort

func (ccr CodeCompleteResults) Sort()

*

  • \brief Sort the code-completion results in case-insensitive alphabetical
  • order. *
  • \param Results The set of results to sort.
  • \param NumResults The number of results in \p Results.

type Comment

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

*

  • \brief A comment AST node.

func (Comment) Child

func (c Comment) Child(idx int) Comment

*

  • \param Comment AST node of any kind. *
  • \param ChildIdx child index (zero-based). *
  • \returns the specified child of the AST node.

func (Comment) HasTrailingNewline

func (c Comment) HasTrailingNewline() bool

*

  • \returns non-zero if \c Comment is inline content and has a newline
  • immediately following it in the comment text. Newlines between paragraphs
  • do not count.

func (Comment) IsWhitespace

func (c Comment) IsWhitespace() bool

*

  • \brief A \c CXComment_Paragraph node is considered whitespace if it contains
  • only \c CXComment_Text nodes that are empty or whitespace. *
  • Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are
  • never considered whitespace. *
  • \returns non-zero if \c Comment is whitespace.

func (Comment) Kind

func (c Comment) Kind() CommentKind

*

  • \param Comment AST node of any kind. *
  • \returns the type of the AST node.

func (Comment) NumChildren

func (c Comment) NumChildren() int

*

  • \param Comment AST node of any kind. *
  • \returns number of children of the AST node.

func (Comment) TextComment

func (c Comment) TextComment() string

*

  • \param Comment a \c CXComment_Text AST node. *
  • \returns text contained in the AST node.

type CommentInlineCommandRenderKind

type CommentInlineCommandRenderKind int

*

  • \brief The most appropriate rendering mode for an inline command, chosen on
  • command semantics in Doxygen.

type CommentKind

type CommentKind int

*

  • \brief Describes the type of the comment AST node (\c CXComment). A comment
  • node can be considered block content (e. g., paragraph), inline content
  • (plain text) or neither (the root AST node).

type CommentParamPassDirection

type CommentParamPassDirection int

*

  • \brief Describes parameter passing direction for \\param or \\arg command.

type CompilationDatabase

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

*

  • A compilation database holds all information used to compile files in a
  • project. For each file in the database, it can be queried for the working
  • directory or the command line used for the compiler invocation. *
  • Must be freed by \c clang_CompilationDatabase_dispose

func NewCompilationDatabase

func NewCompilationDatabase(builddir string) (CompilationDatabase, error)

*

  • \brief Creates a compilation database from the database found in directory
  • buildDir. For example, CMake can output a compile_commands.json which can
  • be used to build the database. *
  • It must be freed by \c clang_CompilationDatabase_dispose.

func (*CompilationDatabase) Dispose

func (db *CompilationDatabase) Dispose()

*

  • \brief Free the given compilation database

func (*CompilationDatabase) GetAllCompileCommands

func (db *CompilationDatabase) GetAllCompileCommands() CompileCommands

*

  • \brief Get all the compile commands in the given compilation database.

func (*CompilationDatabase) GetCompileCommands

func (db *CompilationDatabase) GetCompileCommands(fname string) CompileCommands

*

  • \brief Find the compile commands used for a file. The compile commands
  • must be freed by \c clang_CompileCommands_dispose.

type CompilationDatabaseError

type CompilationDatabaseError int

*

  • \brief Error codes for Compilation Database
const (
	/*
	 * \brief No error occurred
	 */
	CompilationDatabase_NoError CompilationDatabaseError = C.CXCompilationDatabase_NoError

	/*
	 * \brief Database can not be loaded
	 */
	CompilationDatabase_CanNotLoadDatabase = C.CXCompilationDatabase_CanNotLoadDatabase
)

func (CompilationDatabaseError) Error

func (err CompilationDatabaseError) Error() string

type CompileCommand

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

*

  • \brief Represents the command line invocation to compile a specific file.

func (CompileCommand) GetArg

func (cmd CompileCommand) GetArg(idx int) string

*

  • \brief Get the I'th argument value in the compiler invocations *
  • Invariant :
  • - argument 0 is the compiler executable

func (CompileCommand) GetDirectory

func (cmd CompileCommand) GetDirectory() string

*

  • \brief Get the working directory where the CompileCommand was executed from

func (CompileCommand) GetNumArgs

func (cmd CompileCommand) GetNumArgs() int

*

  • \brief Get the number of arguments in the compiler invocation. *

type CompileCommands

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

*

  • \brief Contains the results of a search in the compilation database *
  • When searching for the compile command for a file, the compilation db can
  • return several commands, as the file may have been compiled with
  • different options in different places of the project. This choice of compile
  • commands is wrapped in this opaque data structure. It must be freed by
  • \c clang_CompileCommands_dispose.

func (CompileCommands) GetCommand

func (cmds CompileCommands) GetCommand(idx int) CompileCommand

*

  • \brief Get the I'th CompileCommand for a file *
  • Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands)

func (CompileCommands) GetSize

func (cmds CompileCommands) GetSize() int

*

  • \brief Get the number of CompileCommand we have for a file

type CompletionChunk

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

func (CompletionChunk) Kind

*

  • \brief Determine the kind of a particular chunk within a completion string. *
  • \param completion_string the completion string to query. *
  • \param chunk_number the 0-based index of the chunk in the completion string. *
  • \returns the kind of the chunk at the index \c chunk_number.

func (CompletionChunk) String

func (cc CompletionChunk) String() string

func (CompletionChunk) Text

func (cc CompletionChunk) Text() string

*

  • \brief Retrieve the text associated with a particular chunk within a
  • completion string. *
  • \param completion_string the completion string to query. *
  • \param chunk_number the 0-based index of the chunk in the completion string. *
  • \returns the text associated with the chunk at index \c chunk_number.

type CompletionChunkKind

type CompletionChunkKind int

*

  • \brief Describes a single piece of text within a code-completion string. *
  • Each "chunk" within a code-completion string (\c CXCompletionString) is
  • either a piece of text with a specific "kind" that describes how that text
  • should be interpreted by the client or is another completion string.
const (
	/**
	 * \brief A code-completion string that describes "optional" text that
	 * could be a part of the template (but is not required).
	 *
	 * The Optional chunk is the only kind of chunk that has a code-completion
	 * string for its representation, which is accessible via
	 * \c clang_getCompletionChunkCompletionString(). The code-completion string
	 * describes an additional part of the template that is completely optional.
	 * For example, optional chunks can be used to describe the placeholders for
	 * arguments that match up with defaulted function parameters, e.g. given:
	 *
	 * \code
	 * void f(int x, float y = 3.14, double z = 2.71828);
	 * \endcode
	 *
	 * The code-completion string for this function would contain:
	 *   - a TypedText chunk for "f".
	 *   - a LeftParen chunk for "(".
	 *   - a Placeholder chunk for "int x"
	 *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
	 *       - a Comma chunk for ","
	 *       - a Placeholder chunk for "float y"
	 *       - an Optional chunk containing the last defaulted argument:
	 *           - a Comma chunk for ","
	 *           - a Placeholder chunk for "double z"
	 *   - a RightParen chunk for ")"
	 *
	 * There are many ways to handle Optional chunks. Two simple approaches are:
	 *   - Completely ignore optional chunks, in which case the template for the
	 *     function "f" would only include the first parameter ("int x").
	 *   - Fully expand all optional chunks, in which case the template for the
	 *     function "f" would have all of the parameters.
	 */
	CompletionChunk_Optional CompletionChunkKind = C.CXCompletionChunk_Optional
	/**
	 * \brief Text that a user would be expected to type to get this
	 * code-completion result.
	 *
	 * There will be exactly one "typed text" chunk in a semantic string, which
	 * will typically provide the spelling of a keyword or the name of a
	 * declaration that could be used at the current code point. Clients are
	 * expected to filter the code-completion results based on the text in this
	 * chunk.
	 */
	CompletionChunk_TypedText CompletionChunkKind = C.CXCompletionChunk_TypedText
	/**
	 * \brief Text that should be inserted as part of a code-completion result.
	 *
	 * A "text" chunk represents text that is part of the template to be
	 * inserted into user code should this particular code-completion result
	 * be selected.
	 */
	CompletionChunk_Text CompletionChunkKind = C.CXCompletionChunk_Text
	/**
	 * \brief Placeholder text that should be replaced by the user.
	 *
	 * A "placeholder" chunk marks a place where the user should insert text
	 * into the code-completion template. For example, placeholders might mark
	 * the function parameters for a function declaration, to indicate that the
	 * user should provide arguments for each of those parameters. The actual
	 * text in a placeholder is a suggestion for the text to display before
	 * the user replaces the placeholder with real code.
	 */
	CompletionChunk_Placeholder CompletionChunkKind = C.CXCompletionChunk_Placeholder
	/**
	 * \brief Informative text that should be displayed but never inserted as
	 * part of the template.
	 *
	 * An "informative" chunk contains annotations that can be displayed to
	 * help the user decide whether a particular code-completion result is the
	 * right option, but which is not part of the actual template to be inserted
	 * by code completion.
	 */
	CompletionChunk_Informative CompletionChunkKind = C.CXCompletionChunk_Informative
	/**
	 * \brief Text that describes the current parameter when code-completion is
	 * referring to function call, message send, or template specialization.
	 *
	 * A "current parameter" chunk occurs when code-completion is providing
	 * information about a parameter corresponding to the argument at the
	 * code-completion point. For example, given a function
	 *
	 * \code
	 * int add(int x, int y);
	 * \endcode
	 *
	 * and the source code \c add(, where the code-completion point is after the
	 * "(", the code-completion string will contain a "current parameter" chunk
	 * for "int x", indicating that the current argument will initialize that
	 * parameter. After typing further, to \c add(17, (where the code-completion
	 * point is after the ","), the code-completion string will contain a
	 * "current paremeter" chunk to "int y".
	 */
	CompletionChunk_CurrentParameter CompletionChunkKind = C.CXCompletionChunk_CurrentParameter
	/**
	 * \brief A left parenthesis ('('), used to initiate a function call or
	 * signal the beginning of a function parameter list.
	 */
	CompletionChunk_LeftParen CompletionChunkKind = C.CXCompletionChunk_LeftParen
	/**
	 * \brief A right parenthesis (')'), used to finish a function call or
	 * signal the end of a function parameter list.
	 */
	CompletionChunk_RightParen CompletionChunkKind = C.CXCompletionChunk_RightParen
	/**
	 * \brief A left bracket ('[').
	 */
	CompletionChunk_LeftBracket CompletionChunkKind = C.CXCompletionChunk_LeftBracket
	/**
	 * \brief A right bracket (']').
	 */
	CompletionChunk_RightBracket CompletionChunkKind = C.CXCompletionChunk_RightBracket
	/**
	 * \brief A left brace ('{').
	 */
	CompletionChunk_LeftBrace CompletionChunkKind = C.CXCompletionChunk_LeftBrace
	/**
	 * \brief A right brace ('}').
	 */
	CompletionChunk_RightBrace CompletionChunkKind = C.CXCompletionChunk_RightBrace
	/**
	 * \brief A left angle bracket ('<').
	 */
	CompletionChunk_LeftAngle CompletionChunkKind = C.CXCompletionChunk_LeftAngle
	/**
	 * \brief A right angle bracket ('>').
	 */
	CompletionChunk_RightAngle CompletionChunkKind = C.CXCompletionChunk_RightAngle
	/**
	 * \brief A comma separator (',').
	 */
	CompletionChunk_Comma CompletionChunkKind = C.CXCompletionChunk_Comma
	/**
	 * \brief Text that specifies the result type of a given result.
	 *
	 * This special kind of informative chunk is not meant to be inserted into
	 * the text buffer. Rather, it is meant to illustrate the type that an
	 * expression using the given completion string would have.
	 */
	CompletionChunk_ResultType CompletionChunkKind = C.CXCompletionChunk_ResultType
	/**
	 * \brief A colon (':').
	 */
	CompletionChunk_Colon CompletionChunkKind = C.CXCompletionChunk_Colon
	/**
	 * \brief A semicolon (';').
	 */
	CompletionChunk_SemiColon CompletionChunkKind = C.CXCompletionChunk_SemiColon
	/**
	 * \brief An '=' sign.
	 */
	CompletionChunk_Equal CompletionChunkKind = C.CXCompletionChunk_Equal
	/**
	 * Horizontal space (' ').
	 */
	CompletionChunk_HorizontalSpace CompletionChunkKind = C.CXCompletionChunk_HorizontalSpace
	/**
	 * Vertical space ('\n'), after which it is generally a good idea to
	 * perform indentation.
	 */
	CompletionChunk_VerticalSpace CompletionChunkKind = C.CXCompletionChunk_VerticalSpace
)

func (CompletionChunkKind) String

func (cck CompletionChunkKind) String() string

type CompletionContext

type CompletionContext int

*

  • \brief Bits that represent the context under which completion is occurring. *
  • The enumerators in this enumeration may be bitwise-OR'd together if multiple
  • contexts are occurring simultaneously.
const (
	/**
	 * \brief The context for completions is unexposed, as only Clang results
	 * should be included. (This is equivalent to having no context bits set.)
	 */
	CompletionContext_Unexposed CompletionContext = C.CXCompletionContext_Unexposed

	/**
	 * \brief Completions for any possible type should be included in the results.
	 */
	CompletionContext_AnyType CompletionContext = C.CXCompletionContext_AnyType

	/**
	 * \brief Completions for any possible value (variables, function calls, etc.)
	 * should be included in the results.
	 */
	CompletionContext_AnyValue CompletionContext = C.CXCompletionContext_AnyValue
	/**
	 * \brief Completions for values that resolve to an Objective-C object should
	 * be included in the results.
	 */
	CompletionContext_ObjCObjectValue CompletionContext = C.CXCompletionContext_ObjCObjectValue
	/**
	 * \brief Completions for values that resolve to an Objective-C selector
	 * should be included in the results.
	 */
	CompletionContext_ObjCSelectorValue CompletionContext = C.CXCompletionContext_ObjCSelectorValue
	/**
	 * \brief Completions for values that resolve to a C++ class type should be
	 * included in the results.
	 */
	CompletionContext_CXXClassTypeValue CompletionContext = C.CXCompletionContext_CXXClassTypeValue

	/**
	 * \brief Completions for fields of the member being accessed using the dot
	 * operator should be included in the results.
	 */
	CompletionContext_DotMemberAccess CompletionContext = C.CXCompletionContext_DotMemberAccess
	/**
	 * \brief Completions for fields of the member being accessed using the arrow
	 * operator should be included in the results.
	 */
	CompletionContext_ArrowMemberAccess CompletionContext = C.CXCompletionContext_ArrowMemberAccess
	/**
	 * \brief Completions for properties of the Objective-C object being accessed
	 * using the dot operator should be included in the results.
	 */
	CompletionContext_ObjCPropertyAccess CompletionContext = C.CXCompletionContext_ObjCPropertyAccess

	/**
	 * \brief Completions for enum tags should be included in the results.
	 */
	CompletionContext_EnumTag CompletionContext = C.CXCompletionContext_EnumTag
	/**
	 * \brief Completions for union tags should be included in the results.
	 */
	CompletionContext_UnionTag CompletionContext = C.CXCompletionContext_UnionTag
	/**
	 * \brief Completions for struct tags should be included in the results.
	 */
	CompletionContext_StructTag CompletionContext = C.CXCompletionContext_StructTag

	/**
	 * \brief Completions for C++ class names should be included in the results.
	 */
	CompletionContext_ClassTag CompletionContext = C.CXCompletionContext_ClassTag
	/**
	 * \brief Completions for C++ namespaces and namespace aliases should be
	 * included in the results.
	 */
	CompletionContext_Namespace CompletionContext = C.CXCompletionContext_Namespace
	/**
	 * \brief Completions for C++ nested name specifiers should be included in
	 * the results.
	 */
	CompletionContext_NestedNameSpecifier CompletionContext = C.CXCompletionContext_NestedNameSpecifier

	/**
	 * \brief Completions for Objective-C interfaces (classes) should be included
	 * in the results.
	 */
	CompletionContext_ObjCInterface CompletionContext = C.CXCompletionContext_ObjCInterface
	/**
	 * \brief Completions for Objective-C protocols should be included in
	 * the results.
	 */
	CompletionContext_ObjCProtocol CompletionContext = C.CXCompletionContext_ObjCProtocol
	/**
	 * \brief Completions for Objective-C categories should be included in
	 * the results.
	 */
	CompletionContext_ObjCCategory CompletionContext = C.CXCompletionContext_ObjCCategory
	/**
	 * \brief Completions for Objective-C instance messages should be included
	 * in the results.
	 */
	CompletionContext_ObjCInstanceMessage CompletionContext = C.CXCompletionContext_ObjCInstanceMessage
	/**
	 * \brief Completions for Objective-C class messages should be included in
	 * the results.
	 */
	CompletionContext_ObjCClassMessage CompletionContext = C.CXCompletionContext_ObjCClassMessage
	/**
	 * \brief Completions for Objective-C selector names should be included in
	 * the results.
	 */
	CompletionContext_ObjCSelectorName CompletionContext = C.CXCompletionContext_ObjCSelectorName

	/**
	 * \brief Completions for preprocessor macro names should be included in
	 * the results.
	 */
	CompletionContext_MacroName CompletionContext = C.CXCompletionContext_MacroName

	/**
	 * \brief Natural language completions should be included in the results.
	 */
	CompletionContext_NaturalLanguage CompletionContext = C.CXCompletionContext_NaturalLanguage

	/**
	 * \brief The current context is unknown, so set all contexts.
	 */
	CompletionContext_Unknown CompletionContext = C.CXCompletionContext_Unknown
)

type CompletionResult

type CompletionResult struct {
	/**
	 * \brief The kind of entity that this completion refers to.
	 *
	 * The cursor kind will be a macro, keyword, or a declaration (one of the
	 * *Decl cursor kinds), describing the entity that the completion is
	 * referring to.
	 *
	 * \todo In the future, we would like to provide a full cursor, to allow
	 * the client to extract additional information from declaration.
	 */
	CursorKind CursorKind
	/**
	 * \brief The code-completion string that describes how to insert this
	 * code-completion result into the editing buffer.
	 */
	CompletionString CompletionString
}

*

  • \brief A single result of code completion.

type CompletionString

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

*

  • \brief A semantic string that describes a code-completion result. *
  • A semantic string that describes the formatting of a code-completion
  • result as a single "template" of text that should be inserted into the
  • source buffer when a particular code-completion result is selected.
  • Each semantic string is made up of some number of "chunks", each of which
  • contains some text along with a description of what that text means, e.g.,
  • the name of the entity being referenced, whether the text chunk is part of
  • the template, or whether it is a "placeholder" that the user should replace
  • with actual code,of a specific kind. See \c CXCompletionChunkKind for a
  • description of the different kinds of chunks.

func (CompletionString) Annotation

func (cs CompletionString) Annotation(i int) string

*

  • \brief Retrieve the annotation associated with the given completion string. *
  • \param completion_string the completion string to query. *
  • \param annotation_number the 0-based index of the annotation of the
  • completion string. *
  • \returns annotation string associated with the completion at index
  • \c annotation_number, or a NULL string if that annotation is not available.

func (CompletionString) Availability

func (cs CompletionString) Availability() AvailabilityKind

*

  • \brief Determine the availability of the entity that this code-completion
  • string refers to. *
  • \param completion_string The completion string to query. *
  • \returns The availability of the completion string.

func (CompletionString) Chunks

func (cs CompletionString) Chunks() (ret []CompletionChunk)

func (CompletionString) CompletionBriefComment

func (cs CompletionString) CompletionBriefComment() string

*

  • \brief Retrieve the brief documentation comment attached to the declaration
  • that corresponds to the given completion string.

func (CompletionString) CompletionParent

func (cs CompletionString) CompletionParent() string

*

  • \brief Retrieve the parent context of the given completion string. *
  • The parent context of a completion string is the semantic parent of
  • the declaration (if any) that the code completion represents. For example,
  • a code completion for an Objective-C method would have the method's class
  • or protocol as its context. *
  • \param completion_string The code completion string whose parent is
  • being queried. *
  • \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL. *
  • \returns The name of the completion parent, e.g., "NSObject" if
  • the completion string represents a method in the NSObject class.

func (CompletionString) NumAnnotations

func (cs CompletionString) NumAnnotations() int

*

  • \brief Retrieve the number of annotations associated with the given
  • completion string. *
  • \param completion_string the completion string to query. *
  • \returns the number of annotations associated with the given completion
  • string.

func (CompletionString) Priority

func (cs CompletionString) Priority() int

*

  • \brief Determine the priority of this code completion. *
  • The priority of a code completion indicates how likely it is that this
  • particular completion is the completion that the user will select. The
  • priority is selected by various internal heuristics. *
  • \param completion_string The completion string to query. *
  • \returns The priority of this completion string. Smaller values indicate
  • higher-priority (more likely) completions.

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) Argument

func (c Cursor) Argument(i uint) Cursor

*

  • \brief Retrieve the argument cursor of a function or method. *
  • If a cursor that is not a function or method is passed in or the index
  • exceeds the number of arguments, an invalid cursor is returned.

CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);

func (Cursor) Availability

func (c Cursor) Availability() AvailabilityKind

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

func (Cursor) BriefCommentText

func (c Cursor) BriefCommentText() string

*

  • \brief Given a cursor that represents a documentable entity (e.g.,
  • declaration), return the associated \\brief paragraph; otherwise return the
  • first paragraph.

func (Cursor) CXXMethod_IsPureVirtual

func (c Cursor) CXXMethod_IsPureVirtual() bool

*

  • \brief Determine if a C++ member function or member function template is
  • pure virtual.

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) CommentRange

func (c Cursor) CommentRange() SourceRange

*

  • \brief Given a cursor that represents a declaration, return the associated
  • comment's source range. The range may include multiple consecutive comments
  • with whitespace in between.

func (Cursor) CompletionString

func (c Cursor) CompletionString() CompletionString

*

  • \brief Retrieve a completion string for an arbitrary declaration or macro
  • definition cursor. *
  • \param cursor The cursor to query. *
  • \returns A non-context-sensitive completion string for declaration and macro
  • definition cursors, or NULL for other kinds of cursors.

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) EnumConstantDeclUnsignedValue

func (c Cursor) EnumConstantDeclUnsignedValue() uint64

*

  • \brief Retrieve the integer value of an enum constant declaration as an unsigned
  • long long. *
  • If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
  • Since this is also potentially a valid constant value, the kind of the cursor
  • must be verified before calling this function.

func (Cursor) EnumConstantDeclValue

func (c Cursor) EnumConstantDeclValue() int64

*

  • \brief Retrieve the integer value of an enum constant declaration as a signed
  • long long. *
  • If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
  • Since this is also potentially a valid constant value, the kind of the cursor
  • must be verified before calling this function.

func (Cursor) EnumDeclIntegerType

func (c Cursor) EnumDeclIntegerType() Type

*

  • \brief Retrieve the integer type of an enum declaration. *
  • If the cursor does not reference an enum declaration, an invalid type is
  • returned.

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) FieldDeclBitWidth

func (c Cursor) FieldDeclBitWidth() int

*

  • \brief Retrieve the bit width of a bit field declaration as an integer. *
  • If a cursor that is not a bit field declaration is passed in, -1 is returned.

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) IsBitField

func (c Cursor) IsBitField() bool

*

  • \brief Returns non-zero if the cursor specifies a Record member that is a
  • bitfield.

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) IsDynamicCall

func (c Cursor) IsDynamicCall() bool

*

  • \brief Given a cursor pointing to a C++ method call or an ObjC message,
  • returns non-zero if the method/message is "dynamic", meaning: *
  • For a C++ method: the call is virtual.
  • For an ObjC message: the receiver is an object instance, not 'super' or a
  • specific class. *
  • If the method/message is "static" or the cursor does not point to a
  • method/message, it will return zero.

func (Cursor) IsNull

func (c Cursor) IsNull() bool

IsNull returns true if the underlying Cursor is null

func (Cursor) IsVariadic

func (c Cursor) IsVariadic() bool

*

  • \brief Returns non-zero if the given cursor is a variadic function or method.

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) Module

func (c Cursor) Module() Module

*

  • \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.

func (Cursor) NumArguments

func (c Cursor) NumArguments() int

*

  • \brief Retrieve the number of non-variadic arguments associated with a given
  • cursor. *
  • If a cursor that is not a function or method is passed in, -1 is returned.

CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);

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) ParsedComment

func (c Cursor) ParsedComment() Comment

*

  • \brief Given a cursor that represents a documentable entity (e.g.,
  • declaration), return the associated parsed comment as a
  • \c CXComment_FullComment AST node.

func (Cursor) PlatformAvailability

func (c Cursor) PlatformAvailability(availability []PlatformAvailability) (always_deprecated bool, deprecated_msg string, always_unavailable bool, unavailable_msg string)

*

  • \brief Determine the availability of the entity that this cursor refers to
  • on any platforms for which availability information is known. *
  • \param cursor The cursor to query. *
  • \param always_deprecated If non-NULL, will be set to indicate whether the
  • entity is deprecated on all platforms. *
  • \param deprecated_message If non-NULL, will be set to the message text
  • provided along with the unconditional deprecation of this entity. The client
  • is responsible for deallocating this string. *
  • \param always_unavailable If non-NULL, will be set to indicate whether the
  • entity is unavailable on all platforms. *
  • \param unavailable_message If non-NULL, will be set to the message text
  • provided along with the unconditional unavailability of this entity. The
  • client is responsible for deallocating this string. *
  • \param availability If non-NULL, an array of CXPlatformAvailability instances
  • that will be populated with platform availability information, up to either
  • the number of platforms for which availability information is available (as
  • returned by this function) or \c availability_size, whichever is smaller. *
  • \param availability_size The number of elements available in the
  • \c availability array. *
  • \returns The number of platforms (N) for which availability information is
  • available (which is unrelated to \c availability_size). *
  • Note that the client is responsible for calling
  • \c clang_disposeCXPlatformAvailability to free each of the
  • platform-availability structures returned. There are
  • \c min(N, availability_size) such structures.

func (Cursor) RawCommentText

func (c Cursor) RawCommentText() string

*

  • \brief Given a cursor that represents a declaration, return the associated
  • comment text, including comment markers.

func (Cursor) ReceiverType

func (c Cursor) ReceiverType() Type

*

  • \brief Given a cursor pointing to an ObjC message, returns the CXType of the
  • receiver.

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) TypedefDeclUnderlyingType

func (c Cursor) TypedefDeclUnderlyingType() Type

*

  • \brief Retrieve the underlying type of a typedef declaration. *
  • If the cursor does not reference a typedef declaration, an invalid type is
  • returned.

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

func (CursorKind) String

func (c CursorKind) String() string

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 Diagnostic

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

*

  • \brief A single diagnostic, containing the diagnostic's severity,
  • location, text, source ranges, and fix-it hints.

func (Diagnostic) Dispose

func (d Diagnostic) Dispose()

*

  • \brief Destroy a diagnostic.

func (Diagnostic) FixIts

func (d Diagnostic) FixIts() (ret []FixIt)

*

  • \brief Retrieve the replacement information for a given fix-it. *
  • Fix-its are described in terms of a source range whose contents
  • should be replaced by a string. This approach generalizes over
  • three kinds of operations: removal of source code (the range covers
  • the code to be removed and the replacement string is empty),
  • replacement of source code (the range covers the code to be
  • replaced and the replacement string provides the new code), and
  • insertion (both the start and end of the range point at the
  • insertion location, and the replacement string provides the text to
  • insert). *
  • \param Diagnostic The diagnostic whose fix-its are being queried. *
  • \param FixIt The zero-based index of the fix-it. *
  • \param ReplacementRange The source range whose contents will be
  • replaced with the returned replacement string. Note that source
  • ranges are half-open ranges [a, b), so the source code should be
  • replaced from a and up to (but not including) b. *
  • \returns A string containing text that should be replace the source
  • code indicated by the \c ReplacementRange.

func (Diagnostic) Format

func (d Diagnostic) Format(options DiagnosticDisplayOptions) string

*

  • \brief Format the given diagnostic in a manner that is suitable for display. *
  • This routine will format the given diagnostic to a string, rendering
  • the diagnostic according to the various options given. The
  • \c clang_defaultDiagnosticDisplayOptions() function returns the set of
  • options that most closely mimics the behavior of the clang compiler. *
  • \param Diagnostic The diagnostic to print. *
  • \param Options A set of options that control the diagnostic display,
  • created by combining \c CXDiagnosticDisplayOptions values. *
  • \returns A new string containing for formatted diagnostic.

func (Diagnostic) Location

func (d Diagnostic) Location() SourceLocation

*

  • \brief Retrieve the source location of the given diagnostic. *
  • This location is where Clang would print the caret ('^') when
  • displaying the diagnostic on the command line.

func (Diagnostic) Option

func (d Diagnostic) Option() (enable, disable string)

*

  • \brief Retrieve the name of the command-line option that enabled this
  • diagnostic. *
  • \param Diag The diagnostic to be queried. *
  • \param Disable If non-NULL, will be set to the option that disables this
  • diagnostic (if any). *
  • \returns A string that contains the command-line option used to enable this
  • warning, such as "-Wconversion" or "-pedantic".

func (Diagnostic) Ranges

func (d Diagnostic) Ranges() (ret []SourceRange)

*

  • \brief Retrieve a source range associated with the diagnostic. *
  • A diagnostic's source ranges highlight important elements in the source
  • code. On the command line, Clang displays source ranges by
  • underlining them with '~' characters. *
  • \param Diagnostic the diagnostic whose range is being extracted. *
  • \param Range the zero-based index specifying which range to *
  • \returns the requested source range.

func (Diagnostic) Severity

func (d Diagnostic) Severity() DiagnosticSeverity

*

  • \brief Determine the severity of the given diagnostic.

func (Diagnostic) Spelling

func (d Diagnostic) Spelling() string

*

  • \brief Retrieve the text of the given diagnostic.

func (Diagnostic) String

func (d Diagnostic) String() string

type DiagnosticDisplayOptions

type DiagnosticDisplayOptions int

*

  • \brief Options to control the display of diagnostics. *
  • The values in this enum are meant to be combined to customize the
  • behavior of \c clang_displayDiagnostic().

func DefaultDiagnosticDisplayOptions

func DefaultDiagnosticDisplayOptions() DiagnosticDisplayOptions

*

  • \brief Retrieve the set of display options most similar to the
  • default behavior of the clang compiler. *
  • \returns A set of display options suitable for use with \c
  • clang_displayDiagnostic().

type DiagnosticSeverity

type DiagnosticSeverity int

*

  • \brief Describes the severity of a particular diagnostic.

func (DiagnosticSeverity) String

func (ds DiagnosticSeverity) String() string

type Diagnostics

type Diagnostics []Diagnostic

func (Diagnostics) Dispose

func (d Diagnostics) Dispose()

type File

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

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

func (File) GetFileUniqueID

func (f File) GetFileUniqueID() (FileUniqueID, error)

*

  • \brief Retrieve the unique ID for the given \c file. *
  • \param file the file to get the ID for.
  • \param outID stores the returned CXFileUniqueID.
  • \returns If there was a failure getting the unique ID, returns non-zero,
  • otherwise returns 0.

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 FileUniqueID

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

*

  • \brief Uniquely identifies a CXFile, that refers to the same underlying file,
  • across an indexing session.

type FixIt

type FixIt struct {
	Data             string
	ReplacementRange SourceRange
}

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, us UnsavedFiles) 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.

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, us UnsavedFiles, 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.

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 Module

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

Module describes a C++ Module

func (Module) ASTFile

func (m Module) ASTFile() File

*

  • \param Module a module object. *
  • \returns the module file where the provided module object came from.

func (Module) FullName

func (m Module) FullName() string

*

  • \param Module a module object. *
  • \returns the full name of the module, e.g. "std.vector".

func (Module) Name

func (m Module) Name() string

*

  • \param Module a module object. *
  • \returns the name of the module, e.g. for the 'std.vector' sub-module it
  • will return "vector".

func (Module) Parent

func (m Module) Parent() Module

*

  • \param Module a module object. *
  • \returns 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.

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 PlatformAvailability

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

*

  • Describes the availability of a given entity on a particular platform, e.g.,
  • a particular class might only be available on Mac OS 10.7 or newer.

func (*PlatformAvailability) Deprecated

func (p *PlatformAvailability) Deprecated() Version

*

  • \brief The version number in which this entity was deprecated (but is
  • still available).

func (*PlatformAvailability) Dispose

func (p *PlatformAvailability) Dispose()

*

  • \brief Free the memory associated with a \c CXPlatformAvailability structure.

func (*PlatformAvailability) Introduced

func (p *PlatformAvailability) Introduced() Version

*

  • \brief The version number in which this entity was introduced.

func (*PlatformAvailability) Message

func (p *PlatformAvailability) Message() string

*

  • \brief An optional message to provide to a user of this API, e.g., to
  • suggest replacement APIs.

func (*PlatformAvailability) Obsoleted

func (p *PlatformAvailability) Obsoleted() Version

*

  • \brief The version number in which this entity was obsoleted, and therefore
  • is no longer available.

func (*PlatformAvailability) Platform

func (p *PlatformAvailability) Platform() string

*

  • \brief A string that describes the platform for which this structure
  • provides availability information. *
  • Possible values are "ios" or "macosx".

func (*PlatformAvailability) Unavailable

func (p *PlatformAvailability) Unavailable() int

*

  • \brief Whether the entity is unconditionally unavailable on this platform.

type RefQualifierKind

type RefQualifierKind int

RefQualifierKind describes the kind of reference a Type is decorated with

type Result

type Result int

Result is the result of calling a c-clang function

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) GetFileLocation

func (loc SourceLocation) GetFileLocation() (f 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 expansion, return where the macro was
  • expanded or where the macro argument was written, if the location points at
  • a macro argument. *
  • \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.

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) IsFromMainFile

func (loc SourceLocation) IsFromMainFile() bool

*

  • \brief Returns non-zero if the given source location is in the main file of
  • the corresponding translation unit.

func (SourceLocation) IsInSystemHeader

func (loc SourceLocation) IsInSystemHeader() bool

*

  • \brief Returns non-zero if the given source location is in a system header.

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

func (TokenKind) String

func (tk TokenKind) String() string

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) CompleteAt

func (tu TranslationUnit) CompleteAt(complete_filename string, complete_line, complete_column int, us UnsavedFiles, options CodeCompleteFlags) CodeCompleteResults

*

  • \brief Perform code completion at a given location in a translation unit. *
  • This function performs code completion at a particular file, line, and
  • column within source code, providing results that suggest potential
  • code snippets based on the context of the completion. The basic model
  • for code completion is that Clang will parse a complete source file,
  • performing syntax checking up to the location where code-completion has
  • been requested. At that point, a special code-completion token is passed
  • to the parser, which recognizes this token and determines, based on the
  • current location in the C/Objective-C/C++ grammar and the state of
  • semantic analysis, what completions to provide. These completions are
  • returned via a new \c CXCodeCompleteResults structure. *
  • Code completion itself is meant to be triggered by the client when the
  • user types punctuation characters or whitespace, at which point the
  • code-completion location will coincide with the cursor. For example, if \c p
  • is a pointer, code-completion might be triggered after the "-" and then
  • after the ">" in \c p->. When the code-completion location is afer the ">",
  • the completion results will provide, e.g., the members of the struct that
  • "p" points to. The client is responsible for placing the cursor at the
  • beginning of the token currently being typed, then filtering the results
  • based on the contents of the token. For example, when code-completing for
  • the expression \c p->get, the client should provide the location just after
  • the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
  • client can filter the results based on the current token text ("get"), only
  • showing those results that start with "get". The intent of this interface
  • is to separate the relatively high-latency acquisition of code-completion
  • results from the filtering of results on a per-character basis, which must
  • have a lower latency. *
  • \param TU The translation unit in which code-completion should
  • occur. The source files for this translation unit need not be
  • completely up-to-date (and the contents of those source files may
  • be overridden via \p unsaved_files). Cursors referring into the
  • translation unit may be invalidated by this invocation. *
  • \param complete_filename The name of the source file where code
  • completion should be performed. This filename may be any file
  • included in the translation unit. *
  • \param complete_line The line at which code-completion should occur. *
  • \param complete_column The column at which code-completion should occur.
  • Note that the column should point just after the syntactic construct that
  • initiated code completion, and not in the middle of a lexical token. *
  • \param unsaved_files the Tiles that have not yet been saved to disk
  • but may be required for parsing or 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. *
  • \param num_unsaved_files The number of unsaved file entries in \p
  • unsaved_files. *
  • \param options Extra options that control the behavior of code
  • completion, expressed as a bitwise OR of the enumerators of the
  • CXCodeComplete_Flags enumeration. The
  • \c clang_defaultCodeCompleteOptions() function returns a default set
  • of code-completion options. *
  • \returns If successful, a new \c CXCodeCompleteResults structure
  • containing code-completion results, which should eventually be
  • freed with \c clang_disposeCodeCompleteResults(). If code
  • completion fails, returns NULL.

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) Diagnostics

func (tu TranslationUnit) Diagnostics() (ret Diagnostics)

*

  • \brief Retrieve a diagnostic associated with the given translation unit. *
  • \param Unit the translation unit to query.
  • \param Index the zero-based diagnostic number to retrieve. *
  • \returns the requested diagnostic. This diagnostic must be freed
  • via a call to \c clang_disposeDiagnostic().

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) IsValid

func (tu TranslationUnit) IsValid() bool

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) NumTopLevelHeaders

func (tu TranslationUnit) NumTopLevelHeaders(m Module) int

*

  • \param Module a module object. *
  • \returns the number of top level headers associated with this module.

func (TranslationUnit) Reparse

func (tu TranslationUnit) Reparse(us UnsavedFiles, options TranslationUnitFlags) int

*

  • \brief Reparse the source files that produced this translation unit. *
  • This routine can be used to re-parse the source files that originally
  • created the given translation unit, for example because those source files
  • have changed (either on disk or as passed via \p unsaved_files). The
  • source code will be reparsed with the same command-line options as it
  • was originally parsed. *
  • Reparsing a translation unit invalidates all cursors and source locations
  • that refer into that translation unit. This makes reparsing a translation
  • unit semantically equivalent to destroying the translation unit and then
  • creating a new translation unit with the same command-line arguments.
  • However, it may be more efficient to reparse a translation
  • unit using this routine. *
  • \param TU The translation unit whose contents will be re-parsed. The
  • translation unit must originally have been built with
  • \c clang_createTranslationUnitFromSourceFile(). *
  • \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 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 options A bitset of options composed of the flags in CXReparse_Flags.
  • The function \c clang_defaultReparseOptions() produces a default set of
  • options recommended for most uses, based on the translation unit. *
  • \returns 0 if the sources could be reparsed. A non-zero value will be
  • returned if reparsing was impossible, such that the translation unit is
  • invalid. In such cases, the only valid call for \p TU is
  • \c clang_disposeTranslationUnit(TU).

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.

func (TranslationUnit) TopLevelHeader

func (tu TranslationUnit) TopLevelHeader(m Module, i int) File

*

  • \param Module a module object. *
  • \param Index top level header index (zero-based). *
  • \returns the specified top level header associated with the module.

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) AlignOf

func (t Type) AlignOf() (int, error)

*

  • \brief Return the alignment of a type in bytes as per C++[expr.alignof]
  • standard. *
  • If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
  • If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
  • is returned.
  • If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
  • returned.
  • If the type declaration is not a constant size type,
  • CXTypeLayoutError_NotConstantSize is returned.

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) CXXRefQualifier

func (t Type) CXXRefQualifier() RefQualifierKind

*

  • \brief Retrieve the ref-qualifier kind of a function or method. *
  • The ref-qualifier is returned for C++ functions or methods. For other types
  • or non-C++ declarations, CXRefQualifier_None 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) ClassType

func (t Type) ClassType() Type

*

  • \brief Return the class type of an member pointer type. *
  • If a non-member-pointer type is passed in, an invalid type is returned.

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) Kind

func (c Type) Kind() TypeKind

func (Type) OffsetOf

func (t Type) OffsetOf(s string) (int, error)

*

  • \brief Return 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] *
  • If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
  • is returned.
  • If the field's type declaration is an incomplete type,
  • CXTypeLayoutError_Incomplete is returned.
  • If the field's type declaration is a dependent type,
  • CXTypeLayoutError_Dependent is returned.
  • If the field's name S is not found,
  • CXTypeLayoutError_InvalidFieldName is returned.

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.

func (Type) SizeOf

func (t Type) SizeOf() (int, error)

*

  • \brief Return the size of a type in bytes as per C++[expr.sizeof] standard. *
  • If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
  • If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
  • is returned.
  • If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
  • returned.

func (Type) TypeSpelling

func (t Type) TypeSpelling() string

*

  • \brief Pretty-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.

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.

type TypeLayoutError

type TypeLayoutError int

*

  • \brief List the possible error codes for \c clang_Type_getSizeOf,
  • \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
  • \c clang_Cursor_getOffsetOf. *
  • A value of this enumeration type can be returned if the target type is not
  • a valid argument to sizeof, alignof or offsetof.

func (TypeLayoutError) Error

func (tle TypeLayoutError) Error() string

type UnsavedFiles

type UnsavedFiles map[string]string

type Version

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

*

  • \brief Describes a version number of the form major.minor.subminor.

func (Version) Major

func (v Version) Major() int

*

  • \brief The major version number, e.g., the '10' in '10.7.3'. A negative
  • value indicates that there is no version number at all.

func (Version) Minor

func (v Version) Minor() int

*

  • \brief The minor version number, e.g., the '7' in '10.7.3'. This value
  • will be negative if no minor version number was provided, e.g., for
  • version '10'.

func (Version) Subminor

func (v Version) Subminor() int

*

  • \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
  • will be negative if no minor or subminor version number was provided,
  • e.g., in version '10' or '10.7'.

Directories

Path Synopsis
go-clang-compdb dumps the content of a CLang compilation database
go-clang-compdb dumps the content of a CLang compilation database
go-clang-dump shows how to dump the AST of a C/C++ file via the Cursor visitor API.
go-clang-dump shows how to dump the AST of a C/C++ file via the Cursor visitor API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL