diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h index 82da65a89bdc..ae2c25b11b8f 100644 --- a/clang/include/clang/AST/Attr.h +++ b/clang/include/clang/AST/Attr.h @@ -14,6 +14,8 @@ #ifndef LLVM_CLANG_AST_ATTR_H #define LLVM_CLANG_AST_ATTR_H +#include + namespace clang { /// Attr - This represents one attribute. diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 32127bb3a9ab..0fbf0f92855f 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_DECL_H #define LLVM_CLANG_AST_DECL_H +#include "clang/AST/Attr.h" #include "clang/AST/Type.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/APSInt.h" @@ -24,7 +25,6 @@ class Decl; } namespace clang { -class Attr; class Expr; class Stmt; class StringLiteral; @@ -138,6 +138,14 @@ public: void addAttr(Attr *attr); const Attr *getAttrs() const; + template T *getAttr() { + for (Attr *attr = getAttrs(); attr; attr = attr->getNext()) + if (isa(attr)) + return cast(attr); + + return 0; + } + /// setInvalidDecl - Indicates the Decl had a semantic error. This /// allows for graceful error recovery. void setInvalidDecl() { InvalidDecl = 1; }