Add Attr.h which is an AST-level class for GCC attributes.

llvm-svn: 47112
This commit is contained in:
Anders Carlsson 2008-02-14 07:14:34 +00:00
parent 7c77e2bc65
commit b853a1a049
2 changed files with 77 additions and 0 deletions

View File

@ -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 */,

View File

@ -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