<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="font-size:0.75em;">The EndLoc of StringLiteral is the Loc returned by getStrTokenLoc(getNumConcatenated()-1). </span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I understand that #6 concats the String tokens and the AST matcher gets the already concatenated string.</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">How do I know where the actual end (in the source file) is?</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Example</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Test:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">#define testmacro L"testexpansion"</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">int main(int argc, char** argv) {</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">auto test=testmacro L"append";</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">}</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">​</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">In the Matcher:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">  llvm::dbgs()<<"Range:"<<pLiteral->getBeginLoc().printToString(SM)<<", "<<pLiteral->getEndLoc().printToString(SM)<<"\n";</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">  for (unsigned i = 0; i<pLiteral->getNumConcatenated();++i){</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">    llvm::dbgs()<<"getStrTokenLoc "<<i<<"\n";</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">    pLiteral->getStrTokenLoc(i).dump(SM);</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">  }</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">output:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Range:3:15 <Spelling=1:19>, :3:25</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">getStrTokenLoc 0</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">:3:15 <Spelling=:1:19></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">// which is !testmacro L"append";</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">getStrTokenLoc 1</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">:3:25</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">// which is testmacro !L"append";</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">What I would need is this location:  testmacro L"append"!; (34)</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">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?</p>
</body>
</html>