<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;">Sorry, that was a quick one:</span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"> Lexer::getLocForEndOfToken (pLiteral->getStrTokenLoc (parts-1),0,SM,LO) </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">seems to work</p>
<br /><br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">On Mittwoch, 1. September 2021 17:26:40 CEST chiasa.men via cfe-dev wrote:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> The EndLoc of StringLiteral is the Loc returned by</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> getStrTokenLoc(getNumConcatenated()-1).</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</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> already concatenated string.</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;">> How do I know where the actual end (in the source file) is?</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;">> Example</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;">> 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)<<",</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> "<<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>
<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;">> 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;">> </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;">> </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;">> </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;">> </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;">> </p>
<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>
<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;">> What can I do to get the "actual" end of the StringLiteral in the</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> SourceFile. Is there some kind of callback "onStringConcat" or a supposed</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> way for this?</p>
<br /><br /></body>
</html>