clang 19.0.0git
Enumerations | Functions
C++ AST introspection

The routines in this group provide access information in the ASTs specific to C++ language features. More...

Collaboration diagram for C++ AST introspection:

Enumerations

enum  CXNameRefFlags { CXNameRange_WantQualifier = 0x1 , CXNameRange_WantTemplateArgs = 0x2 , CXNameRange_WantSinglePiece = 0x4 }
 

Functions

CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor (CXCursor C)
 Determine if a C++ constructor is a converting constructor.
 
CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor (CXCursor C)
 Determine if a C++ constructor is a copy constructor.
 
CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor (CXCursor C)
 Determine if a C++ constructor is the default constructor.
 
CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor (CXCursor C)
 Determine if a C++ constructor is a move constructor.
 
CINDEX_LINKAGE unsigned clang_CXXField_isMutable (CXCursor C)
 Determine if a C++ field is declared 'mutable'.
 
CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted (CXCursor C)
 Determine if a C++ method is declared '= default'.
 
CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted (CXCursor C)
 Determine if a C++ method is declared '= delete'.
 
CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual (CXCursor C)
 Determine if a C++ member function or member function template is pure virtual.
 
CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic (CXCursor C)
 Determine if a C++ member function or member function template is declared 'static'.
 
CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual (CXCursor C)
 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.
 
CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator (CXCursor C)
 Determine if a C++ member function is a copy-assignment operator, returning 1 if such is the case and 0 otherwise.
 
CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator (CXCursor C)
 Determine if a C++ member function is a move-assignment operator, returning 1 if such is the case and 0 otherwise.
 
CINDEX_LINKAGE unsigned clang_CXXMethod_isExplicit (CXCursor C)
 Determines if a C++ constructor or conversion function was declared explicit, returning 1 if such is the case and 0 otherwise.
 
CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract (CXCursor C)
 Determine if a C++ record is abstract, i.e.
 
CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped (CXCursor C)
 Determine if an enum declaration refers to a scoped enum.
 
CINDEX_LINKAGE unsigned clang_CXXMethod_isConst (CXCursor C)
 Determine if a C++ member function or member function template is declared 'const'.
 
CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind (CXCursor C)
 Given a cursor that represents a template, determine the cursor kind of the specializations would be generated by instantiating the template.
 
CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate (CXCursor C)
 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.
 
CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange (CXCursor C, unsigned NameFlags, unsigned PieceIndex)
 Given a cursor that references something else, return the source range covering that reference.
 

Detailed Description

The routines in this group provide access information in the ASTs specific to C++ language features.

Enumeration Type Documentation

◆ CXNameRefFlags

Enumerator
CXNameRange_WantQualifier 

Include the nested-name-specifier, e.g.

Foo:: in x.Foo::y, in the range.

CXNameRange_WantTemplateArgs 

Include the explicit template arguments, e.g.

<int> in x.f<int>, in the range.

CXNameRange_WantSinglePiece 

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:

[object doSomething:here withValue:there]; // Objective-C
return some_vector[1]; // C++

Definition at line 4656 of file Index.h.

Function Documentation

◆ clang_CXXConstructor_isConvertingConstructor()

CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor ( CXCursor  C)

Determine if a C++ constructor is a converting constructor.

◆ clang_CXXConstructor_isCopyConstructor()

CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor ( CXCursor  C)

Determine if a C++ constructor is a copy constructor.

◆ clang_CXXConstructor_isDefaultConstructor()

CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor ( CXCursor  C)

Determine if a C++ constructor is the default constructor.

◆ clang_CXXConstructor_isMoveConstructor()

CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor ( CXCursor  C)

Determine if a C++ constructor is a move constructor.

◆ clang_CXXField_isMutable()

CINDEX_LINKAGE unsigned clang_CXXField_isMutable ( CXCursor  C)

Determine if a C++ field is declared 'mutable'.

◆ clang_CXXMethod_isConst()

CINDEX_LINKAGE unsigned clang_CXXMethod_isConst ( CXCursor  C)

Determine if a C++ member function or member function template is declared 'const'.

◆ clang_CXXMethod_isCopyAssignmentOperator()

CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator ( CXCursor  C)

Determine if a C++ member function is a copy-assignment operator, returning 1 if such is the case and 0 otherwise.

‍A copy-assignment operator X::operator= is a non-static, non-template member function of class X with exactly one parameter of type X, X&, const X&, volatile X& or const volatile X&.

That is, for example, the operator= in:

class Foo { bool operator=(const volatile Foo&); };

Is a copy-assignment operator, while the operator= in:

class Bar { bool operator=(const int&); };

Is not.

◆ clang_CXXMethod_isDefaulted()

CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted ( CXCursor  C)

Determine if a C++ method is declared '= default'.

◆ clang_CXXMethod_isDeleted()

CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted ( CXCursor  C)

Determine if a C++ method is declared '= delete'.

◆ clang_CXXMethod_isExplicit()

CINDEX_LINKAGE unsigned clang_CXXMethod_isExplicit ( CXCursor  C)

Determines if a C++ constructor or conversion function was declared explicit, returning 1 if such is the case and 0 otherwise.

Constructors or conversion functions are declared explicit through the use of the explicit specifier.

For example, the following constructor and conversion function are not explicit as they lack the explicit specifier:

class Foo {
    Foo();
    operator int();
};

While the following constructor and conversion function are explicit as they are declared with the explicit specifier.

class Foo {
    explicit Foo();
    explicit operator int();
};

This function will return 0 when given a cursor pointing to one of the former declarations and it will return 1 for a cursor pointing to the latter declarations.

The explicit specifier allows the user to specify a conditional compile-time expression whose value decides whether the marked element is explicit or not.

For example:

constexpr bool foo(int i) { return i % 2 == 0; }

class Foo {
     explicit(foo(1)) Foo();
     explicit(foo(2)) operator int();
}

This function will return 0 for the constructor and 1 for the conversion function.

◆ clang_CXXMethod_isMoveAssignmentOperator()

CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator ( CXCursor  C)

Determine if a C++ member function is a move-assignment operator, returning 1 if such is the case and 0 otherwise.

‍A move-assignment operator X::operator= is a non-static, non-template member function of class X with exactly one parameter of type X&&, const X&&, volatile X&& or const volatile X&&.

That is, for example, the operator= in:

class Foo { bool operator=(const volatile Foo&&); };

Is a move-assignment operator, while the operator= in:

class Bar { bool operator=(const int&&); };

Is not.

◆ clang_CXXMethod_isPureVirtual()

CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual ( CXCursor  C)

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

◆ clang_CXXMethod_isStatic()

CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic ( CXCursor  C)

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

◆ clang_CXXMethod_isVirtual()

CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual ( CXCursor  C)

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.

◆ clang_CXXRecord_isAbstract()

CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract ( CXCursor  C)

Determine if a C++ record is abstract, i.e.

whether a class or struct has a pure virtual member function.

◆ clang_EnumDecl_isScoped()

CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped ( CXCursor  C)

Determine if an enum declaration refers to a scoped enum.

◆ clang_getCursorReferenceNameRange()

CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange ( CXCursor  C,
unsigned  NameFlags,
unsigned  PieceIndex 
)

Given a cursor that references something else, return the source range covering that reference.

Parameters
CA cursor pointing to a member reference, a declaration reference, or an operator call.
NameFlagsA bitset with three independent flags: CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and CXNameRange_WantSinglePiece.
PieceIndexFor 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 retrieve 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.

◆ clang_getSpecializedCursorTemplate()

CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate ( CXCursor  C)

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., std::vector<bool>), this routine will return either the primary template (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.

Parameters
CA 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.

◆ clang_getTemplateCursorKind()

CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind ( CXCursor  C)

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

Parameters
CThe 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 C. If C is not a template, returns CXCursor_NoDeclFound.