<div>Thanks a lot, this works for me:</div><div> </div><div>...</div><div>#include "clang/Tooling/FixIt.h"</div><div>...</div><div>//in AST MatchCallback:</div><div>const CompoundStmt *FS = Result.Nodes.getNodeAs<clang::CompoundStmt>("node_cmpnd");</div><div>ASTContext *Context = Result.Context;</div><div>StringRef text = clang::tooling::fixit::getText<CompoundStmt>(*FS, *Context);</div><div>llvm::outs() << text;</div><div><br /></div><div><br /></div><div>10.06.2020, 14:07, "Nathan James via cfe-dev" <cfe-dev@lists.llvm.org>:</div><blockquote><div style="direction:ltr;text-align:left"><div>Hi,</div><div><br /></div><div>Have you tried using:</div><div>`clang::tooling::fixit::getText(const T &Node, const ASTContext &);`</div><div>Internally that uses</div><div>`clang::Lexer::getSourceText(CharSourceRange, const SourceManager &, const LangOptions &, bool *Invalid);`</div><div><br /></div><div>Hope this helps,</div><div>Nathan</div><div><br /></div><div>On Tue, <span class="1f1ea193f6735cf0wmi-callto">2020-06-09</span> at 09:31 +0300, samins KAlex via cfe-dev wrote:</div><blockquote style="border-left-color:#729fcf;border-left-style:solid;border-left-width:2px;margin:0 0 0 0.8ex;padding-left:1ex"><div>Good day!</div><div>How can I retreive matched node text to some variable, not dump?</div><div>I have</div><div>MatchResult &R;</div><div>ASTContext *C;</div><div>SourceManager &SM;</div><div> </div><div>I don't want to get location and re-read source file. Is there other way?</div><div> </div>
<pre>_______________________________________________</pre><pre>cfe-dev mailing list</pre><pre><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a></pre><pre><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a></pre><pre><br /></pre></blockquote></div>
,<p>_______________________________________________<br />cfe-dev mailing list<br /><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br /><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br /></p></blockquote>