#include "clang/AST/Type.h" QualType myType = ... ; // get type from AST node if (myType->isPointerType()) { // do something with pointer type }
#include "clang/AST/Type.h" QualType myType = ... ; // get type from AST node Qualifiers qs = myType.getQualifiers(); qs.addConst(); myType = myType.getWithAdditionalQualifiers(qs);In this example, we again use the QualType class from the Clang library to add a const qualifier to a given type. We do this by first calling the getQualifiers() method on our original QualType instance to retrieve its existing qualifiers. We then add a const qualifier using the addConst() method of the Qualifiers class. Finally, we create a new QualType instance with the updated qualifiers using the getWithAdditionalQualifiers() method. Package library: LLVM Clang