diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-02-01 22:36:09 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-02-01 22:36:09 +0000 |
commit | 006ae38a494d6b2389b7c67728705dc8da996754 (patch) | |
tree | 6d2c2aee8cbf0ec19d8e9612a10c76e54bd323ed /lib/Sema | |
parent | cf1620a0ef7f6dc71f4fad5c46fbb0a2de6c6308 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124695 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 6fe111fac7..ab190276af 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -9240,15 +9240,18 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *parenE) { 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()); + } } } |