fabic974 random (binary) wanderings in the philament empires…

LLVM/Clang API pointers

</td>
What Method / attributes
ASTContext QualType ASTContext::getTagDeclType (const TagDecl *Decl) const; TagDecl * Type::getAsTagDecl () const;
ASTContext QualType ASTContext::getTypeDeclType ( const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const;Type (as QualType) –given– TypeDecl
Type template< typename T >
const T * Type::getAs<T>() const;
Type CXXRecordDecl * getAsCXXRecordDecl () const;
Type const CXXRecordDecl * getPointeeCXXRecordDecl () const;
Decl
NamedDecl
TypeDecl
TagDecl
ValueDecl

List all Decl nodes

cat <<EOF | clang++ -E -x c++ - | sed -e '/^$/d;/^#/d' | sort -k2 | column -t -s :
#define DECL(CLASS, BASE) CLASS  :  BASE
#include "clang/AST/DeclNodes.inc"
EOF

More convenient with a one-liner :

echo -e '#define DECL(CLASS, BASE) CLASS : BASE\n#include "clang/AST/DeclNodes.inc"\n' \
  | clang++ -E -x c++ -  \
  | sed -e '/^$/d;/^#/d' \
  | sort -k2             \
  | column -t -s :

Likewise for the Type hierarchy :

echo -e '#define TYPE(CLASS, BASE) CLASS : BASE\n#include "clang/AST/TypeNodes.def"\n'  \
  | clang++ -E -x c++ -  \
  | sed -e '/^$/d;/^#/d' \
  | sort -k2             \
  | column -t -s :

The BuiltinType/s :

TODO

And the Stmt hierarchy :

echo -e '#define STMT(CLASS, BASE) CLASS : BASE\n#include "clang/AST/StmtNodes.inc"\n'  \
  | clang++ -E -x c++ -  \
  | sed -e '/^$/d;/^#/d' \
  | sort -k2             \
  | column -t -s :

Pointers

ASTContext

Type

See also TypeSourceInfo that we typically obtain from Decl/s

Decl

NamedDecl

TypeDecl

ValueDecl

DeclaratorDecl

  • [TypeSourceInfo][TypeSourceInfo] * DeclaratorDecl::getTypeSourceInfo () const;
  • SourceRange DeclaratorDecl::getSourceRange () const override LLVM_READONLY;
  • SourceLocation DeclaratorDecl::getLocStart () const LLVM_READONLY;
  • SourceLocation DeclaratorDecl::getTypeSpecStartLoc () const;

DeclContext

TagDecl

FunctionDecl