#ifndef LLVM_CLANG_AST_DECL_H
#define LLVM_CLANG_AST_DECL_H
-#include "clang/Basic/SourceLocation.h"
#include "clang/AST/Type.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Parse/AttributeList.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/Bitcode/SerializationFwd.h"
class Expr;
class Stmt;
class FunctionDecl;
-class AttributeList;
class IdentifierInfo;
/// Decl - This represents one declaration (or definition), e.g. a variable,
/// an enum constant.
class ValueDecl : public ScopedDecl {
QualType DeclType;
+
+ /// Attributes - Linked list of attributes that are attached to this
+ /// function.
+ AttributeList *Attributes;
protected:
ValueDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T,
- ScopedDecl *PrevDecl) : ScopedDecl(DK, L, Id, PrevDecl), DeclType(T) {}
+ ScopedDecl *PrevDecl, AttributeList *A = 0)
+ : ScopedDecl(DK, L, Id, PrevDecl), DeclType(T), Attributes(A) {}
public:
QualType getType() const { return DeclType; }
void setType(QualType newType) { DeclType = newType; }
QualType getCanonicalType() const { return DeclType.getCanonicalType(); }
+ AttributeList *getAttributes() const { return Attributes; }
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() >= ValueFirst && D->getKind() <= ValueLast;
static bool classof(const VarDecl *D) { return true; }
protected:
VarDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T,
- StorageClass SC, ScopedDecl *PrevDecl)
- : ValueDecl(DK, L, Id, T, PrevDecl), Init(0),
+ StorageClass SC, ScopedDecl *PrevDecl, AttributeList *A = 0)
+ : ValueDecl(DK, L, Id, T, PrevDecl, A), Init(0),
objcDeclQualifier(OBJC_TQ_None) { SClass = SC; }
private:
Expr *Init;
class BlockVarDecl : public VarDecl {
public:
BlockVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S,
- ScopedDecl *PrevDecl)
- : VarDecl(BlockVar, L, Id, T, S, PrevDecl) {}
+ ScopedDecl *PrevDecl, AttributeList *A = 0)
+ : VarDecl(BlockVar, L, Id, T, S, PrevDecl, A) {}
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == BlockVar; }
class FileVarDecl : public VarDecl {
public:
FileVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S,
- ScopedDecl *PrevDecl)
- : VarDecl(FileVar, L, Id, T, S, PrevDecl) {}
+ ScopedDecl *PrevDecl, AttributeList *A = 0)
+ : VarDecl(FileVar, L, Id, T, S, PrevDecl, A) {}
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == FileVar; }
class ParmVarDecl : public VarDecl {
public:
ParmVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S,
- ScopedDecl *PrevDecl)
- : VarDecl(ParmVar, L, Id, T, S, PrevDecl) {}
+ ScopedDecl *PrevDecl, AttributeList *A = 0)
+ : VarDecl(ParmVar, L, Id, T, S, PrevDecl, A) {}
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == ParmVar; }
};
FunctionDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
StorageClass S = None, bool isInline = false,
- ScopedDecl *PrevDecl = 0)
- : ValueDecl(Function, L, Id, T, PrevDecl),
+ ScopedDecl *PrevDecl = 0, AttributeList *Attrs = 0)
+ : ValueDecl(Function, L, Id, T, PrevDecl, Attrs),
ParamInfo(0), Body(0), DeclChain(0), SClass(S), IsInline(isInline) {}
virtual ~FunctionDecl();
AttrList = alist;
}
AttributeList *getAttributes() const { return AttrList; }
+ void clearAttributes() { AttrList = 0; }
llvm::SmallVector<Action::DeclTy *, 8> *getProtocolQualifiers() const {
return ProtocolQualifiers;
SourceLocation IdentLoc;
Action::TypeTy *TypeInfo;
bool InvalidType;
- // FIXME: this also needs an attribute list.
+ AttributeList *AttrList;
ParamInfo() {}
ParamInfo(IdentifierInfo *ident, SourceLocation iloc, Action::TypeTy *typ,
- bool flag = false)
- : Ident(ident), IdentLoc(iloc), TypeInfo(typ), InvalidType(flag) {
- }
+ bool flag = false, AttributeList *AL = 0)
+ : Ident(ident), IdentLoc(iloc), TypeInfo(typ), InvalidType(flag),
+ AttrList(AL) {}
};
struct FunctionTypeInfo {
/// Instances of this class should be a transient object that lives on the
/// stack, not objects that are allocated in large quantities on the heap.
class Declarator {
- const DeclSpec &DS;
+ DeclSpec &DS;
IdentifierInfo *Identifier;
SourceLocation IdentifierLoc;
// attributes.
AttributeList *AttrList;
public:
- Declarator(const DeclSpec &ds, TheContext C)
+ Declarator(DeclSpec &ds, TheContext C)
: DS(ds), Identifier(0), Context(C), InvalidType(false), AttrList(0) {
}
/// getDeclSpec - Return the declaration-specifier that this declarator was
/// declared with.
- const DeclSpec &getDeclSpec() const { return DS; }
+ DeclSpec &getDeclSpec() const { return DS; }
TheContext getContext() const { return Context; }