<div dir="ltr">I don't know the specific way off-hand, but my usual approach to finding such APIs would be to run clang on a source file that produces a warning/error/diagnostic with the name you want - then running that under a debugger to see how it is getting that name</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 26, 2020 at 11:05 PM zxhuan via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hey guys,<div><br></div><div>I am new to clang and I am trying to get the specialized name of template classes and functions. For example, the std::map container is an STL class with template parameters. map<string, int> should be expanded as something similar to std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>. I have written a simple clang tool to get the function name and the class name of functions, here is a piece of code:</div><div><br></div><div>map<string, set<string>> func_set;<br><br>DeclarationMatcher methodMatcher = cxxMethodDecl().bind("methods");<br><br>class MethodPrinter : public MatchFinder::MatchCallback {<br>public :<br> virtual void run(const MatchFinder::MatchResult &Result) {<br> if (const CXXMethodDecl *md = Result.Nodes.getNodeAs<clang::CXXMethodDecl>("methods")) {<br> string f_name = md->getNameAsString();<br> string c_name = md->getParent()->getNameAsString();<br><br> if (auto tsd = dyn_cast<ClassTemplateSpecializationDecl>(md->getParent()))<br> c_name = tsd->getNameAsString();<br><br> func_set[c_name].insert(f_name);<br> }<br> }<br>};<br></div><div><br></div><div>This piece of code is getting me started, but not quite there. The getNameAsString() method just gives a very simple name, without the template parameters specialized. I am wondering if there is a way to do that.</div><div><br></div><div>Any help is appreciated!</div><div><br></div><div>Jason</div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>