summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-16 00:37:05 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-16 00:37:05 +0000
commit8eeec5bd033a8ccc1e662b4e0aa3cdb801fccce7 (patch)
tree2674dbbe954c8864fdbb8ee96ba1fa3a71e1b475 /clang/lib/Sema/SemaStmt.cpp
parent62c454847d8041efd71a233d108508116e98e855 (diff)
downloadbcm5719-llvm-8eeec5bd033a8ccc1e662b4e0aa3cdb801fccce7.tar.gz
bcm5719-llvm-8eeec5bd033a8ccc1e662b4e0aa3cdb801fccce7.zip
Do not warn about empty bodies for 'if' statements if the body is expanded from a macro.
Fixes <rdar://problem/8436021>. llvm-svn: 114049
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 84dfa1a9999..c9a6da13fbe 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -272,9 +272,12 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar,
// this helps prevent bugs due to typos, such as
// if (condition);
// do_stuff();
+ //
+ // NOTE: Do not emit this warning if the body is expanded from a macro.
if (!elseStmt) {
if (NullStmt* stmt = dyn_cast<NullStmt>(thenStmt))
- Diag(stmt->getSemiLoc(), diag::warn_empty_if_body);
+ if (!stmt->getLocStart().isMacroID())
+ Diag(stmt->getSemiLoc(), diag::warn_empty_if_body);
}
DiagnoseUnusedExprResult(elseStmt);
OpenPOWER on IntegriCloud