aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-02 04:16:50 +0000
committerChris Lattner <sabre@nondot.org>2009-04-02 04:16:50 +0000
commit97144fc41a9419bf6d74fc9450e8ef3f6e11f7e0 (patch)
treefa4999c1dd962098ab138210b5268e02b340acbc /lib/Parse/ParseStmt.cpp
parent0ddaff3a558cca0d1157c3f63e3ad82b72cf625a (diff)
fix a FIXME, providing accurate source range info for DeclStmt's. The end
of the range is now the ';' location. For something like this: $ cat t2.c #define bool int void f(int x, int y) { bool b = !x && y; } We used to produce: $ clang-cc t2.c -ast-dump typedef char *__builtin_va_list; void f(int x, int y) (CompoundStmt 0x2201f10 <t2.c:3:22, line:5:1> (DeclStmt 0x2201ef0 <line:2:14> <---- 0x2201a20 "int b = (BinaryOperator 0x2201ed0 <line:4:10, col:16> 'int' '&&' (UnaryOperator 0x2201e90 <col:10, col:11> 'int' prefix '!' (DeclRefExpr 0x2201c90 <col:11> 'int' ParmVar='x' 0x2201a50)) (DeclRefExpr 0x2201eb0 <col:16> 'int' ParmVar='y' 0x2201e10))") Now we produce: $ clang-cc t2.c -ast-dump typedef char *__builtin_va_list; void f(int x, int y) (CompoundStmt 0x2201f10 <t2.c:3:22, line:5:1> (DeclStmt 0x2201ef0 <line:2:14, line:4:17> <------ 0x2201a20 "int b = (BinaryOperator 0x2201ed0 <col:10, col:16> 'int' '&&' (UnaryOperator 0x2201e90 <col:10, col:11> 'int' prefix '!' (DeclRefExpr 0x2201c90 <col:11> 'int' ParmVar='x' 0x2201a50)) (DeclRefExpr 0x2201eb0 <col:16> 'int' ParmVar='y' 0x2201e10))") git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r--lib/Parse/ParseStmt.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index b11ffbe82e..b87ede9388 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -100,10 +100,9 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
default: {
if ((getLang().CPlusPlus || !OnlyStatement) && isDeclarationStatement()) {
- SourceLocation DeclStart = Tok.getLocation();
- DeclGroupPtrTy Decl = ParseDeclaration(Declarator::BlockContext);
- // FIXME: Pass in the right location for the end of the declstmt.
- return Actions.ActOnDeclStmt(Decl, DeclStart, DeclStart);
+ SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
+ DeclGroupPtrTy Decl = ParseDeclaration(Declarator::BlockContext, DeclEnd);
+ return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd);
}
if (Tok.is(tok::r_brace)) {
@@ -442,11 +441,10 @@ Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
// If this is the start of a declaration, parse it as such.
if (isDeclarationStatement()) {
- // FIXME: Save the __extension__ on the decl as a node somehow.
- SourceLocation DeclStart = Tok.getLocation();
- DeclGroupPtrTy Res = ParseDeclaration(Declarator::BlockContext);
- // FIXME: Pass in the right location for the end of the declstmt.
- R = Actions.ActOnDeclStmt(Res, DeclStart, DeclStart);
+ // FIXME: Save the __extension__ on the decl as a node somehow?
+ SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
+ DeclGroupPtrTy Res = ParseDeclaration(Declarator::BlockContext,DeclEnd);
+ R = Actions.ActOnDeclStmt(Res, DeclStart, DeclEnd);
} else {
// Otherwise this was a unary __extension__ marker.
OwningExprResult Res(ParseExpressionWithLeadingExtension(ExtLoc));
@@ -911,8 +909,9 @@ Parser::OwningStmtResult Parser::ParseForStatement() {
if (!C99orCXX) // Use of C99-style for loops in C90 mode?
Diag(Tok, diag::ext_c99_variable_decl_in_for_loop);
- SourceLocation DeclStart = Tok.getLocation();
- DeclGroupPtrTy DG = ParseSimpleDeclaration(Declarator::ForContext, false);
+ SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
+ DeclGroupPtrTy DG = ParseSimpleDeclaration(Declarator::ForContext, DeclEnd,
+ false);
FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation());
if (Tok.is(tok::semi)) { // for (int x = 4;