Submitted by:
Reviewed by:
Interface file for GCC attributes.

llvm-svn: 39541
This commit is contained in:
Steve Naroff 2007-06-01 21:53:25 +00:00
parent e47e440c42
commit ff12778709
2 changed files with 67 additions and 38 deletions

View File

@ -0,0 +1,66 @@
//===--- Attr.h -------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Steve Naroff and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the Attribute class interfaces
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_ATTR_H
#define LLVM_CLANG_AST_ATTR_H
#include "clang/Basic/SourceLocation.h"
#include "clang/AST/Type.h"
namespace llvm {
namespace clang {
class IdentifierInfo;
class Expr;
/// Attr - Represents GCC's __attribute__ declaration. There are
/// 4 forms of this construct...they are:
///
/// 1: __attribute__(( const )). ParmName/Args/NumArgs will all be unused.
/// 2: __attribute__(( mode(byte) )). ParmName used, Args/NumArgs unused.
/// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
/// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
///
class Attr {
IdentifierInfo *AttrName;
SourceLocation AttrLoc;
IdentifierInfo *ParmName;
Expr **Args;
unsigned NumArgs;
Attr *Next;
public:
Attr(SourceLocation L, IdentifierInfo *AttrName,
IdentifierInfo *ParmName, Expr **args, unsigned numargs);
~Attr() {
delete [] Args;
}
IdentifierInfo *getAttributeName() const { return AttrName; }
IdentifierInfo *getParameterName() const { return ParmName; }
Attr *getNext() const { return Next; }
void setNext(Attr *N) { Next = N; }
/// getNumArgs - Return the number of actual arguments to this attribute.
unsigned getNumArgs() const { return NumArgs; }
/// getArg - Return the specified argument.
Expr *getArg(unsigned Arg) const {
assert(Arg < NumArgs && "Arg access out of range!");
return Args[Arg];
}
};
} // end namespace clang
} // end namespace llvm
#endif

View File

@ -36,7 +36,7 @@ public:
// Concrete sub-classes of TypeDecl
Typedef, Struct, Union, Class, Enum,
// Concrete sub-class of Decl
Field, Attribute
Field
};
/// IdentifierNamespace - According to C99 6.2.3, there are four namespaces,
@ -405,43 +405,6 @@ public:
static bool classof(const RecordDecl *D) { return true; }
};
/// AttributeDecl - Represents GCC's __attribute__ declaration. There are
/// 4 forms of this construct...they are:
///
/// 1: __attribute__(( const )). ParmName/Args/NumArgs will all be unused.
/// 2: __attribute__(( mode(byte) )). ParmName used, Args/NumArgs unused.
/// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
/// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
///
class AttributeDecl : public Decl {
IdentifierInfo *ParmName;
Expr **Args;
unsigned NumArgs;
public:
AttributeDecl(SourceLocation L, IdentifierInfo *AttrName,
IdentifierInfo *ParmName, Expr **args, unsigned numargs);
~AttributeDecl() {
delete [] Args;
}
IdentifierInfo *getAttributeName() const { return getIdentifier(); }
IdentifierInfo *getParameterName() const { return ParmName; }
/// getNumArgs - Return the number of actual arguments to this attribute.
unsigned getNumArgs() const { return NumArgs; }
/// getArg - Return the specified argument.
Expr *getArg(unsigned Arg) const {
assert(Arg < NumArgs && "Arg access out of range!");
return Args[Arg];
}
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() == Attribute;
}
static bool classof(const AttributeDecl *D) { return true; }
};
} // end namespace clang
} // end namespace llvm