summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Sema/Sema.h4
-rw-r--r--clang/lib/Parse/ParseStmt.cpp1
-rw-r--r--clang/lib/Sema/SemaChecking.cpp2
-rw-r--r--clang/lib/Sema/SemaStmt.cpp3
-rw-r--r--clang/test/SemaCXX/warn-empty-body.cpp11
5 files changed, 3 insertions, 18 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 355e20edc03..574a1ca069d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9698,7 +9698,6 @@ public:
class ConditionResult {
Decl *ConditionVar;
FullExprArg Condition;
- SourceLocation RParenLoc;
bool Invalid;
bool HasKnownValue;
bool KnownValue;
@@ -9722,9 +9721,6 @@ public:
return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
Condition.get());
}
-
- void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
-
llvm::Optional<bool> getKnownValue() const {
if (!HasKnownValue)
return None;
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index ec14cee5a34..e8cf7d5fa45 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1101,7 +1101,6 @@ bool Parser::ParseParenExprOrCondition(StmtResult *InitStmt,
// Otherwise the condition is valid or the rparen is present.
T.consumeClose();
- Cond.setRParenLoc(T.getCloseLocation());
// Check for extraneous ')'s to catch things like "if (foo())) {". We know
// that all callers are looking for a statement after the condition, so ")"
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 8a85830bfdb..e662a5c8b97 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11821,7 +11821,7 @@ static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr,
// Get line numbers of statement and body.
bool StmtLineInvalid;
- unsigned StmtLine = SourceMgr.getSpellingLineNumber(StmtLoc,
+ unsigned StmtLine = SourceMgr.getPresumedLineNumber(StmtLoc,
&StmtLineInvalid);
if (StmtLineInvalid)
return false;
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index de9b8c3b76c..07b70305c19 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -530,7 +530,8 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, bool IsConstexpr, Stmt *InitStmt,
if (elseStmt)
DiagnoseEmptyStmtBody(ElseLoc, elseStmt, diag::warn_empty_else_body);
else
- DiagnoseEmptyStmtBody(Cond.RParenLoc, thenStmt, diag::warn_empty_if_body);
+ DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), thenStmt,
+ diag::warn_empty_if_body);
return BuildIfStmt(IfLoc, IsConstexpr, InitStmt, Cond, thenStmt, ElseLoc,
elseStmt);
diff --git a/clang/test/SemaCXX/warn-empty-body.cpp b/clang/test/SemaCXX/warn-empty-body.cpp
index 0fc0cd51f93..bd6b47f053f 100644
--- a/clang/test/SemaCXX/warn-empty-body.cpp
+++ b/clang/test/SemaCXX/warn-empty-body.cpp
@@ -301,14 +301,3 @@ void test7(int x, int y) {
if (x) IDENTITY(); // no-warning
}
-#define SOME_IF(A) if (A)
-#define IF_ELSE(A) if (A); else
-
-
-void test_macros() {
- SOME_IF(0);
- IF_ELSE(0);
-
- IDENTITY(if (0);) // expected-warning{{if statement has empty body}} expected-note{{separate line}}
- IDENTITY(if (0); else;) // expected-warning{{else clause has empty body}} expected-note{{separate line}}}
-}
OpenPOWER on IntegriCloud