[cfe-dev] get identifier end SourceLocation of CXXRecordDecl

Ivan Sorokin sorokin at rain.ifmo.ru
Mon Mar 8 04:25:47 PST 2010


Hello!

I have a bit stupid question about getting SourceLocation from clang ast.

CXXRecordDecl has getLocation() member function that returns 
SourceLocation of first character of identifier. That is for code

struct test {};

getLocation() points to first letter of "test" identifier. CXXRecordDecl 
also has getLocStart() and getLocEnd() that return SourceLocation of 
first letter of "struct" keyword and closing bracket "}" correspondingly.

But how can I get position of last letter of "test" identifier, position 
of last letter of "struct" keyword and position of open bracket "{". I 
can use SourceManager::getCharacterData() and skip over letters and 
digits until I find end of "test" identifier, but this is silly. What is 
canonical way to do this?

docs/InternalsManual.html did not help me.



More information about the cfe-dev mailing list