Attr.h revision f78915fa196b3d284ad756f65eecadaefef71eef
1//===--- Attr.h - Classes for representing expressions ----------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//  This file defines the Attr interface and subclasses.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_ATTR_H
15#define LLVM_CLANG_AST_ATTR_H
16
17namespace clang {
18
19/// Attr - This represents one attribute.
20class Attr {
21public:
22  enum Kind {
23    Aligned,
24    Packed
25  };
26
27private:
28  Attr *Next;
29  Kind AttrKind;
30
31protected:
32  Attr(Kind AK) : Next(0), AttrKind(AK) {}
33  virtual ~Attr() {
34    delete Next;
35  }
36
37public:
38  Kind getKind() const { return AttrKind; }
39
40  Attr *getNext() { return Next; }
41  const Attr *getNext() const { return Next; }
42  void setNext(Attr *next) { Next = next; }
43
44  void addAttr(Attr *attr) {
45    assert((attr != 0) && "addAttr(): attr is null");
46
47    // FIXME: This doesn't preserve the order in any way.
48    attr->Next = Next;
49    Next = attr;
50  }
51
52  // Implement isa/cast/dyncast/etc.
53  static bool classof(const Attr *) { return true; }
54};
55
56class PackedAttr : public Attr {
57public:
58  PackedAttr() : Attr(Packed) {}
59
60  // Implement isa/cast/dyncast/etc.
61  static bool classof(const Attr *A) {
62    return A->getKind() == Packed;
63  }
64  static bool classof(const PackedAttr *A) { return true; }
65};
66
67}  // end namespace clang
68
69#endif
70