aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Decl.h24
-rw-r--r--lib/AST/Decl.cpp11
-rw-r--r--lib/Sema/SemaDecl.cpp9
3 files changed, 31 insertions, 13 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 29ec40b6e2..fe5e1400ca 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -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
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 8bc212d302..3ddf81974b 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -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,
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 8214fe4c63..1d755efd12 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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