[cfe-commits] r124714 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/warn-assignment-condition.cpp

Ted Kremenek kremenek at apple.com
Tue Feb 1 18:20:30 PST 2011


Author: kremenek
Date: Tue Feb  1 20:20:30 2011
New Revision: 124714

URL: http://llvm.org/viewvc/llvm-project?rev=124714&view=rev
Log:
Remove redundant check to not warn for warn_equality_with_extra_parens if we are in a macro.  This is checked twice.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaCXX/warn-assignment-condition.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=124714&r1=124713&r2=124714&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Feb  1 20:20:30 2011
@@ -9244,17 +9244,12 @@
                                                            == 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());
     }
 }
 

Modified: cfe/trunk/test/SemaCXX/warn-assignment-condition.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-assignment-condition.cpp?rev=124714&r1=124713&r2=124714&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-assignment-condition.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-assignment-condition.cpp Tue Feb  1 20:20:30 2011
@@ -125,12 +125,3 @@
     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;
-}
-





More information about the cfe-commits mailing list