]> granicus.if.org Git - clang/commitdiff
Store attributes in a global hash map instead.
authorAnders Carlsson <andersca@mac.com>
Fri, 15 Feb 2008 23:57:38 +0000 (23:57 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 15 Feb 2008 23:57:38 +0000 (23:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47193 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Attr.h
include/clang/AST/Decl.h

index 82da65a89bdc83201b2a42386626437d2a90ee7d..ae2c25b11b8f97bb7c399cd2c7881616bdce918d 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef LLVM_CLANG_AST_ATTR_H
 #define LLVM_CLANG_AST_ATTR_H
 
+#include <assert.h>
+
 namespace clang {
 
 /// Attr - This represents one attribute.
index 32127bb3a9ab62d872a2b0618e57e60682c205f2..0fbf0f92855f6227b8d472189e0ecff710622ed9 100644 (file)
@@ -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<typename T> T *getAttr() {
+    for (Attr *attr = getAttrs(); attr; attr = attr->getNext())
+      if (isa<T>(attr))
+        return cast<T>(attr);
+
+    return 0;
+  }
+    
   /// setInvalidDecl - Indicates the Decl had a semantic error. This
   /// allows for graceful error recovery.
   void setInvalidDecl() { InvalidDecl = 1; }