improve DeclStmt to be able to store SourceRange info correctly.
Set the start of DeclStmt range. Right now the end is meaningless
though.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48330 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/ParseDecl.cpp b/Parse/ParseDecl.cpp
index 8b8d645..7d15e98 100644
--- a/Parse/ParseDecl.cpp
+++ b/Parse/ParseDecl.cpp
@@ -388,7 +388,7 @@
/// [C99] 'inline'
///
void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) {
- DS.Range.setBegin(Tok.getLocation());
+ DS.SetRangeStart(Tok.getLocation());
while (1) {
int isInvalid = false;
const char *PrevSpec = 0;
@@ -409,7 +409,7 @@
if (isInvalid)
break;
// FIXME: restrict this to "id" and ObjC classnames.
- DS.Range.setEnd(Tok.getLocation());
+ DS.SetRangeEnd(Tok.getLocation());
ConsumeToken(); // The identifier
if (Tok.is(tok::less)) {
SourceLocation endProtoLoc;
@@ -555,7 +555,7 @@
else // extwarn.
Diag(Tok, diag::ext_duplicate_declspec, PrevSpec);
}
- DS.Range.setEnd(Tok.getLocation());
+ DS.SetRangeEnd(Tok.getLocation());
ConsumeToken();
}
}
diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp
index 7f33ffd..77d2adb 100644
--- a/Parse/ParseObjc.cpp
+++ b/Parse/ParseObjc.cpp
@@ -1186,9 +1186,11 @@
// FIXME: Is BlockContext right?
Declarator DeclaratorInfo(DS, Declarator::BlockContext);
ParseDeclarator(DeclaratorInfo);
- DeclTy * aBlockVarDecl = Actions.ActOnDeclarator(CurScope,
- DeclaratorInfo, 0);
- StmtResult stmtResult = Actions.ActOnDeclStmt(aBlockVarDecl);
+ DeclTy *aBlockVarDecl = Actions.ActOnDeclarator(CurScope,
+ DeclaratorInfo, 0);
+ StmtResult stmtResult =
+ Actions.ActOnDeclStmt(aBlockVarDecl, DS.getSourceRange().getBegin(),
+ DeclaratorInfo.getSourceRange().getEnd());
FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val;
} else
ConsumeToken(); // consume '...'
diff --git a/Parse/ParseStmt.cpp b/Parse/ParseStmt.cpp
index 389d5d4..160701e 100644
--- a/Parse/ParseStmt.cpp
+++ b/Parse/ParseStmt.cpp
@@ -93,7 +93,10 @@
default:
if (!OnlyStatement && isDeclarationSpecifier()) {
- return Actions.ActOnDeclStmt(ParseDeclaration(Declarator::BlockContext));
+ SourceLocation DeclStart = Tok.getLocation();
+ DeclTy *Res = ParseDeclaration(Declarator::BlockContext);
+ // FIXME: Pass in the right location for the end of the declstmt.
+ return Actions.ActOnDeclStmt(Res, DeclStart, SourceLocation());
} else if (Tok.is(tok::r_brace)) {
Diag(Tok, diag::err_expected_statement);
return true;
@@ -255,7 +258,9 @@
ParseDeclarator(DeclaratorInfo);
DeclTy *Decl = ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
- return Decl ? Actions.ActOnDeclStmt(Decl) : 0;
+ if (!Decl) return 0;
+ return Actions.ActOnDeclStmt(Decl, DS.getSourceRange().getBegin(),
+ DeclaratorInfo.getSourceRange().getEnd());
}
// Otherwise, this is an expression. Seed it with II and parse it.
@@ -430,7 +435,10 @@
if (isDeclarationSpecifier()) {
// FIXME: Save the __extension__ on the decl as a node somehow.
// FIXME: disable extwarns.
- R = Actions.ActOnDeclStmt(ParseDeclaration(Declarator::BlockContext));
+ SourceLocation DeclStart = Tok.getLocation();
+ DeclTy *Res = ParseDeclaration(Declarator::BlockContext);
+ // FIXME: Pass in the right location for the end of the declstmt.
+ R = Actions.ActOnDeclStmt(Res, DeclStart, SourceLocation());
} else {
// Otherwise this was a unary __extension__ marker. Parse the
// subexpression and add the __extension__ unary op.
@@ -743,8 +751,12 @@
// Parse declaration, which eats the ';'.
if (!getLang().C99) // Use of C99-style for loops in C90 mode?
Diag(Tok, diag::ext_c99_variable_decl_in_for_loop);
+
+ SourceLocation DeclStart = Tok.getLocation();
DeclTy *aBlockVarDecl = ParseDeclaration(Declarator::ForContext);
- StmtResult stmtResult = Actions.ActOnDeclStmt(aBlockVarDecl);
+ // FIXME: Pass in the right location for the end of the declstmt.
+ StmtResult stmtResult = Actions.ActOnDeclStmt(aBlockVarDecl, DeclStart,
+ SourceLocation());
FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val;
if ((ForEach = isTokIdentifier_in())) {
ConsumeToken(); // consume 'in'