зеркало из https://github.com/microsoft/clang-1.git
Add getTypeSpecStartLoc() to VarDecls and FunctionDecls.
This is a temporary solution to help with the block rewriter (though it certainly has general utility). Once DeclGroup's are implemented, this SourceLocation should be stored with it (since it applies to all the decls). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56985 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
a0b75cf582
Коммит
0eb07bfde0
|
@ -230,19 +230,25 @@ private:
|
|||
unsigned SClass : 3;
|
||||
bool ThreadSpecified : 1;
|
||||
|
||||
// Move to DeclGroup when it is implemented.
|
||||
SourceLocation TypeSpecStartLoc;
|
||||
friend class StmtIteratorBase;
|
||||
protected:
|
||||
VarDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
|
||||
QualType T, StorageClass SC, ScopedDecl *PrevDecl)
|
||||
QualType T, StorageClass SC, ScopedDecl *PrevDecl,
|
||||
SourceLocation TSSL = SourceLocation())
|
||||
: ValueDecl(DK, DC, L, Id, T, PrevDecl), Init(0),
|
||||
ThreadSpecified(false) { SClass = SC; }
|
||||
ThreadSpecified(false), TypeSpecStartLoc(TSSL) { SClass = SC; }
|
||||
public:
|
||||
static VarDecl *Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
QualType T, StorageClass S, ScopedDecl *PrevDecl);
|
||||
QualType T, StorageClass S, ScopedDecl *PrevDecl,
|
||||
SourceLocation TypeSpecStartLoc = SourceLocation());
|
||||
|
||||
StorageClass getStorageClass() const { return (StorageClass)SClass; }
|
||||
|
||||
SourceLocation getTypeSpecStartLoc() const { return TypeSpecStartLoc; }
|
||||
|
||||
const Expr *getInit() const { return (const Expr*) Init; }
|
||||
Expr *getInit() { return (Expr*) Init; }
|
||||
void setInit(Expr *I) { Init = (Stmt*) I; }
|
||||
|
@ -416,14 +422,17 @@ private:
|
|||
bool IsInline : 1;
|
||||
bool IsImplicit : 1;
|
||||
|
||||
// Move to DeclGroup when it is implemented.
|
||||
SourceLocation TypeSpecStartLoc;
|
||||
protected:
|
||||
FunctionDecl(Kind DK, DeclContext *DC, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T,
|
||||
StorageClass S, bool isInline, ScopedDecl *PrevDecl)
|
||||
StorageClass S, bool isInline, ScopedDecl *PrevDecl,
|
||||
SourceLocation TSSL = SourceLocation())
|
||||
: ValueDecl(DK, DC, L, Id, T, PrevDecl),
|
||||
DeclContext(DK),
|
||||
ParamInfo(0), Body(0), PreviousDeclaration(0),
|
||||
SClass(S), IsInline(isInline), IsImplicit(0) {}
|
||||
SClass(S), IsInline(isInline), IsImplicit(0), TypeSpecStartLoc(TSSL) {}
|
||||
|
||||
virtual ~FunctionDecl();
|
||||
virtual void Destroy(ASTContext& C);
|
||||
|
@ -432,8 +441,11 @@ public:
|
|||
static FunctionDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T,
|
||||
StorageClass S = None, bool isInline = false,
|
||||
ScopedDecl *PrevDecl = 0);
|
||||
ScopedDecl *PrevDecl = 0,
|
||||
SourceLocation TSStartLoc = SourceLocation());
|
||||
|
||||
SourceLocation getTypeSpecStartLoc() const { return TypeSpecStartLoc; }
|
||||
|
||||
/// getBody - Retrieve the body (definition) of the function. The
|
||||
/// function body might be in any of the (re-)declarations of this
|
||||
/// function. The variant that accepts a FunctionDecl pointer will
|
||||
|
|
|
@ -51,9 +51,10 @@ ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC,
|
|||
VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T,
|
||||
StorageClass S, ScopedDecl *PrevDecl) {
|
||||
StorageClass S, ScopedDecl *PrevDecl,
|
||||
SourceLocation TypeSpecStartLoc) {
|
||||
void *Mem = C.getAllocator().Allocate<VarDecl>();
|
||||
return new (Mem) VarDecl(Var, DC, L, Id, T, S, PrevDecl);
|
||||
return new (Mem) VarDecl(Var, DC, L, Id, T, S, PrevDecl, TypeSpecStartLoc);
|
||||
}
|
||||
|
||||
ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
|
@ -68,9 +69,11 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
|
|||
SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T,
|
||||
StorageClass S, bool isInline,
|
||||
ScopedDecl *PrevDecl) {
|
||||
ScopedDecl *PrevDecl,
|
||||
SourceLocation TypeSpecStartLoc) {
|
||||
void *Mem = C.getAllocator().Allocate<FunctionDecl>();
|
||||
return new (Mem) FunctionDecl(Function, DC, L, Id, T, S, isInline, PrevDecl);
|
||||
return new (Mem) FunctionDecl(Function, DC, L, Id, T, S, isInline, PrevDecl,
|
||||
TypeSpecStartLoc);
|
||||
}
|
||||
|
||||
FieldDecl *FieldDecl::Create(ASTContext &C, SourceLocation L,
|
||||
|
|
|
@ -661,8 +661,9 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
|
|||
} else {
|
||||
NewFD = FunctionDecl::Create(Context, CurContext,
|
||||
D.getIdentifierLoc(),
|
||||
II, R, SC, isInline,
|
||||
LastDeclarator);
|
||||
II, R, SC, isInline, LastDeclarator,
|
||||
// FIXME: Move to DeclGroup...
|
||||
D.getDeclSpec().getSourceRange().getBegin());
|
||||
}
|
||||
// Handle attributes.
|
||||
ProcessDeclAttributes(NewFD, D);
|
||||
|
@ -766,7 +767,9 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
|
|||
}
|
||||
}
|
||||
NewVD = VarDecl::Create(Context, CurContext, D.getIdentifierLoc(),
|
||||
II, R, SC, LastDeclarator);
|
||||
II, R, SC, LastDeclarator,
|
||||
// FIXME: Move to DeclGroup...
|
||||
D.getDeclSpec().getSourceRange().getBegin());
|
||||
NewVD->setThreadSpecified(ThreadSpecified);
|
||||
}
|
||||
// Handle attributes prior to checking for duplicates in MergeVarDecl
|
||||
|
|
Загрузка…
Ссылка в новой задаче