Dear Clang developers, I am experimenting with “poor man’s deep const” in C++.
I have the following C++ code:
#define immutable const
struct CC { immutable int myInt; };
I would like to use Clang to check if the type qualifier source code reads “const” or “immutable”.
I am able to retrieve the clang::FieldDecl and it’s QualType.
Is it possible, given my fieldDecl, to retrieve it’s DeclSpec?
If I had a DeclSpec, I would then call DeclSpec::getConstSpecLoc() and retrieve the source code at that location.
Here are two of the approaches I already tried:
-
called fieldDecl->getSourceRange(); but that returns range only for “int myInt”
-
retrieved my field’s TypeLoc and cast it to a QualifiedTypeLoc.
But, as the header file warns, the QualifiedTypeLoc does not have valid SourceRange data.
Any ideas?
Thanks for your advice,
Jiri