[cfe-commits] r56985 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp lib/Sema/SemaDecl.cpp
Steve Naroff
snaroff at apple.com
Thu Oct 2 17:02:04 PDT 2008
Author: snaroff
Date: Thu Oct 2 19:02:03 2008
New Revision: 56985
URL: http://llvm.org/viewvc/llvm-project?rev=56985&view=rev
Log:
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).
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=56985&r1=56984&r2=56985&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Oct 2 19:02:03 2008
@@ -230,19 +230,25 @@
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 @@
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 @@
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
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=56985&r1=56984&r2=56985&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Oct 2 19:02:03 2008
@@ -51,9 +51,10 @@
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 @@
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,
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=56985&r1=56984&r2=56985&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct 2 19:02:03 2008
@@ -661,8 +661,9 @@
} 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 @@
}
}
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
More information about the cfe-commits
mailing list