[cfe-commits] r166522 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/unused-expr.c

Matt Beaumont-Gay matthewbg at google.com
Tue Oct 23 18:17:07 PDT 2012


Thanks for the review! Done in r166534.

On Tue, Oct 23, 2012 at 4:57 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Tue, Oct 23, 2012 at 4:19 PM, Matt Beaumont-Gay <matthewbg at google.com> wrote:
>> Author: matthewbg
>> Date: Tue Oct 23 18:19:32 2012
>> New Revision: 166522
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=166522&view=rev
>> Log:
>> Don't emit -Wunused-value warnings from macro expansions.
>>
>> Modified:
>>     cfe/trunk/lib/AST/Expr.cpp
>>     cfe/trunk/test/Sema/unused-expr.c
>>
>> Modified: cfe/trunk/lib/AST/Expr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=166522&r1=166521&r2=166522&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/AST/Expr.cpp (original)
>> +++ cfe/trunk/lib/AST/Expr.cpp Tue Oct 23 18:19:32 2012
>> @@ -2026,6 +2026,10 @@
>>    }
>>    case CXXFunctionalCastExprClass:
>>    case CStyleCastExprClass: {
>> +    // Ignore casts within macro expansions.
>> +    if (getExprLoc().isMacroID())
>> +      return false;
>
> A few issues:
>
> 1. Please move this below the special-case for casts to void.
> 2. "Ignore" in this context should be written as "return
> CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);";
> we don't want to completely suppress unused-value warnings just
> because there's a cast in a macro.  (e.g. "(long)1" should still be
> treated as an unused value).
>
> -Eli



More information about the cfe-commits mailing list