Skip to content

Commit

Permalink
Switch the note order for -Woverloaded-shift-op-parentheses so that t…
Browse files Browse the repository at this point in the history
…he note

with the silence fix-it comes first.  This is more consistent with the rest
of the warnings in -Wparentheses.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179742 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Weverything committed Apr 18, 2013
1 parent aea5201 commit 1a7df99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8894,14 +8894,14 @@ static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc,
S.Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
<< LHSExpr->getSourceRange() << RHSExpr->getSourceRange()
<< (Kind == OO_LessLess);
SuggestParentheses(S, OpLoc,
S.PDiag(diag::note_evaluate_comparison_first),
SourceRange(OCE->getArg(1)->getLocStart(),
RHSExpr->getLocEnd()));
SuggestParentheses(S, OCE->getOperatorLoc(),
S.PDiag(diag::note_precedence_silence)
<< (Kind == OO_LessLess ? "<<" : ">>"),
OCE->getSourceRange());
SuggestParentheses(S, OpLoc,
S.PDiag(diag::note_evaluate_comparison_first),
SourceRange(OCE->getArg(1)->getLocStart(),
RHSExpr->getLocEnd()));
}

/// DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky
Expand Down
20 changes: 12 additions & 8 deletions test/Sema/parentheses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ void f(Stream& s, bool b) {
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:32-[[@LINE-6]]:32}:")"

(void)(s << 5 == 1); // expected-warning {{overloaded operator << has lower precedence than comparison operator}} \
// expected-note {{place parentheses around comparison expression to evaluate it first}} \
// expected-note {{place parentheses around the '<<' expression to silence this warning}}
// expected-note {{place parentheses around the '<<' expression to silence this warning}} \
// expected-note {{place parentheses around comparison expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"

(void)(s >> 5 == 1); // expected-warning {{overloaded operator >> has lower precedence than comparison operator}} \
// expected-note {{place parentheses around comparison expression to evaluate it first}} \
// expected-note {{place parentheses around the '>>' expression to silence this warning}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:21-[[@LINE-4]]:21}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:16-[[@LINE-6]]:16}:")"
// expected-note {{place parentheses around the '>>' expression to silence this warning}} \
// expected-note {{place parentheses around comparison expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"
}

struct S {
Expand Down

0 comments on commit 1a7df99

Please sign in to comment.