Simplify the interface to ParseFunctionStatementBody to not take
locations that are the current tok loc. Note that inline C++ methods
have a big fixme that could cause a crash.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66113 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp
index 4aa923c..cc61f0f 100644
--- a/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/lib/Parse/ParseCXXInlineMethods.cpp
@@ -136,8 +136,8 @@
if (Tok.is(tok::colon))
ParseConstructorInitializer(LM.D);
-
- ParseFunctionStatementBody(LM.D, Tok.getLocation(), Tok.getLocation());
+ // FIXME: What if ParseConstructorInitializer doesn't leave us with a '{'??
+ ParseFunctionStatementBody(LM.D);
}
}
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 4f7affc..1ecbe8b 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -1284,8 +1284,10 @@
return true;
}
-Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl,
- SourceLocation L, SourceLocation R) {
+Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl) {
+ assert(Tok.is(tok::l_brace));
+ SourceLocation LBraceLoc = Tok.getLocation();
+
// Do not enter a scope for the brace, as the arguments are in the same scope
// (the function body) as the body itself. Instead, just read the statement
// list and put it into a CompoundStmt for safe keeping.
@@ -1293,7 +1295,8 @@
// If the function body could not be parsed, make a bogus compoundstmt.
if (FnBody.isInvalid())
- FnBody = Actions.ActOnCompoundStmt(L, R, MultiStmtArg(Actions), false);
+ FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc,
+ MultiStmtArg(Actions), false);
return Actions.ActOnFinishFunctionBody(Decl, move(FnBody));
}
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 30db5e6..3cdaab6 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -590,7 +590,7 @@
ParseConstructorInitializer(Res);
SourceLocation BraceLoc = Tok.getLocation();
- return ParseFunctionStatementBody(Res, BraceLoc, BraceLoc);
+ return ParseFunctionStatementBody(Res);
}
/// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides