[llvm-dev] RecursiveASTVisitor won't visit all declarations (original) (raw)
Bekket McClane via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 5 10:24:13 PST 2019
- Previous message: [llvm-dev] RecursiveASTVisitor won't visit all declarations
- Next message: [llvm-dev] IRBuilder constraints
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I think it’s more suitable to ask this question on clang mailing list (cfe-dev)
B.R. Bekket
On Feb 5, 2019, at 12:29 AM, Teodor Dermendzhiev via llvm-dev <llvm-dev at lists.llvm.org> wrote:
Hi all, I am having problems walking through the syntax tree of a simple header file. With llvm 4.0.1 everything works as expected but after upgrading to 7.0.0 I notice that just a small number of all declarations in the AST are being visited. Running a simple ASTFrontendAction (like the one from this article - https://clang.llvm.org/docs/RAVFrontendAction.html <https://clang.llvm.org/docs/RAVFrontendAction.html> ) in HandleTranslationUnit() - virtual void HandleTranslationUnit(ASTContext &Context) { Decl* tu = Context.getTranslationUnitDecl(); Visitor.TraverseDecl(tu); } when I dump the tu variable I get a lot smaller dump with 7.0.0. After investigating further I updated TraverseDeclContextHelper() method in order to print the size of decls() container for every DeclContext we visit: template bool RecursiveASTVisitor::TraverseDeclContextHelper(DeclContext *DC) { if (!DC) return true; int childSize = 0; // my code for (auto *Child : DC->decls()) { childSize++; // my code if (!canIgnoreChildDeclWhileTraversingDeclContext(Child)) TRYTO(TraverseDecl(Child)); } std::cout << DC->getDeclKindName() << ": " << childSize << " child declarations" << "\n"; //my code_ _return true;_ _}_ _With llvm 4.0.0 I get:_ _TranslationUnit: 20526 child declarations_ _while with 7.0.0:_ _TranslationUnit: 486 child declarations_ _I created a sample project that illustrates this behavior - https://github.com/tdermendjiev/clang-samples <https://github.com/tdermendjiev/clang-samples> . Any help tackling this issue is appreciated. Thank you. Best wishes, Teodor Dermendzhiev
LLVM Developers mailing list llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190205/4f6a73e3/attachment.html>
- Previous message: [llvm-dev] RecursiveASTVisitor won't visit all declarations
- Next message: [llvm-dev] IRBuilder constraints
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]