[cfe-commits] r83907 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.h lib/Sema/SemaExpr.cpp lib/Sema/SemaStmt.cpp test/SemaCXX/warn-assignment-condition.cpp

Douglas Gregor dgregor at apple.com
Mon Oct 12 15:16:04 PDT 2009


On Oct 12, 2009, at 2:59 PM, John McCall wrote:

> Author: rjmccall
> Date: Mon Oct 12 16:59:07 2009
> New Revision: 83907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=83907&view=rev
> Log:
> Implement -Wparentheses:  warn about using assignments in contexts  
> that require
> conditions.  Add a fixit to insert the parentheses.  Also fix a very  
> minor
> possible memory leak in 'for' conditions.
>
> Fixes PR 4876 and rdar://problem/7289172

Cool.

> +  // We want to insert before the start of the expression...
> +  SourceLocation Open = E->getSourceRange().getBegin();
> +  // ...and one character after the end.
> +  SourceLocation Close = E->getSourceRange().getEnd 
> ().getFileLocWithOffset(1);

We don't want to be one character after the end; we want to be after  
the last character in the token that end points to . Use  
PP.getLocForEndOfToken(E->getSourceRange().getEnd()) instead, as we do  
in Parser::SuggestParentheses.

	- Doug



More information about the cfe-commits mailing list