зеркало из https://github.com/microsoft/clang-1.git
Get rid of AttributeList in the AST and use the new Attr class instead
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
f963339f63
Коммит
f78915fa19
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "clang/AST/Decl.h"
|
#include "clang/AST/Decl.h"
|
||||||
#include "clang/AST/DeclObjC.h"
|
#include "clang/AST/DeclObjC.h"
|
||||||
|
#include "clang/AST/Attr.h"
|
||||||
#include "clang/Basic/IdentifierTable.h"
|
#include "clang/Basic/IdentifierTable.h"
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
|
@ -258,6 +259,11 @@ const char *NamedDecl::getName() const {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ValueDecl::addAttr(Attr *attr)
|
||||||
|
{
|
||||||
|
attr->setNext(Attrs);
|
||||||
|
Attrs = attr;
|
||||||
|
}
|
||||||
|
|
||||||
FunctionDecl::~FunctionDecl() {
|
FunctionDecl::~FunctionDecl() {
|
||||||
delete[] ParamInfo;
|
delete[] ParamInfo;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "Sema.h"
|
#include "Sema.h"
|
||||||
#include "clang/AST/ASTConsumer.h"
|
#include "clang/AST/ASTConsumer.h"
|
||||||
#include "clang/AST/ASTContext.h"
|
#include "clang/AST/ASTContext.h"
|
||||||
|
#include "clang/AST/Attr.h"
|
||||||
#include "clang/AST/Builtins.h"
|
#include "clang/AST/Builtins.h"
|
||||||
#include "clang/AST/Decl.h"
|
#include "clang/AST/Decl.h"
|
||||||
#include "clang/AST/Expr.h"
|
#include "clang/AST/Expr.h"
|
||||||
|
@ -737,10 +738,8 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
|
||||||
|
|
||||||
FunctionDecl *NewFD = new FunctionDecl(D.getIdentifierLoc(), II, R, SC,
|
FunctionDecl *NewFD = new FunctionDecl(D.getIdentifierLoc(), II, R, SC,
|
||||||
D.getDeclSpec().isInlineSpecified(),
|
D.getDeclSpec().isInlineSpecified(),
|
||||||
LastDeclarator,
|
LastDeclarator);
|
||||||
D.getDeclSpec().getAttributes());
|
// FIXME: Handle attributes.
|
||||||
|
|
||||||
// Transfer ownership of DeclSpec attributes to FunctionDecl
|
|
||||||
D.getDeclSpec().clearAttributes();
|
D.getDeclSpec().clearAttributes();
|
||||||
|
|
||||||
// Merge the decl with the existing one if appropriate. Since C functions
|
// Merge the decl with the existing one if appropriate. Since C functions
|
||||||
|
@ -989,7 +988,9 @@ Sema::ActOnParamDeclarator(struct DeclaratorChunk::ParamInfo &PI, Scope *FnScope
|
||||||
parmDeclType = Context.getPointerType(parmDeclType);
|
parmDeclType = Context.getPointerType(parmDeclType);
|
||||||
|
|
||||||
ParmVarDecl *New = new ParmVarDecl(PI.IdentLoc, II, parmDeclType,
|
ParmVarDecl *New = new ParmVarDecl(PI.IdentLoc, II, parmDeclType,
|
||||||
VarDecl::None, 0, PI.AttrList);
|
VarDecl::None, 0);
|
||||||
|
// FIXME: Handle attributes
|
||||||
|
|
||||||
if (PI.InvalidType)
|
if (PI.InvalidType)
|
||||||
New->setInvalidDecl();
|
New->setInvalidDecl();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ private:
|
||||||
Kind AttrKind;
|
Kind AttrKind;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Attr(Kind AK) : AttrKind(AK) {}
|
Attr(Kind AK) : Next(0), AttrKind(AK) {}
|
||||||
virtual ~Attr() {
|
virtual ~Attr() {
|
||||||
delete Next;
|
delete Next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#include "clang/AST/Type.h"
|
#include "clang/AST/Type.h"
|
||||||
#include "clang/Basic/SourceLocation.h"
|
#include "clang/Basic/SourceLocation.h"
|
||||||
#include "clang/Parse/AttributeList.h"
|
|
||||||
#include "llvm/ADT/APSInt.h"
|
#include "llvm/ADT/APSInt.h"
|
||||||
#include "llvm/Bitcode/SerializationFwd.h"
|
#include "llvm/Bitcode/SerializationFwd.h"
|
||||||
|
|
||||||
|
@ -25,6 +24,7 @@ class Decl;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
class Attr;
|
||||||
class Expr;
|
class Expr;
|
||||||
class Stmt;
|
class Stmt;
|
||||||
class StringLiteral;
|
class StringLiteral;
|
||||||
|
@ -253,19 +253,20 @@ protected:
|
||||||
class ValueDecl : public ScopedDecl {
|
class ValueDecl : public ScopedDecl {
|
||||||
QualType DeclType;
|
QualType DeclType;
|
||||||
|
|
||||||
/// Attributes - Linked list of attributes that are attached to this
|
/// Attrs - Linked list of attributes that are attached to this
|
||||||
/// function.
|
/// function.
|
||||||
AttributeList *Attributes;
|
Attr *Attrs;
|
||||||
protected:
|
protected:
|
||||||
ValueDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T,
|
ValueDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T,
|
||||||
ScopedDecl *PrevDecl, AttributeList *A = 0)
|
ScopedDecl *PrevDecl)
|
||||||
: ScopedDecl(DK, L, Id, PrevDecl), DeclType(T), Attributes(A) {}
|
: ScopedDecl(DK, L, Id, PrevDecl), DeclType(T) {}
|
||||||
public:
|
public:
|
||||||
QualType getType() const { return DeclType; }
|
QualType getType() const { return DeclType; }
|
||||||
void setType(QualType newType) { DeclType = newType; }
|
void setType(QualType newType) { DeclType = newType; }
|
||||||
QualType getCanonicalType() const { return DeclType.getCanonicalType(); }
|
QualType getCanonicalType() const { return DeclType.getCanonicalType(); }
|
||||||
|
|
||||||
AttributeList *getAttributes() const { return Attributes; }
|
void addAttr(Attr *attr);
|
||||||
|
const Attr *getAttrs() const { return Attrs; }
|
||||||
|
|
||||||
// Implement isa/cast/dyncast/etc.
|
// Implement isa/cast/dyncast/etc.
|
||||||
static bool classof(const Decl *D) {
|
static bool classof(const Decl *D) {
|
||||||
|
@ -329,8 +330,8 @@ public:
|
||||||
static bool classof(const VarDecl *D) { return true; }
|
static bool classof(const VarDecl *D) { return true; }
|
||||||
protected:
|
protected:
|
||||||
VarDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T,
|
VarDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T,
|
||||||
StorageClass SC, ScopedDecl *PrevDecl, AttributeList *A = 0)
|
StorageClass SC, ScopedDecl *PrevDecl)
|
||||||
: ValueDecl(DK, L, Id, T, PrevDecl, A), Init(0) { SClass = SC; }
|
: ValueDecl(DK, L, Id, T, PrevDecl), Init(0) { SClass = SC; }
|
||||||
private:
|
private:
|
||||||
Expr *Init;
|
Expr *Init;
|
||||||
// FIXME: This can be packed into the bitfields in Decl.
|
// FIXME: This can be packed into the bitfields in Decl.
|
||||||
|
@ -356,8 +357,8 @@ protected:
|
||||||
class BlockVarDecl : public VarDecl {
|
class BlockVarDecl : public VarDecl {
|
||||||
public:
|
public:
|
||||||
BlockVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S,
|
BlockVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S,
|
||||||
ScopedDecl *PrevDecl, AttributeList *A = 0)
|
ScopedDecl *PrevDecl)
|
||||||
: VarDecl(BlockVar, L, Id, T, S, PrevDecl, A) {}
|
: VarDecl(BlockVar, L, Id, T, S, PrevDecl) {}
|
||||||
|
|
||||||
// Implement isa/cast/dyncast/etc.
|
// Implement isa/cast/dyncast/etc.
|
||||||
static bool classof(const Decl *D) { return D->getKind() == BlockVar; }
|
static bool classof(const Decl *D) { return D->getKind() == BlockVar; }
|
||||||
|
@ -377,8 +378,8 @@ protected:
|
||||||
class FileVarDecl : public VarDecl {
|
class FileVarDecl : public VarDecl {
|
||||||
public:
|
public:
|
||||||
FileVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S,
|
FileVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S,
|
||||||
ScopedDecl *PrevDecl, AttributeList *A = 0)
|
ScopedDecl *PrevDecl)
|
||||||
: VarDecl(FileVar, L, Id, T, S, PrevDecl, A) {}
|
: VarDecl(FileVar, L, Id, T, S, PrevDecl) {}
|
||||||
|
|
||||||
// Implement isa/cast/dyncast/etc.
|
// Implement isa/cast/dyncast/etc.
|
||||||
static bool classof(const Decl *D) { return D->getKind() == FileVar; }
|
static bool classof(const Decl *D) { return D->getKind() == FileVar; }
|
||||||
|
@ -395,8 +396,8 @@ protected:
|
||||||
class ParmVarDecl : public VarDecl {
|
class ParmVarDecl : public VarDecl {
|
||||||
public:
|
public:
|
||||||
ParmVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S,
|
ParmVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S,
|
||||||
ScopedDecl *PrevDecl, AttributeList *A = 0)
|
ScopedDecl *PrevDecl)
|
||||||
: VarDecl(ParmVar, L, Id, T, S, PrevDecl, A),
|
: VarDecl(ParmVar, L, Id, T, S, PrevDecl),
|
||||||
objcDeclQualifier(OBJC_TQ_None) {}
|
objcDeclQualifier(OBJC_TQ_None) {}
|
||||||
|
|
||||||
ObjCDeclQualifier getObjCDeclQualifier() const { return objcDeclQualifier; }
|
ObjCDeclQualifier getObjCDeclQualifier() const { return objcDeclQualifier; }
|
||||||
|
@ -431,8 +432,8 @@ public:
|
||||||
};
|
};
|
||||||
FunctionDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
|
FunctionDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
|
||||||
StorageClass S = None, bool isInline = false,
|
StorageClass S = None, bool isInline = false,
|
||||||
ScopedDecl *PrevDecl = 0, AttributeList *Attrs = 0)
|
ScopedDecl *PrevDecl = 0)
|
||||||
: ValueDecl(Function, L, Id, T, PrevDecl, Attrs),
|
: ValueDecl(Function, L, Id, T, PrevDecl),
|
||||||
ParamInfo(0), Body(0), DeclChain(0), SClass(S), IsInline(isInline) {}
|
ParamInfo(0), Body(0), DeclChain(0), SClass(S), IsInline(isInline) {}
|
||||||
virtual ~FunctionDecl();
|
virtual ~FunctionDecl();
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче