From ff127787095cfdd50166cc26cbd0c17af6a7b81d Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Fri, 1 Jun 2007 21:53:25 +0000 Subject: [PATCH] Bug #: Submitted by: Reviewed by: Interface file for GCC attributes. llvm-svn: 39541 --- clang/include/clang/AST/Attr.h | 66 ++++++++++++++++++++++++++++++++++ clang/include/clang/AST/Decl.h | 39 +------------------- 2 files changed, 67 insertions(+), 38 deletions(-) create mode 100644 clang/include/clang/AST/Attr.h diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h new file mode 100644 index 000000000000..7ddb07ac8698 --- /dev/null +++ b/clang/include/clang/AST/Attr.h @@ -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 diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index e5f03476fd03..b4fbf1fad1d2 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -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