How to get the StringLiteral EndLocation of the last token

The EndLoc of StringLiteral is the Loc returned by getStrTokenLoc(getNumConcatenated()-1).

I understand that #6 concats the String tokens and the AST matcher gets the already concatenated string.

How do I know where the actual end (in the source file) is?

Example

Test:

#define testmacro L"testexpansion"

int main(int argc, char** argv) {

auto test=testmacro L"append";

}

In the Matcher:

llvm::dbgs()<<“Range:”<getBeginLoc().printToString(SM)<<“, “<getEndLoc().printToString(SM)<<”\n”;

for (unsigned i = 0; igetNumConcatenated();++i){

llvm::dbgs()<<“getStrTokenLoc “<<i<<”\n”;

pLiteral->getStrTokenLoc(i).dump(SM);

}

output:

Range:3:15 <Spelling=1:19>, :3:25

getStrTokenLoc 0

:3:15 <Spelling=:1:19>

// which is !testmacro L"append";

getStrTokenLoc 1

:3:25

// which is testmacro !L"append";

What I would need is this location: testmacro L"append"!; (34)

What can I do to get the “actual” end of the StringLiteral in the SourceFile. Is there some kind of callback “onStringConcat” or a supposed way for this?

Sorry, that was a quick one:

Lexer::getLocForEndOfToken (pLiteral->getStrTokenLoc (parts-1),0,SM,LO)

seems to work