summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeLesley Hutchins <delesley@google.com>2013-12-30 21:03:02 +0000
committerDeLesley Hutchins <delesley@google.com>2013-12-30 21:03:02 +0000
commitbb79c338edc0abd2260ba7fdcb2d60ab16e473e4 (patch)
tree7282f66edfaab4b69976b51e642ea1ff25c92b91
parent00b9b695c44f599dade1c0fe6d70c9e1e604fdd7 (diff)
downloadbcm5719-llvm-bb79c338edc0abd2260ba7fdcb2d60ab16e473e4.tar.gz
bcm5719-llvm-bb79c338edc0abd2260ba7fdcb2d60ab16e473e4.zip
Update DataRecursiveASTVisitor so that it visits attributes.
llvm-svn: 198249
-rw-r--r--clang/include/clang/AST/DataRecursiveASTVisitor.h37
-rw-r--r--clang/include/clang/AST/RecursiveASTVisitor.h2
-rw-r--r--clang/utils/TableGen/ClangAttrEmitter.cpp4
3 files changed, 38 insertions, 5 deletions
diff --git a/clang/include/clang/AST/DataRecursiveASTVisitor.h b/clang/include/clang/AST/DataRecursiveASTVisitor.h
index 3f4df50c545..229989f1194 100644
--- a/clang/include/clang/AST/DataRecursiveASTVisitor.h
+++ b/clang/include/clang/AST/DataRecursiveASTVisitor.h
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_AST_DATARECURSIVEASTVISITOR_H
#define LLVM_CLANG_AST_DATARECURSIVEASTVISITOR_H
+#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclFriend.h"
@@ -174,6 +175,13 @@ public:
/// otherwise (including when the argument is a Null type location).
bool TraverseTypeLoc(TypeLoc TL);
+ /// \brief Recursively visit an attribute, by dispatching to
+ /// Traverse*Attr() based on the argument's dynamic type.
+ ///
+ /// \returns false if the visitation was terminated early, true
+ /// otherwise (including when the argument is a Null type location).
+ bool TraverseAttr(Attr *At);
+
/// \brief Recursively visit a declaration, by dispatching to
/// Traverse*Decl() based on the argument's dynamic type.
///
@@ -237,7 +245,17 @@ public:
///
/// \returns false if the visitation was terminated early, true otherwise.
bool TraverseLambdaCapture(LambdaExpr::Capture C);
-
+
+ // ---- Methods on Attrs ----
+
+ // \brief Visit an attribute.
+ bool VisitAttr(Attr *A) { return true; }
+
+ // Declare Traverse* and empty Visit* for all Attr classes.
+#define ATTR_VISITOR_DECLS_ONLY
+#include "clang/AST/AttrVisitor.inc"
+#undef ATTR_VISITOR_DECLS_ONLY
+
// ---- Methods on Stmts ----
// Declare Traverse*() for all concrete Stmt classes.
@@ -552,6 +570,11 @@ bool DataRecursiveASTVisitor<Derived>::TraverseTypeLoc(TypeLoc TL) {
}
+// Define the Traverse*Attr(Attr* A) methods
+#define VISITORCLASS DataRecursiveASTVisitor
+#include "clang/AST/AttrVisitor.inc"
+#undef VISITORCLASS
+
template<typename Derived>
bool DataRecursiveASTVisitor<Derived>::TraverseDecl(Decl *D) {
if (!D)
@@ -566,10 +589,18 @@ bool DataRecursiveASTVisitor<Derived>::TraverseDecl(Decl *D) {
switch (D->getKind()) {
#define ABSTRACT_DECL(DECL)
#define DECL(CLASS, BASE) \
- case Decl::CLASS: DISPATCH(CLASS##Decl, CLASS##Decl, D);
+ case Decl::CLASS: \
+ if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl*>(D))) \
+ return false; \
+ break;
#include "clang/AST/DeclNodes.inc"
- }
+ }
+ // Visit any attributes attached to this declaration.
+ for (Decl::attr_iterator I=D->attr_begin(), E=D->attr_end(); I != E; ++I) {
+ if (!getDerived().TraverseAttr(*I))
+ return false;
+ }
return true;
}
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index aa15f9fc534..1ccb58ca78a 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -642,7 +642,9 @@ bool RecursiveASTVisitor<Derived>::TraverseTypeLoc(TypeLoc TL) {
// Define the Traverse*Attr(Attr* A) methods
+#define VISITORCLASS RecursiveASTVisitor
#include "clang/AST/AttrVisitor.inc"
+#undef VISITORCLASS
template<typename Derived>
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index be4ae62578e..7d45d4beebb 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1620,7 +1620,7 @@ void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) {
continue;
OS << "template <typename Derived>\n"
- << "bool RecursiveASTVisitor<Derived>::Traverse"
+ << "bool VISITORCLASS<Derived>::Traverse"
<< R.getName() << "Attr(" << R.getName() << "Attr *A) {\n"
<< " if (!getDerived().VisitAttr(A))\n"
<< " return false;\n"
@@ -1643,7 +1643,7 @@ void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) {
// Write generic Traverse routine
OS << "template <typename Derived>\n"
- << "bool RecursiveASTVisitor<Derived>::TraverseAttr(Attr *A) {\n"
+ << "bool VISITORCLASS<Derived>::TraverseAttr(Attr *A) {\n"
<< " if (!A)\n"
<< " return true;\n"
<< "\n"
OpenPOWER on IntegriCloud