aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-01 22:23:56 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-01 22:23:56 +0000
commitcf1620a0ef7f6dc71f4fad5c46fbb0a2de6c6308 (patch)
treeb86f49a4de6c5a89ae57675e33ff0318ba3dc5bf /lib/Sema/SemaExpr.cpp
parent7143325db76d6c3dabce82500f8cc7c93a941970 (diff)
Don't warn for "if ((a == b))" if the parens came from a macro. Thanks to Fariborz for the hint!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124689 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 8448ed8079..6fe111fac7 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -9228,6 +9228,11 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
/// \brief Redundant parentheses over an equality comparison can indicate
/// that the user intended an assignment used as condition.
void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *parenE) {
+ // Don't warn if the parens came from a macro.
+ SourceLocation parenLoc = parenE->getLocStart();
+ if (parenLoc.isInvalid() || parenLoc.isMacroID())
+ return;
+
Expr *E = parenE->IgnoreParens();
if (BinaryOperator *opE = dyn_cast<BinaryOperator>(E))