Files
llgo/c/clang/clang.go

1862 lines
43 KiB
Go
Raw Normal View History

2024-06-25 00:33:48 +08:00
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package clang
import (
2024-07-15 13:14:47 +08:00
"unsafe"
2024-06-25 00:33:48 +08:00
"github.com/goplus/llgo/c"
)
2024-06-25 12:00:48 +08:00
const (
2024-07-15 13:14:47 +08:00
LLGoFiles = "$(llvm-config --cflags): _wrap/cursor.cpp"
2024-06-25 12:00:48 +08:00
LLGoPackage = "link: -L$(llvm-config --libdir) -lclang; -lclang"
)
2024-07-24 14:22:41 +08:00
const (
/* Declarations */
/**
* 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.
*/
2024-08-06 14:46:38 +08:00
CursorUnexposedDecl CursorKind = iota + 1
2024-07-24 14:22:41 +08:00
/** A C or C++ struct. */
2024-08-06 14:46:38 +08:00
CursorStructDecl
2024-07-24 14:22:41 +08:00
/** A C or C++ union. */
2024-08-06 14:46:38 +08:00
CursorUnionDecl
2024-07-24 14:22:41 +08:00
/** A C++ class. */
2024-08-06 14:46:38 +08:00
CursorClassDecl
2024-07-24 14:22:41 +08:00
/** An enumeration. */
2024-08-06 14:46:38 +08:00
CursorEnumDecl
2024-07-24 14:22:41 +08:00
/**
* A field (in C) or non-static data member (in C++) in a
* struct, union, or C++ class.
*/
2024-08-06 14:46:38 +08:00
CursorFieldDecl
2024-07-24 14:22:41 +08:00
/** An enumerator constant. */
2024-08-06 14:46:38 +08:00
CursorEnumConstantDecl
2024-07-24 14:22:41 +08:00
/** A function. */
2024-08-06 14:46:38 +08:00
CursorFunctionDecl
2024-07-24 14:22:41 +08:00
/** A variable. */
2024-08-06 14:46:38 +08:00
CursorVarDecl
2024-07-24 14:22:41 +08:00
/** A function or method parameter. */
2024-08-06 14:46:38 +08:00
CursorParmDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C \@interface. */
2024-08-06 14:46:38 +08:00
CursorObjCInterfaceDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C \@interface for a category. */
2024-08-06 14:46:38 +08:00
CursorObjCCategoryDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C \@protocol declaration. */
2024-08-06 14:46:38 +08:00
CursorObjCProtocolDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C \@property declaration. */
2024-08-06 14:46:38 +08:00
CursorObjCPropertyDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C instance variable. */
2024-08-06 14:46:38 +08:00
CursorObjCIvarDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C instance method. */
2024-08-06 14:46:38 +08:00
CursorObjCInstanceMethodDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C class method. */
2024-08-06 14:46:38 +08:00
CursorObjCClassMethodDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C \@implementation. */
2024-08-06 14:46:38 +08:00
CursorObjCImplementationDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C \@implementation for a category. */
2024-08-06 14:46:38 +08:00
CursorObjCCategoryImplDecl
2024-07-24 14:22:41 +08:00
/** A typedef. */
2024-08-06 14:46:38 +08:00
CursorTypedefDecl
2024-07-24 14:22:41 +08:00
/** A C++ class method. */
2024-08-06 14:46:38 +08:00
CursorCXXMethod
2024-07-24 14:22:41 +08:00
/** A C++ namespace. */
2024-08-06 14:46:38 +08:00
CursorNamespace
2024-07-24 14:22:41 +08:00
/** A linkage specification, e.g. 'extern "C"'. */
2024-08-06 14:46:38 +08:00
CursorLinkageSpec
2024-07-24 14:22:41 +08:00
/** A C++ constructor. */
2024-08-06 14:46:38 +08:00
CursorConstructor
2024-07-24 14:22:41 +08:00
/** A C++ destructor. */
2024-08-06 14:46:38 +08:00
CursorDestructor
2024-07-24 14:22:41 +08:00
/** A C++ conversion function. */
2024-08-06 14:46:38 +08:00
CursorConversionFunction
2024-07-24 14:22:41 +08:00
/** A C++ template type parameter. */
2024-08-06 14:46:38 +08:00
CursorTemplateTypeParameter
2024-07-24 14:22:41 +08:00
/** A C++ non-type template parameter. */
2024-08-06 14:46:38 +08:00
CursorNonTypeTemplateParameter
2024-07-24 14:22:41 +08:00
/** A C++ template template parameter. */
2024-08-06 14:46:38 +08:00
CursorTemplateTemplateParameter
2024-07-24 14:22:41 +08:00
/** A C++ function template. */
2024-08-06 14:46:38 +08:00
CursorFunctionTemplate
2024-07-24 14:22:41 +08:00
/** A C++ class template. */
2024-08-06 14:46:38 +08:00
CursorClassTemplate
2024-07-24 14:22:41 +08:00
/** A C++ class template partial specialization. */
2024-08-06 14:46:38 +08:00
CursorClassTemplatePartialSpecialization
2024-07-24 14:22:41 +08:00
/** A C++ namespace alias declaration. */
2024-08-06 14:46:38 +08:00
CursorNamespaceAlias
2024-07-24 14:22:41 +08:00
/** A C++ using directive. */
2024-08-06 14:46:38 +08:00
CursorUsingDirective
2024-07-24 14:22:41 +08:00
/** A C++ using declaration. */
2024-08-06 14:46:38 +08:00
CursorUsingDeclaration
2024-07-24 14:22:41 +08:00
/** A C++ alias declaration */
2024-08-06 14:46:38 +08:00
CursorTypeAliasDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C \@synthesize definition. */
2024-08-06 14:46:38 +08:00
CursorObjCSynthesizeDecl
2024-07-24 14:22:41 +08:00
/** An Objective-C \@dynamic definition. */
2024-08-06 14:46:38 +08:00
CursorObjCDynamicDecl
2024-07-24 14:22:41 +08:00
/** An access specifier. */
2024-08-06 14:46:38 +08:00
CursorCXXAccessSpecifier
2024-07-24 14:22:41 +08:00
2024-08-06 14:46:38 +08:00
CursorFirstDecl = CursorUnexposedDecl
CursorLastDecl = CursorCXXAccessSpecifier
2024-07-24 14:22:41 +08:00
/* References */
2024-08-06 14:46:38 +08:00
CursorFirstRef = 40
CursorObjCSuperClassRef = iota - 2 //40
CursorObjCProtocolRef
CursorObjCClassRef
2024-07-24 14:22:41 +08:00
/**
* 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.
*/
2024-08-06 14:46:38 +08:00
CursorTypeRef
2024-07-24 14:22:41 +08:00
2024-08-06 14:46:38 +08:00
CursorCXXBaseSpecifier
2024-07-24 14:22:41 +08:00
/**
* A reference to a class template, function template, template
* template parameter, or class template partial specialization.
*/
2024-08-06 14:46:38 +08:00
CursorTemplateRef
2024-07-24 14:22:41 +08:00
/**
* A reference to a namespace or namespace alias.
*/
2024-08-06 14:46:38 +08:00
CursorNamespaceRef
2024-07-24 14:22:41 +08:00
/**
* A reference to a member of a struct, union, or class that occurs in
* some non-expression context, e.g., a designated initializer.
*/
2024-08-06 14:46:38 +08:00
CursorMemberRef
2024-07-24 14:22:41 +08:00
/**
* 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.
*/
2024-08-06 14:46:38 +08:00
CursorLabelRef
2024-07-24 14:22:41 +08:00
/**
* 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.
*/
2024-08-06 14:46:38 +08:00
CursorOverloadedDeclRef
2024-07-24 14:22:41 +08:00
/**
* A reference to a variable that occurs in some non-expression
* context, e.g., a C++ lambda capture list.
*/
2024-08-06 14:46:38 +08:00
CursorVariableRef
2024-07-24 14:22:41 +08:00
2024-08-06 14:46:38 +08:00
CursorLastRef = CursorVariableRef
2024-07-24 14:22:41 +08:00
/* Error conditions */
2024-08-06 14:46:38 +08:00
CursorFirstInvalid = 70
CursorInvalidFile = iota + 15 //70
CursorNoDeclFound
CursorNotImplemented
CursorInvalidCode
CursorLastInvalid = CursorInvalidCode
2024-07-24 14:22:41 +08:00
/* Expressions */
2024-08-06 14:46:38 +08:00
CursorFirstExpr = 100
2024-07-24 14:22:41 +08:00
/**
* 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.
*/
2024-08-06 14:46:38 +08:00
CursorUnexposedExpr = iota + 39 //100
2024-07-24 14:22:41 +08:00
/**
* An expression that refers to some value declaration, such
* as a function, variable, or enumerator.
*/
2024-08-06 14:46:38 +08:00
CursorDeclRefExpr
2024-07-24 14:22:41 +08:00
/**
* An expression that refers to a member of a struct, union,
* class, Objective-C class, etc.
*/
2024-08-06 14:46:38 +08:00
CursorMemberRefExpr
2024-07-24 14:22:41 +08:00
/** An expression that calls a function. */
2024-08-06 14:46:38 +08:00
CursorCallExpr
2024-07-24 14:22:41 +08:00
/** An expression that sends a message to an Objective-C
object or class. */
2024-08-06 14:46:38 +08:00
CursorObjCMessageExpr
2024-07-24 14:22:41 +08:00
/** An expression that represents a block literal. */
2024-08-06 14:46:38 +08:00
CursorBlockExpr
2024-07-24 14:22:41 +08:00
/** An integer literal.
*/
2024-08-06 14:46:38 +08:00
CursorIntegerLiteral
2024-07-24 14:22:41 +08:00
/** A floating point number literal.
*/
2024-08-06 14:46:38 +08:00
CursorFloatingLiteral
2024-07-24 14:22:41 +08:00
/** An imaginary number literal.
*/
2024-08-06 14:46:38 +08:00
CursorImaginaryLiteral
2024-07-24 14:22:41 +08:00
/** A string literal.
*/
2024-08-06 14:46:38 +08:00
CursorStringLiteral
2024-07-24 14:22:41 +08:00
/** A character literal.
*/
2024-08-06 14:46:38 +08:00
CursorCharacterLiteral
2024-07-24 14:22:41 +08:00
/** A parenthesized expression, e.g. "(1)".
*
* This AST node is only formed if full location information is requested.
*/
2024-08-06 14:46:38 +08:00
CursorParenExpr
2024-07-24 14:22:41 +08:00
/** This represents the unary-expression's (except sizeof and
* alignof).
*/
2024-08-06 14:46:38 +08:00
CursorUnaryOperator
2024-07-24 14:22:41 +08:00
/** [C99 6.5.2.1] Array Subscripting.
*/
2024-08-06 14:46:38 +08:00
CursorArraySubscriptExpr
2024-07-24 14:22:41 +08:00
/** A builtin binary operation expression such as "x + y" or
* "x <= y".
*/
2024-08-06 14:46:38 +08:00
CursorBinaryOperator
2024-07-24 14:22:41 +08:00
/** Compound assignment such as "+=".
*/
2024-08-06 14:46:38 +08:00
CursorCompoundAssignOperator
2024-07-24 14:22:41 +08:00
/** The ?: ternary operator.
*/
2024-08-06 14:46:38 +08:00
CursorConditionalOperator
2024-07-24 14:22:41 +08:00
/** 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.
*/
2024-08-06 14:46:38 +08:00
CursorCStyleCastExpr
2024-07-24 14:22:41 +08:00
/** [C99 6.5.2.5]
*/
2024-08-06 14:46:38 +08:00
CursorCompoundLiteralExpr
2024-07-24 14:22:41 +08:00
/** Describes an C or C++ initializer list.
*/
2024-08-06 14:46:38 +08:00
CursorInitListExpr
2024-07-24 14:22:41 +08:00
/** The GNU address of label extension, representing &&label.
*/
2024-08-06 14:46:38 +08:00
CursorAddrLabelExpr
2024-07-24 14:22:41 +08:00
/** This is the GNU Statement Expression extension: ({int X=4; X;})
*/
2024-08-06 14:46:38 +08:00
CursorStmtExpr
2024-07-24 14:22:41 +08:00
/** Represents a C11 generic selection.
*/
2024-08-06 14:46:38 +08:00
CursorGenericSelectionExpr
2024-07-24 14:22:41 +08:00
/** 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).
*/
2024-08-06 14:46:38 +08:00
CursorGNUNullExpr
2024-07-24 14:22:41 +08:00
/** C++'s static_cast<> expression.
*/
2024-08-06 14:46:38 +08:00
CursorCXXStaticCastExpr
2024-07-24 14:22:41 +08:00
/** C++'s dynamic_cast<> expression.
*/
2024-08-06 14:46:38 +08:00
CursorCXXDynamicCastExpr
2024-07-24 14:22:41 +08:00
/** C++'s reinterpret_cast<> expression.
*/
2024-08-06 14:46:38 +08:00
CursorCXXReinterpretCastExpr
2024-07-24 14:22:41 +08:00
/** C++'s const_cast<> expression.
*/
2024-08-06 14:46:38 +08:00
CursorCXXConstCastExpr
2024-07-24 14:22:41 +08:00
/** Represents an explicit C++ type conversion that uses "functional"
* notion (C++ [expr.type.conv]).
*
* Example:
* \code
* x = int(0.5);
* \endcode
*/
2024-08-06 14:46:38 +08:00
CursorCXXFunctionalCastExpr
2024-07-24 14:22:41 +08:00
/** A C++ typeid expression (C++ [expr.typeid]).
*/
2024-08-06 14:46:38 +08:00
CursorCXXTypeidExpr
2024-07-24 14:22:41 +08:00
/** [C++ 2.13.5] C++ Boolean Literal.
*/
2024-08-06 14:46:38 +08:00
CursorCXXBoolLiteralExpr
2024-07-24 14:22:41 +08:00
/** [C++0x 2.14.7] C++ Pointer Literal.
*/
2024-08-06 14:46:38 +08:00
CursorCXXNullPtrLiteralExpr
2024-07-24 14:22:41 +08:00
/** Represents the "this" expression in C++
*/
2024-08-06 14:46:38 +08:00
CursorCXXThisExpr
2024-07-24 14:22:41 +08:00
/** [C++ 15] C++ Throw Expression.
*
* This handles 'throw' and 'throw' assignment-expression. When
* assignment-expression isn't present, Op will be null.
*/
2024-08-06 14:46:38 +08:00
CursorCXXThrowExpr
2024-07-24 14:22:41 +08:00
/** A new expression for memory allocation and constructor calls, e.g:
* "new CXXNewExpr(foo)".
*/
2024-08-06 14:46:38 +08:00
CursorCXXNewExpr
2024-07-24 14:22:41 +08:00
/** A delete expression for memory deallocation and destructor calls,
* e.g. "delete[] pArray".
*/
2024-08-06 14:46:38 +08:00
CursorCXXDeleteExpr
2024-07-24 14:22:41 +08:00
/** A unary expression. (noexcept, sizeof, or other traits)
*/
2024-08-06 14:46:38 +08:00
CursorUnaryExpr
2024-07-24 14:22:41 +08:00
/** An Objective-C string literal i.e. @"foo".
*/
2024-08-06 14:46:38 +08:00
CursorObjCStringLiteral
2024-07-24 14:22:41 +08:00
/** An Objective-C \@encode expression.
*/
2024-08-06 14:46:38 +08:00
CursorObjCEncodeExpr
2024-07-24 14:22:41 +08:00
/** An Objective-C \@selector expression.
*/
2024-08-06 14:46:38 +08:00
CursorObjCSelectorExpr
2024-07-24 14:22:41 +08:00
/** An Objective-C \@protocol expression.
*/
2024-08-06 14:46:38 +08:00
CursorObjCProtocolExpr
2024-07-24 14:22:41 +08:00
/** 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
*/
2024-08-06 14:46:38 +08:00
CursorObjCBridgedCastExpr
2024-07-24 14:22:41 +08:00
/** 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
*/
2024-08-06 14:46:38 +08:00
CursorPackExpansionExpr
2024-07-24 14:22:41 +08:00
/** Represents an expression that computes the length of a parameter
* pack.
*
* \code
* template<typename ...Types>
* struct count {
* static const unsigned value = sizeof...(Types);
* };
* \endcode
*/
2024-08-06 14:46:38 +08:00
CursorSizeOfPackExpr
2024-07-24 14:22:41 +08:00
/* Represents a C++ lambda expression that produces a local function
* object.
*
* \code
* void abssort(float *x, unsigned N) {
* std::sort(x, x + N,
* [](float a, float b) {
* return std::abs(a) < std::abs(b);
* });
* }
* \endcode
*/
2024-08-06 14:46:38 +08:00
CursorLambdaExpr
2024-07-24 14:22:41 +08:00
/** Objective-c Boolean Literal.
*/
2024-08-06 14:46:38 +08:00
CursorObjCBoolLiteralExpr
2024-07-24 14:22:41 +08:00
/** Represents the "self" expression in an Objective-C method.
*/
2024-08-06 14:46:38 +08:00
CursorObjCSelfExpr
2024-07-24 14:22:41 +08:00
/** OpenMP 5.0 [2.1.5, Array Section].
*/
2024-08-06 14:46:38 +08:00
CursorOMPArraySectionExpr
2024-07-24 14:22:41 +08:00
/** Represents an @available(...) check.
*/
2024-08-06 14:46:38 +08:00
CursorObjCAvailabilityCheckExpr
2024-07-24 14:22:41 +08:00
/**
* Fixed point literal
*/
2024-08-06 14:46:38 +08:00
CursorFixedPointLiteral
2024-07-24 14:22:41 +08:00
/** OpenMP 5.0 [2.1.4, Array Shaping].
*/
2024-08-06 14:46:38 +08:00
CursorOMPArrayShapingExpr
2024-07-24 14:22:41 +08:00
/**
* OpenMP 5.0 [2.1.6 Iterators]
*/
2024-08-06 14:46:38 +08:00
CursorOMPIteratorExpr
2024-07-24 14:22:41 +08:00
/** OpenCL's addrspace_cast<> expression.
*/
2024-08-06 14:46:38 +08:00
CursorCXXAddrspaceCastExpr
2024-07-24 14:22:41 +08:00
/**
* Expression that references a C++20 concept.
*/
2024-08-06 14:46:38 +08:00
CursorConceptSpecializationExpr
2024-07-24 14:22:41 +08:00
/**
* Expression that references a C++20 concept.
*/
2024-08-06 14:46:38 +08:00
CursorRequiresExpr
2024-07-24 14:22:41 +08:00
/**
* Expression that references a C++20 parenthesized list aggregate
* initializer.
*/
2024-08-06 14:46:38 +08:00
CursorCXXParenListInitExpr
2024-07-24 14:22:41 +08:00
2024-08-06 14:46:38 +08:00
CursorLastExpr = CursorCXXParenListInitExpr
2024-07-24 14:22:41 +08:00
/* Statements */
2024-08-06 14:46:38 +08:00
CursorFirstStmt = 200
2024-07-24 14:22:41 +08:00
/**
* 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.
*/
2024-08-06 14:46:38 +08:00
CursorUnexposedStmt = iota + 81 //200
2024-07-24 14:22:41 +08:00
/** 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
*
*/
2024-08-06 14:46:38 +08:00
CursorLabelStmt
2024-07-24 14:22:41 +08:00
/** A group of statements like { stmt stmt }.
*
* This cursor kind is used to describe compound statements, e.g. function
* bodies.
*/
2024-08-06 14:46:38 +08:00
CursorCompoundStmt
2024-07-24 14:22:41 +08:00
/** A case statement.
*/
2024-08-06 14:46:38 +08:00
CursorCaseStmt
2024-07-24 14:22:41 +08:00
/** A default statement.
*/
2024-08-06 14:46:38 +08:00
CursorDefaultStmt
2024-07-24 14:22:41 +08:00
/** An if statement
*/
2024-08-06 14:46:38 +08:00
CursorIfStmt
2024-07-24 14:22:41 +08:00
/** A switch statement.
*/
2024-08-06 14:46:38 +08:00
CursorSwitchStmt
2024-07-24 14:22:41 +08:00
/** A while statement.
*/
2024-08-06 14:46:38 +08:00
CursorWhileStmt
2024-07-24 14:22:41 +08:00
/** A do statement.
*/
2024-08-06 14:46:38 +08:00
CursorDoStmt
2024-07-24 14:22:41 +08:00
/** A for statement.
*/
2024-08-06 14:46:38 +08:00
CursorForStmt
2024-07-24 14:22:41 +08:00
/** A goto statement.
*/
2024-08-06 14:46:38 +08:00
CursorGotoStmt
2024-07-24 14:22:41 +08:00
/** An indirect goto statement.
*/
2024-08-06 14:46:38 +08:00
CursorIndirectGotoStmt
2024-07-24 14:22:41 +08:00
/** A continue statement.
*/
2024-08-06 14:46:38 +08:00
CursorContinueStmt
2024-07-24 14:22:41 +08:00
/** A break statement.
*/
2024-08-06 14:46:38 +08:00
CursorBreakStmt
2024-07-24 14:22:41 +08:00
/** A return statement.
*/
2024-08-06 14:46:38 +08:00
CursorReturnStmt
2024-07-24 14:22:41 +08:00
/** A GCC inline assembly statement extension.
*/
2024-08-06 14:46:38 +08:00
CursorGCCAsmStmt
CursorAsmStmt = CursorGCCAsmStmt
2024-07-24 14:22:41 +08:00
/** Objective-C's overall \@try-\@catch-\@finally statement.
*/
2024-08-06 14:46:38 +08:00
CursorObjCAtTryStmt = iota + 80 //216
2024-07-24 14:22:41 +08:00
/** Objective-C's \@catch statement.
*/
2024-08-06 14:46:38 +08:00
CursorObjCAtCatchStmt
2024-07-24 14:22:41 +08:00
/** Objective-C's \@finally statement.
*/
2024-08-06 14:46:38 +08:00
CursorObjCAtFinallyStmt
2024-07-24 14:22:41 +08:00
/** Objective-C's \@throw statement.
*/
2024-08-06 14:46:38 +08:00
CursorObjCAtThrowStmt
2024-07-24 14:22:41 +08:00
/** Objective-C's \@synchronized statement.
*/
2024-08-06 14:46:38 +08:00
CursorObjCAtSynchronizedStmt
2024-07-24 14:22:41 +08:00
/** Objective-C's autorelease pool statement.
*/
2024-08-06 14:46:38 +08:00
CursorObjCAutoreleasePoolStmt
2024-07-24 14:22:41 +08:00
/** Objective-C's collection statement.
*/
2024-08-06 14:46:38 +08:00
CursorObjCForCollectionStmt
2024-07-24 14:22:41 +08:00
/** C++'s catch statement.
*/
2024-08-06 14:46:38 +08:00
CursorCXXCatchStmt
2024-07-24 14:22:41 +08:00
/** C++'s try statement.
*/
2024-08-06 14:46:38 +08:00
CursorCXXTryStmt
2024-07-24 14:22:41 +08:00
/** C++'s for (* : *) statement.
*/
2024-08-06 14:46:38 +08:00
CursorCXXForRangeStmt
2024-07-24 14:22:41 +08:00
/** Windows Structured Exception Handling's try statement.
*/
2024-08-06 14:46:38 +08:00
CursorSEHTryStmt
2024-07-24 14:22:41 +08:00
/** Windows Structured Exception Handling's except statement.
*/
2024-08-06 14:46:38 +08:00
CursorSEHExceptStmt
2024-07-24 14:22:41 +08:00
/** Windows Structured Exception Handling's finally statement.
*/
2024-08-06 14:46:38 +08:00
CursorSEHFinallyStmt
2024-07-24 14:22:41 +08:00
/** A MS inline assembly statement extension.
*/
2024-08-06 14:46:38 +08:00
CursorMSAsmStmt
2024-07-24 14:22:41 +08:00
/** The null statement ";": C99 6.8.3p3.
*
* This cursor kind is used to describe the null statement.
*/
2024-08-06 14:46:38 +08:00
CursorNullStmt
2024-07-24 14:22:41 +08:00
/** Adaptor class for mixing declarations with statements and
* expressions.
*/
2024-08-06 14:46:38 +08:00
CursorDeclStmt
2024-07-24 14:22:41 +08:00
/** OpenMP parallel directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelDirective
2024-07-24 14:22:41 +08:00
/** OpenMP SIMD directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP for directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPForDirective
2024-07-24 14:22:41 +08:00
/** OpenMP sections directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPSectionsDirective
2024-07-24 14:22:41 +08:00
/** OpenMP section directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPSectionDirective
2024-07-24 14:22:41 +08:00
/** OpenMP single directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPSingleDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel for directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelForDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel sections directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelSectionsDirective
2024-07-24 14:22:41 +08:00
/** OpenMP task directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTaskDirective
2024-07-24 14:22:41 +08:00
/** OpenMP master directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPMasterDirective
2024-07-24 14:22:41 +08:00
/** OpenMP critical directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPCriticalDirective
2024-07-24 14:22:41 +08:00
/** OpenMP taskyield directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTaskyieldDirective
2024-07-24 14:22:41 +08:00
/** OpenMP barrier directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPBarrierDirective
2024-07-24 14:22:41 +08:00
/** OpenMP taskwait directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTaskwaitDirective
2024-07-24 14:22:41 +08:00
/** OpenMP flush directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPFlushDirective
2024-07-24 14:22:41 +08:00
/** Windows Structured Exception Handling's leave statement.
*/
2024-08-06 14:46:38 +08:00
CursorSEHLeaveStmt
2024-07-24 14:22:41 +08:00
/** OpenMP ordered directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPOrderedDirective
2024-07-24 14:22:41 +08:00
/** OpenMP atomic directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPAtomicDirective
2024-07-24 14:22:41 +08:00
/** OpenMP for SIMD directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPForSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel for SIMD directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelForSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetDirective
2024-07-24 14:22:41 +08:00
/** OpenMP teams directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTeamsDirective
2024-07-24 14:22:41 +08:00
/** OpenMP taskgroup directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTaskgroupDirective
2024-07-24 14:22:41 +08:00
/** OpenMP cancellation point directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPCancellationPointDirective
2024-07-24 14:22:41 +08:00
/** OpenMP cancel directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPCancelDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target data directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetDataDirective
2024-07-24 14:22:41 +08:00
/** OpenMP taskloop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTaskLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP taskloop simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTaskLoopSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP distribute directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPDistributeDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target enter data directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetEnterDataDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target exit data directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetExitDataDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target parallel directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetParallelDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target parallel for directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetParallelForDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target update directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetUpdateDirective
2024-07-24 14:22:41 +08:00
/** OpenMP distribute parallel for directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPDistributeParallelForDirective
2024-07-24 14:22:41 +08:00
/** OpenMP distribute parallel for simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPDistributeParallelForSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP distribute simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPDistributeSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target parallel for simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetParallelForSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP teams distribute directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTeamsDistributeDirective
2024-07-24 14:22:41 +08:00
/** OpenMP teams distribute simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTeamsDistributeSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP teams distribute parallel for simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTeamsDistributeParallelForSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP teams distribute parallel for directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTeamsDistributeParallelForDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target teams directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetTeamsDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target teams distribute directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetTeamsDistributeDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target teams distribute parallel for directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetTeamsDistributeParallelForDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target teams distribute parallel for simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetTeamsDistributeParallelForSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target teams distribute simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetTeamsDistributeSimdDirective
2024-07-24 14:22:41 +08:00
/** C++2a std::bit_cast expression.
*/
2024-08-06 14:46:38 +08:00
CursorBuiltinBitCastExpr
2024-07-24 14:22:41 +08:00
/** OpenMP master taskloop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPMasterTaskLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel master taskloop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelMasterTaskLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP master taskloop simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPMasterTaskLoopSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel master taskloop simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelMasterTaskLoopSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel master directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelMasterDirective
2024-07-24 14:22:41 +08:00
/** OpenMP depobj directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPDepobjDirective
2024-07-24 14:22:41 +08:00
/** OpenMP scan directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPScanDirective
2024-07-24 14:22:41 +08:00
/** OpenMP tile directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTileDirective
2024-07-24 14:22:41 +08:00
/** OpenMP canonical loop.
*/
2024-08-06 14:46:38 +08:00
CursorOMPCanonicalLoop
2024-07-24 14:22:41 +08:00
/** OpenMP interop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPInteropDirective
2024-07-24 14:22:41 +08:00
/** OpenMP dispatch directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPDispatchDirective
2024-07-24 14:22:41 +08:00
/** OpenMP masked directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPMaskedDirective
2024-07-24 14:22:41 +08:00
/** OpenMP unroll directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPUnrollDirective
2024-07-24 14:22:41 +08:00
/** OpenMP metadirective directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPMetaDirective
2024-07-24 14:22:41 +08:00
/** OpenMP loop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPGenericLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP teams loop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTeamsGenericLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target teams loop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetTeamsGenericLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel loop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelGenericLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP target parallel loop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPTargetParallelGenericLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel masked directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelMaskedDirective
2024-07-24 14:22:41 +08:00
/** OpenMP masked taskloop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPMaskedTaskLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP masked taskloop simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPMaskedTaskLoopSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel masked taskloop directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelMaskedTaskLoopDirective
2024-07-24 14:22:41 +08:00
/** OpenMP parallel masked taskloop simd directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPParallelMaskedTaskLoopSimdDirective
2024-07-24 14:22:41 +08:00
/** OpenMP error directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPErrorDirective
2024-07-24 14:22:41 +08:00
/** OpenMP scope directive.
*/
2024-08-06 14:46:38 +08:00
CursorOMPScopeDirective
2024-07-24 14:22:41 +08:00
2024-08-06 14:46:38 +08:00
CursorLastStmt = CursorOMPScopeDirective
2024-07-24 14:22:41 +08:00
/**
* 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.
*/
CursorTranslationUnit = 350
/* Attributes */
2024-08-06 14:46:38 +08:00
CursorFirstAttr = 400
2024-07-24 14:22:41 +08:00
/**
* An attribute whose specific kind is not exposed via this
* interface.
*/
2024-08-06 14:46:38 +08:00
CursorUnexposedAttr = iota + 170
CursorIBActionAttr
CursorIBOutletAttr
CursorIBOutletCollectionAttr
CursorCXXFinalAttr
CursorCXXOverrideAttr
CursorAnnotateAttr
CursorAsmLabelAttr
CursorPackedAttr
CursorPureAttr
CursorConstAttr
CursorNoDuplicateAttr
CursorCUDAConstantAttr
CursorCUDADeviceAttr
CursorCUDAGlobalAttr
CursorCUDAHostAttr
CursorCUDASharedAttr
CursorVisibilityAttr
CursorDLLExport
CursorDLLImport
CursorNSReturnsRetained
CursorNSReturnsNotRetained
CursorNSReturnsAutoreleased
CursorNSConsumesSelf
CursorNSConsumed
CursorObjCException
CursorObjCNSObject
CursorObjCIndependentClass
CursorObjCPreciseLifetime
CursorObjCReturnsInnerPointer
CursorObjCRequiresSuper
CursorObjCRootClass
CursorObjCSubclassingRestricted
CursorObjCExplicitProtocolImpl
CursorObjCDesignatedInitializer
CursorObjCRuntimeVisible
CursorObjCBoxable
CursorFlagEnum
CursorConvergentAttr
CursorWarnUnusedAttr
CursorWarnUnusedResultAttr
CursorAlignedAttr
CursorLastAttr = CursorAlignedAttr
2024-07-24 14:22:41 +08:00
/* Preprocessing */
2024-08-06 14:46:38 +08:00
CursorPreprocessingDirective = iota + 227 //500
CursorMacroDefinition
CursorMacroExpansion
CursorMacroInstantiation = CursorMacroExpansion
CursorInclusionDirective = 503
CursorFirstPreprocessing = CursorPreprocessingDirective
CursorLastPreprocessing = CursorInclusionDirective
2024-07-24 14:22:41 +08:00
/* Extra Declarations */
/**
* A module import declaration.
*/
2024-08-06 14:46:38 +08:00
CursorModuleImportDecl = iota + 320 //600
CursorTypeAliasTemplateDecl
2024-07-24 14:22:41 +08:00
/**
* A static_assert or _Static_assert node
*/
2024-08-06 14:46:38 +08:00
CursorStaticAssert
2024-07-24 14:22:41 +08:00
/**
* a friend declaration.
*/
2024-08-06 14:46:38 +08:00
CursorFriendDecl
2024-07-24 14:22:41 +08:00
/**
* a concept declaration.
*/
2024-08-06 14:46:38 +08:00
CursorConceptDecl
2024-07-24 14:22:41 +08:00
2024-08-06 14:46:38 +08:00
CursorFirstExtraDecl = CursorModuleImportDecl
CursorLastExtraDecl = CursorConceptDecl
2024-07-24 14:22:41 +08:00
/**
* A code completion overload candidate.
*/
2024-08-06 14:46:38 +08:00
CursorOverloadCandidate = 700
2024-07-24 14:22:41 +08:00
)
/**
* Opaque pointer representing client data that will be passed through
* to various callbacks and visitors.
*/
type ClientData = c.Pointer
/**
* Provides the contents of a file that has not yet been saved to disk.
*
* Each CXUnsavedFile instance provides the name of a file on the
* system along with the current contents of that file that have not
* yet been saved to disk.
*/
type UnsavedFile struct {
/**
* The file whose contents have not yet been saved.
*
* This file must already exist in the file system.
*/
Filename *c.Char
/**
* A buffer containing the unsaved contents of this file.
*/
Contents *c.Char
/**
* The length of the unsaved contents of this buffer.
*/
Length c.Ulong
}
/**
* An "index" that consists of a set of translation units that would
* typically be linked together into an executable or library.
*/
type Index struct {
Unused [0]byte
}
/**
* 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:
*
* \code
* // 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);
* \endcode
*
* 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).
*/
//go:linkname CreateIndex C.clang_createIndex
func CreateIndex(excludeDeclarationsFromPCH, displayDiagnostics c.Int) *Index
/**
* Destroy the given index.
*
* The index must not be destroyed until all of the translation units created
* within that index have been destroyed.
*/
// llgo:link (*Index).Dispose C.clang_disposeIndex
func (*Index) Dispose() {}
/**
* 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.
*/
const (
2024-08-04 13:55:19 +08:00
/**
* Used to indicate that no special translation-unit options are
* needed.
*/
TranslationUnit_None = 0x0
2024-08-04 13:55:19 +08:00
/**
* 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.
*/
DetailedPreprocessingRecord = 0x01
)
/**
* Same as \c clang_parseTranslationUnit2, but returns
* the \c CXTranslationUnit instead of an error code. In case of an error this
* routine returns a \c NULL \c CXTranslationUnit, without further detailed
* error codes.
*/
// llgo:link (*Index).ParseTranslationUnit C.clang_parseTranslationUnit
func (*Index) ParseTranslationUnit(
sourceFilename *c.Char, commandLineArgs **c.Char, numCommandLineArgs c.Int,
unsavedFiles *UnsavedFile, numUnsavedFiles c.Uint, options c.Uint) *TranslationUnit {
return nil
}
/**
* A single translation unit, which resides in an index.
*/
type TranslationUnit struct {
Unused [0]byte
}
/**
* Destroy the specified CXTranslationUnit object.
*/
// llgo:link (*TranslationUnit).Dispose C.clang_disposeTranslationUnit
func (*TranslationUnit) Dispose() {}
/**
* 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.
*/
//llgo:link (*TranslationUnit).wrapCursor C.wrap_clang_getTranslationUnitCursor
func (t *TranslationUnit) wrapCursor(cursor *Cursor) {}
func (t *TranslationUnit) Cursor() (ret Cursor) {
t.wrapCursor(&ret)
return
}
/**
* Describes the kind of entity that a cursor refers to.
*/
type CursorKind c.Int
/* for debug/testing */
// llgo:link CursorKind.String C.clang_getCursorKindSpelling
func (CursorKind) String() (ret String) {
return
}
2024-06-25 00:33:48 +08:00
/**
* 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.
*/
type Cursor struct {
Kind CursorKind
2024-07-24 14:22:41 +08:00
xdata c.Int
data [3]c.Pointer
}
2024-08-06 15:55:21 +08:00
type TypeKind c.Int
/**
* Describes the kind of type
*/
const (
/**
* Represents an invalid type (e.g., where no type is available).
*/
TypeInvalid TypeKind = iota
/**
* A type whose specific kind is not exposed via this
* interface.
*/
TypeUnexposed
/* Builtin types */
TypeVoid
TypeBool
TypeCharU
TypeUChar
TypeChar16
TypeChar32
TypeUShort
TypeUInt
TypeULong
TypeULongLong
TypeUInt128
TypeCharS
TypeSChar
TypeWChar
TypeShort
TypeInt
TypeLong
TypeLongLong
TypeInt128
TypeFloat
TypeDouble
TypeLongDouble
TypeNullPtr
TypeOverload
TypeDependent
TypeObjCId
TypeObjCClass
TypeObjCSel
TypeFloat128
TypeHalf
TypeFloat16
TypeShortAccum
TypeAccum
TypeLongAccum
TypeUShortAccum
TypeUAccum
TypeULongAccum
TypeBFloat16
TypeIbm128
TypeFirstBuiltin = TypeVoid
TypeLastBuiltin = TypeIbm128
TypeComplex TypeKind = iota + 57 // 100
TypePointer
TypeBlockPointer
TypeLValueReference
TypeRValueReference
TypeRecord
TypeEnum
TypeTypedef
TypeObjCInterface
TypeObjCObjectPointer
TypeFunctionNoProto
TypeFunctionProto
TypeConstantArray
TypeVector
TypeIncompleteArray
TypeVariableArray
TypeDependentSizedArray
TypeMemberPointer
TypeAuto
/**
* Represents a type that was referred to using an elaborated type keyword.
*
* E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
*/
TypeElaborated
/* OpenCL PipeType. */
TypePipe
/* OpenCL builtin types. */
TypeOCLImage1dRO
TypeOCLImage1dArrayRO
TypeOCLImage1dBufferRO
TypeOCLImage2dRO
TypeOCLImage2dArrayRO
TypeOCLImage2dDepthRO
TypeOCLImage2dArrayDepthRO
TypeOCLImage2dMSAARO
TypeOCLImage2dArrayMSAARO
TypeOCLImage2dMSAADepthRO
TypeOCLImage2dArrayMSAADepthRO
TypeOCLImage3dRO
TypeOCLImage1dWO
TypeOCLImage1dArrayWO
TypeOCLImage1dBufferWO
TypeOCLImage2dWO
TypeOCLImage2dArrayWO
TypeOCLImage2dDepthWO
TypeOCLImage2dArrayDepthWO
TypeOCLImage2dMSAAWO
TypeOCLImage2dArrayMSAAWO
TypeOCLImage2dMSAADepthWO
TypeOCLImage2dArrayMSAADepthWO
TypeOCLImage3dWO
TypeOCLImage1dRW
TypeOCLImage1dArrayRW
TypeOCLImage1dBufferRW
TypeOCLImage2dRW
TypeOCLImage2dArrayRW
TypeOCLImage2dDepthRW
TypeOCLImage2dArrayDepthRW
TypeOCLImage2dMSAARW
TypeOCLImage2dArrayMSAARW
TypeOCLImage2dMSAADepthRW
TypeOCLImage2dArrayMSAADepthRW
TypeOCLImage3dRW
TypeOCLSampler
TypeOCLEvent
TypeOCLQueue
TypeOCLReserveID
TypeObjCObject
TypeObjCTypeParam
TypeAttributed
TypeOCLIntelSubgroupAVCMcePayload
TypeOCLIntelSubgroupAVCImePayload
TypeOCLIntelSubgroupAVCRefPayload
TypeOCLIntelSubgroupAVCSicPayload
TypeOCLIntelSubgroupAVCMceResult
TypeOCLIntelSubgroupAVCImeResult
TypeOCLIntelSubgroupAVCRefResult
TypeOCLIntelSubgroupAVCSicResult
TypeOCLIntelSubgroupAVCImeResultSingleReferenceStreamout
TypeOCLIntelSubgroupAVCImeResultDualReferenceStreamout
TypeOCLIntelSubgroupAVCImeSingleReferenceStreamin
TypeOCLIntelSubgroupAVCImeDualReferenceStreamin
/* Old aliases for AVC OpenCL extension types. */
TypeOCLIntelSubgroupAVCImeResultSingleRefStreamout = TypeOCLIntelSubgroupAVCImeResultSingleReferenceStreamout
TypeOCLIntelSubgroupAVCImeResultDualRefStreamout = TypeOCLIntelSubgroupAVCImeResultDualReferenceStreamout
TypeOCLIntelSubgroupAVCImeSingleRefStreamin = TypeOCLIntelSubgroupAVCImeSingleReferenceStreamin
TypeOCLIntelSubgroupAVCImeDualRefStreamin = TypeOCLIntelSubgroupAVCImeDualReferenceStreamin
TypeExtVector = iota + 53 // 176
TypeAtomic
TypeBTFTagAttributed
)
/**
* The type of an element in the abstract syntax tree.
*
*/
2024-07-24 14:22:41 +08:00
type Type struct {
2024-08-06 15:55:21 +08:00
Kind TypeKind
2024-07-24 14:22:41 +08:00
data [2]c.Pointer
2024-06-25 00:33:48 +08:00
}
/**
* A particular source file that is part of a translation unit.
*/
type File uintptr
/**
* 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.
*/
type SourceLocation struct {
ptrData [2]c.Pointer
intData c.Uint
}
2024-08-04 13:55:19 +08:00
/**
* 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.
*/
type SourceRange struct {
ptrData [2]c.Pointer
beginIntData c.Uint
endIntData c.Uint
}
/**
* Describes a kind of token.
*/
type TokenKind c.Int
const (
/**
* A token that contains some kind of punctuation.
*/
Punctuation TokenKind = iota
/**
* A language keyword.
*/
Keyword
/**
* An identifier (that is not a keyword).
*/
Identifier
/**
* A numeric, string, or character literal.
*/
Literal
/**
* A comment.
*/
Comment
)
type Token struct {
intData [4]c.Uint
ptrData c.Pointer
}
2024-06-25 00:33:48 +08:00
/**
* Retrieve a name for the entity referenced by this cursor.
*/
2024-07-15 13:14:47 +08:00
// llgo:link (*Cursor).wrapString C.wrap_clang_getCursorSpelling
func (*Cursor) wrapString() (ret String) {
2024-06-25 00:33:48 +08:00
return
}
2024-07-15 13:14:47 +08:00
func (c Cursor) String() (ret String) {
return c.wrapString()
}
2024-07-15 01:07:26 +08:00
2024-07-24 14:22:41 +08:00
/**
* Retrieve a name for the entity referenced by this cursor.
*/
// llgo:link (*Cursor).wrapMangling C.wrap_clang_Cursor_getMangling
func (*Cursor) wrapMangling() (ret String) {
return
}
func (c Cursor) Mangling() (ret String) {
return c.wrapMangling()
}
/**
* Retrieve the type of a CXCursor (if any).
*/
// llgo:link (*Cursor).wrapType C.wrap_clang_getCursorType
func (c *Cursor) wrapType(ret *Type) {}
func (c Cursor) Type() (ret Type) {
2024-07-24 14:22:41 +08:00
c.wrapType(&ret)
return
}
/**
* Retrieve the return type associated with a given cursor.
*
* This only returns a valid type if the cursor refers to a function or method.
*/
// llgo:link (*Cursor).wrapResultType C.wrap_clang_getCursorResultType
func (c *Cursor) wrapResultType(ret *Type) {}
func (c Cursor) ResultType() (ret Type) {
2024-07-24 14:22:41 +08:00
c.wrapResultType(&ret)
return
}
/**
* Retrieve the number of non-variadic arguments associated with a given
* cursor.
*
* The number of arguments can be determined for calls as well as for
* declarations of functions or methods. For other cursors -1 is returned.
*/
// llgo:link (*Cursor).wrapNumArguments C.wrap_clang_Cursor_getNumArguments
func (*Cursor) wrapNumArguments() (num c.Int) {
return 0
}
func (c Cursor) NumArguments() (num c.Int) {
return c.wrapNumArguments()
}
/**
* Retrieve the argument cursor of a function or method.
*
* The argument cursor can be determined for calls as well as for declarations
* of functions or methods. For other cursors and for invalid indices, an
* invalid cursor is returned.
*/
// llgo:link (*Cursor).wrapArgument C.wrap_clang_Cursor_getArgument
func (*Cursor) wrapArgument(index c.Uint, arg *Cursor) {}
2024-07-24 14:22:41 +08:00
func (c Cursor) Argument(index c.Uint) (arg Cursor) {
2024-07-24 14:22:41 +08:00
c.wrapArgument(index, &arg)
return
}
2024-08-05 19:26:59 +08:00
/**
* 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.
*/
// llgo:link (*Cursor).wrapLocation C.wrap_clang_getCursorLocation
func (c *Cursor) wrapLocation(loc *SourceLocation) {}
func (c Cursor) Location() (loc SourceLocation) {
c.wrapLocation(&loc)
return
}
2024-08-06 15:55:21 +08:00
/**
* Represents the C++ access control level to a base class for a
* cursor with kind CX_CXXBaseSpecifier.
*/
type CXXAccessSpecifier c.Int
const (
CXXInvalidAccessSpecifier CXXAccessSpecifier = iota
CXXPublic
CXXProtected
CXXPrivate
)
/**
* Returns the access control level for the referenced object.
*
* If the cursor refers to a C++ declaration, its access control level within
* its parent scope is returned. Otherwise, if the cursor refers to a base
* specifier or access specifier, the specifier itself is returned.
*/
// llgo:link (*Cursor).wrapCXXAccessSpecifier C.wrap_clang_getCXXAccessSpecifier
func (*Cursor) wrapCXXAccessSpecifier() (spec CXXAccessSpecifier) {
return 0
}
func (c Cursor) CXXAccessSpecifier() CXXAccessSpecifier {
return c.wrapCXXAccessSpecifier()
}
2024-08-04 13:55:19 +08:00
/**
* 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 within that source construct. For a
* declaration, the extent covers the declaration itself. For a reference,
* the extent covers the location of the reference (e.g., where the referenced
* entity was actually used).
*/
// llgo:link (*Cursor).wrapExtent C.wrap_clang_getCursorExtent
func (c *Cursor) wrapExtent(loc *SourceRange) {}
func (c Cursor) Extent() (loc SourceRange) {
c.wrapExtent(&loc)
return
}
/**
* 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.
*
*/
// llgo:link (*TranslationUnit).wrapTokenize C.wrap_clang_tokenize
func (t *TranslationUnit) wrapTokenize(ran *SourceRange, tokens **Token, numTokens *c.Uint) {}
2024-08-05 19:26:59 +08:00
func (t *TranslationUnit) Tokenize(ran SourceRange, tokens **Token, numTokens *c.Uint) {
2024-08-04 13:55:19 +08:00
t.wrapTokenize(&ran, tokens, numTokens)
}
/**
* 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.
*/
// llgo:link (*TranslationUnit).wrapToken C.wrap_clang_getTokenSpelling
func (*TranslationUnit) wrapToken(token *Token) (ret String) {
return
}
2024-08-05 19:26:59 +08:00
func (c *TranslationUnit) Token(token Token) (ret String) {
2024-08-04 13:55:19 +08:00
return c.wrapToken(&token)
}
/**
* 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.
*/
// llgo:link (*SourceLocation).wrapSpellingLocation C.wrap_clang_getSpellingLocation
func (l *SourceLocation) wrapSpellingLocation(file *File, line, column, offset *c.Uint) {}
func (l SourceLocation) SpellingLocation(file *File, line, column, offset *c.Uint) {
l.wrapSpellingLocation(file, line, column, offset)
}
2024-07-24 14:22:41 +08:00
/**
* 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.
*/
// llgo:link (*Type).wrapString C.wrap_clang_getTypeSpelling
func (t *Type) wrapString() (ret String) {
return
}
func (t Type) String() (ret String) {
return t.wrapString()
}
//llgo:link File.FileName C.clang_getFileName
func (File) FileName() (ret String) { return }
2024-06-25 00:33:48 +08:00
/**
* 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.
*/
type ChildVisitResult c.Int
const (
/**
* Terminates the cursor traversal.
*/
ChildVisit_Break ChildVisitResult = iota
/**
* Continues the cursor traversal with the next sibling of
* the cursor just visited, without visiting its children.
*/
ChildVisit_Continue
/**
* Recursively traverse the children of this cursor, using
* the same visitor and client data.
*/
ChildVisit_Recurse
)
/**
* 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.
*/
2024-07-15 13:14:47 +08:00
//go:linkname wrapVisitChildren C.wrap_clang_visitChildren
func wrapVisitChildren(
cusor *Cursor,
fn wrapVisitor,
2024-06-25 00:33:48 +08:00
clientData ClientData) c.Uint {
return 0
}
2024-07-15 13:14:47 +08:00
//llgo:type C
type wrapVisitor func(cursor, parent *Cursor, clientData ClientData) ChildVisitResult
type wrapData struct {
data ClientData
fn Visitor
}
func VisitChildren(
root Cursor,
fn Visitor,
clientData ClientData) c.Uint {
return wrapVisitChildren(&root, func(cursor, parent *Cursor, data ClientData) ChildVisitResult {
p := (*wrapData)(data)
return p.fn(*cursor, *parent, p.data)
}, unsafe.Pointer(&wrapData{clientData, fn}))
}
//llgo:type C
type Visitor func(cursor, parent Cursor, clientData ClientData) ChildVisitResult