1 //===--- AttributeList.cpp --------------------------------------*- 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 AttributeList class implementation
12 //===----------------------------------------------------------------------===//
14 #include "clang/Parse/AttributeList.h"
15 using namespace clang;
17 AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
18 IdentifierInfo *pName, SourceLocation pLoc,
19 Action::ExprTy **elist, unsigned numargs,
21 : AttrName(aName), AttrLoc(aLoc), ParmName(pName), ParmLoc(pLoc),
22 NumArgs(numargs), Next(n) {
23 Args = new Action::ExprTy*[numargs];
24 for (unsigned i = 0; i != numargs; ++i)
28 AttributeList::~AttributeList() {
30 // FIXME: before we delete the vector, we need to make sure the Expr's
31 // have been deleted. Since Action::ExprTy is "void", we are dependent
32 // on the actions module for actually freeing the memory. The specific
33 // hooks are ActOnDeclarator, ActOnTypeName, ActOnParamDeclaratorType,
34 // ParseField, ParseTag. Once these routines have freed the expression,
35 // they should zero out the Args slot (to indicate the memory has been
36 // freed). If any element of the vector is non-null, we should assert.
42 AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
43 const char *Str = Name->getName();
44 unsigned Len = Name->getLength();
46 // Normalize the attribute name, __foo__ becomes foo.
47 if (Len > 4 && Str[0] == '_' && Str[1] == '_' &&
48 Str[Len - 2] == '_' && Str[Len - 1] == '_') {
55 if (!memcmp(Str, "packed", 6)) return AT_packed;
58 if (!memcmp(Str, "aligned", 7)) return AT_aligned;
61 if (!memcmp(Str, "annotate", 8)) return AT_annotate;
62 if (!memcmp(Str, "noreturn", 8)) return AT_noreturn;
65 if (!memcmp(Str, "deprecated", 10)) return AT_deprecated;
68 if (!memcmp(Str, "vector_size", 11)) return AT_vector_size;
71 if (!memcmp(Str, "address_space", 13)) return AT_address_space;
74 if (!memcmp(Str, "ocu_vector_type", 15)) return AT_ocu_vector_type;
77 return UnknownAttribute;