summaryrefslogtreecommitdiffstats
path: root/clang/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-13 06:29:04 +0000
committerChris Lattner <sabre@nondot.org>2008-03-13 06:29:04 +0000
commit2e23209df1652630ed9a7ca8cb8e71719560f26e (patch)
treee5e2d128e16a2f4ad064016dc83ba2dc94f83eb1 /clang/Parse/ParseStmt.cpp
parentdd55d3f1b2b4adf27e2284696dc08613cbad3405 (diff)
downloadbcm5719-llvm-2e23209df1652630ed9a7ca8cb8e71719560f26e.tar.gz
bcm5719-llvm-2e23209df1652630ed9a7ca8cb8e71719560f26e.zip
improve DeclStmt to be able to store SourceRange info correctly.
Set the start of DeclStmt range. Right now the end is meaningless though. llvm-svn: 48330
Diffstat (limited to 'clang/Parse/ParseStmt.cpp')
-rw-r--r--clang/Parse/ParseStmt.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/Parse/ParseStmt.cpp b/clang/Parse/ParseStmt.cpp
index 389d5d4a54d..160701ee9c7 100644
--- a/clang/Parse/ParseStmt.cpp
+++ b/clang/Parse/ParseStmt.cpp
@@ -93,7 +93,10 @@ Parser::StmtResult Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
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 @@ Parser::StmtResult Parser::ParseIdentifierStatement(bool OnlyStatement) {
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 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
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 @@ Parser::StmtResult Parser::ParseForStatement() {
// 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'
OpenPOWER on IntegriCloud