[cfe-commits] r47112 - in /cfe/trunk: clang.xcodeproj/project.pbxproj include/clang/AST/Attr.h

Anders Carlsson andersca at mac.com
Wed Feb 13 23:14:35 PST 2008


Author: andersca
Date: Thu Feb 14 01:14:34 2008
New Revision: 47112

URL: http://llvm.org/viewvc/llvm-project?rev=47112&view=rev
Log:
Add Attr.h which is an AST-level class for GCC attributes.

Added:
    cfe/trunk/include/clang/AST/Attr.h
Modified:
    cfe/trunk/clang.xcodeproj/project.pbxproj

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=47112&r1=47111&r2=47112&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Thu Feb 14 01:14:34 2008
@@ -226,6 +226,7 @@
 		1A68BC110D0CADDD001A28C8 /* PPCBuiltins.def */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = PPCBuiltins.def; path = clang/AST/PPCBuiltins.def; sourceTree = "<group>"; };
 		1A68BC120D0CADDD001A28C8 /* TargetBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TargetBuiltins.h; path = clang/AST/TargetBuiltins.h; sourceTree = "<group>"; };
 		1A68BC130D0CADDD001A28C8 /* X86Builtins.def */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = X86Builtins.def; path = clang/AST/X86Builtins.def; sourceTree = "<group>"; };
+		1A72BEAC0D641E9400B085E9 /* Attr.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = Attr.h; path = clang/AST/Attr.h; sourceTree = "<group>"; tabWidth = 2; };
 		1A7342470C7B57D500122F56 /* CGObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CGObjC.cpp; path = CodeGen/CGObjC.cpp; sourceTree = "<group>"; };
 		1A869A6E0BA2164C008DA07A /* LiteralSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiteralSupport.h; sourceTree = "<group>"; };
 		1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralSupport.cpp; sourceTree = "<group>"; };
@@ -627,6 +628,7 @@
 				DEC8D9A30A94346E00353FCA /* AST.h */,
 				35BFBD2B0C9EDE1E006CB644 /* ASTConsumer.h */,
 				DE75ED280B044DC90020CF81 /* ASTContext.h */,
+				1A72BEAC0D641E9400B085E9 /* Attr.h */,
 				DED676D00B6C786700AAD4A3 /* Builtins.def */,
 				DED676F90B6C797B00AAD4A3 /* Builtins.h */,
 				DEC63B1B0C7B940600DBF169 /* CFG.h */,

Added: cfe/trunk/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=47112&view=auto

==============================================================================
--- cfe/trunk/include/clang/AST/Attr.h (added)
+++ cfe/trunk/include/clang/AST/Attr.h Thu Feb 14 01:14:34 2008
@@ -0,0 +1,75 @@
+//===--- Attr.h - Classes for representing expressions ----------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//  This file defines the Attr interface and subclasses.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_EXPR_H
+#define LLVM_CLANG_AST_EXPR_H
+
+namespace clang {
+
+/// Attr - This represents one attribute.
+class Attr {
+public:
+  enum Kind {
+    AddressSpace,
+    Aligned,
+    OCUVectorType,
+    Packed,
+    VectorSize
+  };
+    
+private:
+  Attr *next;
+  
+  Kind AttrKind;
+  
+protected:
+  Attr(Kind AK) : AttrKind(AK) {}
+  virtual ~Attr() {
+    if (Next)
+      delete Next;
+  }
+  
+public:
+  Kind getKind() const { return AttrKind; }
+
+  Attr *getNext() const { return Next; }
+  void setNext(Attr *N) { Next = N; }
+  
+  void addAttr(Attr *attr) {
+    assert((attr != 0) && "addAttr(): attr is null");
+    Attr *next = this, *prev;
+    do {
+      prev = next;
+      next = next->getNext();
+    } while (next);
+    prev->setNext(attr);
+  }
+  
+  // Implement isa/cast/dyncast/etc.
+  static bool classof(const Attr *) { return true; }
+};
+
+class PackedAttr : public Attr {
+public:
+  PackedAttr() : Attr(Packed) {}
+  
+  // Implement isa/cast/dyncast/etc.
+  static bool classof(const Attr *A) {
+    return A->getKind() == Packed;
+  }
+  static bool classof(const PackedAttr *A) { return true; }
+};
+  
+}  // end namespace clang
+
+#endif





More information about the cfe-commits mailing list