Don't warn about extraneous '()' around a comparison if it occurs within a macro.

Macros frequently contain extra '()' to make instantiation less error prone.
This warning was flagging a ton of times on postgresql because of its use of macros.

llvm-svn: 124695
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 6fe111f..ab19027 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9240,15 +9240,18 @@
         opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
                                                            == Expr::MLV_Valid) {
       SourceLocation Loc = opE->getOperatorLoc();
-
-      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());
+      
+      // 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());
+      }
     }
 }
 
diff --git a/clang/test/SemaCXX/warn-assignment-condition.cpp b/clang/test/SemaCXX/warn-assignment-condition.cpp
index 7596bb2..ab9d2ad 100644
--- a/clang/test/SemaCXX/warn-assignment-condition.cpp
+++ b/clang/test/SemaCXX/warn-assignment-condition.cpp
@@ -124,3 +124,13 @@
                           // expected-note {{remove extraneous parentheses around the comparison to silence this warning}}
     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;
+}
+