diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2019-08-06 15:46:12 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2019-08-06 15:46:12 +0000 |
commit | 888cb09800dc23e1090f968b94184260c7f88308 (patch) | |
tree | ae1bc8b78bf3c2c5cc52d1bcb27f67783dffa8ab /include | |
parent | 66528e8d1fc0ae58660f3d736b23339fc78c2f99 (diff) | |
download | clang-888cb09800dc23e1090f968b94184260c7f88308.tar.gz |
[AST] Traverse attributes inside DEF_TRAVERSE_DECL macro
Summary:
Instead of traversing inside the TraverseDecl() function.
Previously the attributes were traversed after Travese(Some)Decl
returns.
Logically attributes are properties of particular Decls and should be
traversed alongside other "child" nodes.
None of the tests relied on this behavior, hopefully this is an indication
that the change is relatively safe.
This change started with a discussion on cfe-dev, for details see:
https://lists.llvm.org/pipermail/cfe-dev/2019-July/062899.html
Reviewers: rsmith, gribozavr
Reviewed By: gribozavr
Subscribers: mgorny, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64907
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/RecursiveASTVisitor.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index eb047bd5c5..918e5b084d 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -722,12 +722,6 @@ bool RecursiveASTVisitor<Derived>::TraverseDecl(Decl *D) { break; #include "clang/AST/DeclNodes.inc" } - - // Visit any attributes attached to this declaration. - for (auto *I : D->attrs()) { - if (!getDerived().TraverseAttr(I)) - return false; - } return true; } @@ -1407,6 +1401,11 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC) { { CODE; } \ if (ReturnValue && ShouldVisitChildren) \ TRY_TO(TraverseDeclContextHelper(dyn_cast<DeclContext>(D))); \ + if (ReturnValue) { \ + /* Visit any attributes attached to this declaration. */ \ + for (auto *I : D->attrs()) \ + TRY_TO(getDerived().TraverseAttr(I)); \ + } \ if (ReturnValue && getDerived().shouldTraversePostOrder()) \ TRY_TO(WalkUpFrom##DECL(D)); \ return ReturnValue; \ |