[cfe-dev] unable to traverse FunctionTemplateDecl (right name?) with either RecursiveASTVisitor or Matcher

John P. Feltz jfeltz at gmail.com
Mon Dec 1 20:06:23 PST 2014


No change:

visiting func decl: f
visiting func decl: g
visiting func decl: main

Also with:
ci->getDiagnostics().setSuppressAllDiagnostics(false);

file.cc:1:10: fatal error: 'iostream' file not found
#include <iostream>
visiting func decl: f
visiting func decl: g
visiting func decl: main

also h() shows up for #include <iostream_adsf> in both:
$ clang-query file.cc --
clang-query> m functionTemplateDecl()

and,
$ clang -Xclang -ast-dump -fsyntax-only file.cc

On 12/01/2014 04:01 PM, Nikola Smiljanic wrote:
> What happens if you add a call to template function inside main?
>
> h(1);
>
> On Tue, Dec 2, 2014 at 8:11 AM, John P. Feltz <jfeltz at gmail.com 
> <mailto:jfeltz at gmail.com>> wrote:
>
>     Did you look at my failing test-case that I attached earlier?
>     Specifically:
>
>     ...
>     class Vis : public RecursiveASTVisitor<Vis> {
>     public:
>       Vis(SourceManager& sm_) : sm(sm_) {}
>
>       bool VisitFunctionTemplateDecl(FunctionTemplateDecl *tf) {
>         std::cout << "visiting template func decl" << std::endl;
>         return true;
>       }
>       bool VisitFunctionDecl(FunctionDecl *f) {
>         std::cout << "visiting func decl: " <<
>     f->getNameInfo().getAsString() << std::endl;
>         return true;
>       }
>
>       SourceManager& sm;
>     };
>     ...
>
>     Neither functions find h().
>
>
>     On 11/29/2014 08:40 PM, James Dennett wrote:
>>     On Sat, Nov 29, 2014 at 2:48 PM, John P. Feltz <jfeltz at gmail.com
>>     <mailto:jfeltz at gmail.com>> wrote:
>>
>>         Hi,
>>
>>         I can't seem to traverse the following with either a
>>         RecursiveASTVisitor or a AST Matcher converted to an ASTConsumer:
>>
>>         template<typename T> void h(T x) { .. }
>>
>>         First some things I'd like to note:
>>         1) $ llvm-config --version
>>         3.5.0
>>
>>         2) 'clang' actually does find the template function, so I
>>         suspect I'm doing something wrong in either the visitor and
>>         matcher, or in the compiler setup:
>>         $ clang -Xclang -ast-dump -fsyntax-only file.cc
>>         ..
>>         FunctionTemplateDecl 0x23e5330 <line:13:1, line:15:1>
>>         line:13:27 h
>>         ..
>>
>>         3) I am not a C++ expert, and I am a libtooling newbie.
>>
>>         I've attached the parsed subject (file.cc) and the code I'm
>>         using to build and run the test-case.
>>
>>
>>     You might try visiting the FunctionDecl and then calling
>>     getDescribedFunctionTemplate
>>     <https://cs.corp.google.com/#piper///depot/google3/third_party/llvm/llvm/tools/clang/include/clang/AST/Decl.h&ct=xref_jump_to_def&cl=GROK&l=2013&gsn=getDescribedFunctionTemplate> on
>>     it to get the associated FunctionTemplateDecl.
>>
>>     -- James
>>
>
>
>     _______________________________________________
>     cfe-dev mailing list
>     cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
>     http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141201/60e44d61/attachment.html>


More information about the cfe-dev mailing list