From adf21bdb3d17acfdb74657fcbc5035a404c6c8f4 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 15 Feb 2008 23:57:38 +0000 Subject: [PATCH] Store attributes in a global hash map instead. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47193 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Attr.h | 2 ++ include/clang/AST/Decl.h | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 82da65a89b..ae2c25b11b 100644 --- a/include/clang/AST/Attr.h +++ b/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/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 32127bb3a9..0fbf0f9285 100644 --- a/include/clang/AST/Decl.h +++ b/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; } -- 2.50.1