1 //===--- Attr.h - Classes for representing expressions ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the Attr interface and subclasses.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_AST_ATTR_H
15 #define LLVM_CLANG_AST_ATTR_H
22 /// Attr - This represents one attribute.
38 Attr(Kind AK) : Next(0), AttrKind(AK) {}
44 Kind getKind() const { return AttrKind; }
46 Attr *getNext() { return Next; }
47 const Attr *getNext() const { return Next; }
48 void setNext(Attr *next) { Next = next; }
50 void addAttr(Attr *attr) {
51 assert((attr != 0) && "addAttr(): attr is null");
53 // FIXME: This doesn't preserve the order in any way.
58 // Implement isa/cast/dyncast/etc.
59 static bool classof(const Attr *) { return true; }
62 class PackedAttr : public Attr {
64 PackedAttr() : Attr(Packed) {}
66 // Implement isa/cast/dyncast/etc.
67 static bool classof(const Attr *A) {
68 return A->getKind() == Packed;
70 static bool classof(const PackedAttr *A) { return true; }
73 class AlignedAttr : public Attr {
76 AlignedAttr(unsigned alignment) : Attr(Aligned), Alignment(alignment) {}
78 unsigned getAlignment() const { return Alignment; }
80 // Implement isa/cast/dyncast/etc.
81 static bool classof(const Attr *A) {
82 return A->getKind() == Aligned;
84 static bool classof(const AlignedAttr *A) { return true; }
87 class AnnotateAttr : public Attr {
88 std::string Annotation;
90 AnnotateAttr(const std::string &ann) : Attr(Annotate), Annotation(ann) {}
92 const std::string& getAnnotation() const { return Annotation; }
94 // Implement isa/cast/dyncast/etc.
95 static bool classof(const Attr *A) {
96 return A->getKind() == Annotate;
98 static bool classof(const AnnotateAttr *A) { return true; }
101 class NoReturnAttr : public Attr {
103 NoReturnAttr() : Attr(NoReturn) {}
105 // Implement isa/cast/dyncast/etc.
107 static bool classof(const Attr *A) { return A->getKind() == NoReturn; }
108 static bool classof(const NoReturnAttr *A) { return true; }
111 class DeprecatedAttr : public Attr {
113 DeprecatedAttr() : Attr(Deprecated) {}
115 // Implement isa/cast/dyncast/etc.
117 static bool classof(const Attr *A) { return A->getKind() == Deprecated; }
118 static bool classof(const DeprecatedAttr *A) { return true; }
121 } // end namespace clang