]> granicus.if.org Git - clang/blob - include/clang/Parse/AttributeList.h
rename some methods.
[clang] / include / clang / Parse / AttributeList.h
1 //===--- AttributeList.h ----------------------------------------*- 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 AttributeList class interface.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_ATTRLIST_H
15 #define LLVM_CLANG_ATTRLIST_H
16
17 #include "clang/Parse/Action.h"
18 #include <cassert>
19
20 namespace clang {
21   
22 /// AttributeList - Represents GCC's __attribute__ declaration. There are
23 /// 4 forms of this construct...they are:
24 ///
25 /// 1: __attribute__(( const )). ParmName/Args/NumArgs will all be unused.
26 /// 2: __attribute__(( mode(byte) )). ParmName used, Args/NumArgs unused.
27 /// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
28 /// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
29 ///
30 class AttributeList {
31   IdentifierInfo *AttrName;
32   SourceLocation AttrLoc;
33   IdentifierInfo *ParmName;
34   SourceLocation ParmLoc;
35   Action::ExprTy **Args;
36   unsigned NumArgs;
37   AttributeList *Next;
38 public:
39   AttributeList(IdentifierInfo *AttrName, SourceLocation AttrLoc,
40                 IdentifierInfo *ParmName, SourceLocation ParmLoc,
41                 Action::ExprTy **args, unsigned numargs, AttributeList *Next);
42   ~AttributeList();
43   
44   enum Kind {
45     UnknownAttribute,
46     AT_vector_size,
47     AT_ocu_vector_type,
48     AT_address_space,
49     AT_aligned,
50     AT_packed
51   };
52   
53   IdentifierInfo *getName() const { return AttrName; }
54   SourceLocation getLoc() const { return AttrLoc; }
55   IdentifierInfo *getParameterName() const { return ParmName; }
56   
57   Kind getKind() const { return getKind(getName()); }
58   static Kind getKind(const IdentifierInfo *Name);
59   
60   AttributeList *getNext() const { return Next; }
61   void setNext(AttributeList *N) { Next = N; }
62   
63   void addAttributeList(AttributeList *alist) {
64     assert((alist != 0) && "addAttributeList(): alist is null");
65     AttributeList *next = this, *prev;
66     do {
67       prev = next;
68       next = next->getNext();
69     } while (next);
70     prev->setNext(alist);
71   }
72
73   /// getNumArgs - Return the number of actual arguments to this attribute.
74   unsigned getNumArgs() const { return NumArgs; }
75   
76   /// getArg - Return the specified argument.
77   Action::ExprTy *getArg(unsigned Arg) const {
78     assert(Arg < NumArgs && "Arg access out of range!");
79     return Args[Arg];
80   }
81 };
82
83 }  // end namespace clang
84
85 #endif