[cfe-commits] r133526 - /cfe/trunk/lib/Sema/SemaExpr.cpp

Douglas Gregor dgregor at apple.com
Tue Jun 21 11:23:12 PDT 2011


On Jun 21, 2011, at 11:07 AM, Chandler Carruth wrote:

> Author: chandlerc
> Date: Tue Jun 21 13:07:33 2011
> New Revision: 133526
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=133526&view=rev
> Log:
> Switch the order of the notes for the parentheses suggested in the case
> of: a + b ? x : y. In our testing of this flag we've yet to hit a single
> case where the existing precedence was correct, so we should suggest
> grouping the ?: first.

I'm not a big fan of this change. In general, we've taken the approach that the "silence the warning" option is always first. Being consistent about that helps users (particularly in an IDE setting) understand which of the options actually makes a change. I think that consistency is more valuable than trying to guess what the user intended.

	- Doug

> Modified:
>    cfe/trunk/lib/Sema/SemaExpr.cpp
> 
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=133526&r1=133525&r2=133526&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jun 21 13:07:33 2011
> @@ -6377,13 +6377,13 @@
>       << BinaryOperator::getOpcodeStr(CondOpcode);
> 
>   SuggestParentheses(Self, OpLoc,
> +    Self.PDiag(diag::note_precedence_conditional_first),
> +    SourceRange(CondRHS->getLocStart(), RHS->getLocEnd()));
> +
> +  SuggestParentheses(Self, OpLoc,
>     Self.PDiag(diag::note_precedence_conditional_silence)
>       << BinaryOperator::getOpcodeStr(CondOpcode),
>     SourceRange(Condition->getLocStart(), Condition->getLocEnd()));
> -
> -  SuggestParentheses(Self, OpLoc,
> -    Self.PDiag(diag::note_precedence_conditional_first),
> -    SourceRange(CondRHS->getLocStart(), RHS->getLocEnd()));
> }
> 
> /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list