[cfe-dev] Deep const experiment - how to retrieve SourceLocation of "const"?

george moudry gmoudry_2004 at hotmail.com
Tue Aug 2 14:08:25 PDT 2011



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:1) called fieldDecl->getSourceRange(); but that returns range only for "int myInt"2) 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 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110802/ac5c166d/attachment.html>


More information about the cfe-dev mailing list