]> granicus.if.org Git - clang/commitdiff
Remove redundant check to not warn for warn_equality_with_extra_parens if we are...
authorTed Kremenek <kremenek@apple.com>
Wed, 2 Feb 2011 02:20:30 +0000 (02:20 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 2 Feb 2011 02:20:30 +0000 (02:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124714 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/warn-assignment-condition.cpp

index c084bb0a80d21a57fa57549ded45355c36a4a917..ec5e3e0c3c3b6a3cb1b321f6927dc42ad0359164 100644 (file)
@@ -9244,17 +9244,12 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *parenE) {
                                                            == Expr::MLV_Valid) {
       SourceLocation Loc = opE->getOperatorLoc();
       
-      // Don't emit a warning if the operation occurs within a macro.
-      // Sometimes extra parentheses are used within macros to make the
-      // instantiation of the macro less error prone.
-      if (!Loc.isMacroID()) {
-        Diag(Loc, diag::warn_equality_with_extra_parens) << E->getSourceRange();
-        Diag(Loc, diag::note_equality_comparison_to_assign)
-          << FixItHint::CreateReplacement(Loc, "=");
-        Diag(Loc, diag::note_equality_comparison_silence)
-          << FixItHint::CreateRemoval(parenE->getSourceRange().getBegin())
-          << FixItHint::CreateRemoval(parenE->getSourceRange().getEnd());
-      }
+      Diag(Loc, diag::warn_equality_with_extra_parens) << E->getSourceRange();
+      Diag(Loc, diag::note_equality_comparison_to_assign)
+        << FixItHint::CreateReplacement(Loc, "=");
+      Diag(Loc, diag::note_equality_comparison_silence)
+        << FixItHint::CreateRemoval(parenE->getSourceRange().getBegin())
+        << FixItHint::CreateRemoval(parenE->getSourceRange().getEnd());
     }
 }
 
index ab9d2ad4a5757ea02ce7bca707ea0f87601ef829..27eedb9128d7ee04e2103a62d7d4609d1da8503d 100644 (file)
@@ -125,12 +125,3 @@ void test2() {
     if ((test2 == fn)) {}
 }
 
-// Do not warn about extra '()' used within a macro.  This pattern
-// occurs frequently.
-#define COMPARE(x,y) (x == y)
-int test3(int x, int y) {
-  if (COMPARE(x, y)) // no-warning
-    return 0;
-  return 1;
-}
-