From: Anders Carlsson Date: Thu, 14 Feb 2008 07:14:34 +0000 (+0000) Subject: Add Attr.h which is an AST-level class for GCC attributes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d429cd459aef723fa0e7a44ac957d4c2256e241c;p=clang Add Attr.h which is an AST-level class for GCC attributes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47112 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index a6bff1111d..dcbf2289f5 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -226,6 +226,7 @@ 1A68BC110D0CADDD001A28C8 /* PPCBuiltins.def */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = PPCBuiltins.def; path = clang/AST/PPCBuiltins.def; sourceTree = ""; }; 1A68BC120D0CADDD001A28C8 /* TargetBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TargetBuiltins.h; path = clang/AST/TargetBuiltins.h; sourceTree = ""; }; 1A68BC130D0CADDD001A28C8 /* X86Builtins.def */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = X86Builtins.def; path = clang/AST/X86Builtins.def; sourceTree = ""; }; + 1A72BEAC0D641E9400B085E9 /* Attr.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = Attr.h; path = clang/AST/Attr.h; sourceTree = ""; tabWidth = 2; }; 1A7342470C7B57D500122F56 /* CGObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CGObjC.cpp; path = CodeGen/CGObjC.cpp; sourceTree = ""; }; 1A869A6E0BA2164C008DA07A /* LiteralSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiteralSupport.h; sourceTree = ""; }; 1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralSupport.cpp; sourceTree = ""; }; @@ -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 */, diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h new file mode 100644 index 0000000000..39de4faac9 --- /dev/null +++ b/include/clang/AST/Attr.h @@ -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