[cfe-commits] r47193 - in /cfe/trunk/include/clang/AST: Attr.h Decl.h

Anders Carlsson andersca at mac.com
Fri Feb 15 15:57:38 PST 2008


Author: andersca
Date: Fri Feb 15 17:57:38 2008
New Revision: 47193

URL: http://llvm.org/viewvc/llvm-project?rev=47193&view=rev
Log:
Store attributes in a global hash map instead.

Modified:
    cfe/trunk/include/clang/AST/Attr.h
    cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=47193&r1=47192&r2=47193&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Fri Feb 15 17:57:38 2008
@@ -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.

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=47193&r1=47192&r2=47193&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Feb 15 17:57:38 2008
@@ -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 @@
 }
 
 namespace clang {
-class Attr;
 class Expr;
 class Stmt;
 class StringLiteral;
@@ -138,6 +138,14 @@
   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; }





More information about the cfe-commits mailing list