]> granicus.if.org Git - clang/commitdiff
Add Attr.h which is an AST-level class for GCC attributes.
authorAnders Carlsson <andersca@mac.com>
Thu, 14 Feb 2008 07:14:34 +0000 (07:14 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 14 Feb 2008 07:14:34 +0000 (07:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47112 91177308-0d34-0410-b5e6-96231b3b80d8

clang.xcodeproj/project.pbxproj
include/clang/AST/Attr.h [new file with mode: 0644]

index a6bff1111d0e37f43e0d7e0be65548ee34d9b53e..dcbf2289f594eab07f3134d2ff930b39992322eb 100644 (file)
                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>"; };
                                DEC8D9A30A94346E00353FCA /* AST.h */,
                                35BFBD2B0C9EDE1E006CB644 /* ASTConsumer.h */,
                                DE75ED280B044DC90020CF81 /* ASTContext.h */,
+                               1A72BEAC0D641E9400B085E9 /* Attr.h */,
                                DED676D00B6C786700AAD4A3 /* Builtins.def */,
                                DED676F90B6C797B00AAD4A3 /* Builtins.h */,
                                DEC63B1B0C7B940600DBF169 /* CFG.h */,
diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h
new file mode 100644 (file)
index 0000000..39de4fa
--- /dev/null
@@ -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