r197150 - Suppress -Wshadow / -Wold-style-cast expanded from system header macros

Aaron Ballman aaron at aaronballman.com
Thu Dec 12 05:54:38 PST 2013


On Thu, Dec 12, 2013 at 8:04 AM, Alp Toker <alp at nuanti.com> wrote:
>
> On 12/12/2013 12:47, Alp Toker wrote:
>>
>> Author: alp
>> Date: Thu Dec 12 06:47:48 2013
>> New Revision: 197150
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=197150&view=rev
>> Log:
>> Suppress -Wshadow / -Wold-style-cast expanded from system header macros
>>
>> Thanks to Jonathan Sauer for providing initial test cases.
>>
>> Fixes PR16093 and PR18147.
>>
>> Added:
>>      cfe/trunk/test/SemaCXX/warn-sysheader-macro.cpp
>> Modified:
>>      cfe/trunk/lib/Sema/SemaDecl.cpp
>>      cfe/trunk/lib/Sema/SemaExpr.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=197150&r1=197149&r2=197150&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Dec 12 06:47:48 2013
>> @@ -5599,6 +5599,8 @@ void Sema::CheckShadow(Scope *S, VarDecl
>>     DeclarationName Name = R.getLookupName();
>>       // Emit warning and note.
>> +  if (getSourceManager().isInSystemMacro(R.getNameLoc()))
>> +    return;
>
>
>
> Incidentally, isInSystemMacro() calls are scattered all over the place right
> now to suppress various warnings.
>
> It'd be great to replace those with a diagnostic TableGen bit indicating
> which warning groups are meant to be suppressed when expanded from a system
> macro.
>
> (Would save a few cycles to delay the check until emission time, and would
> let us make the suppression conditional on -Wsystem-header.)
>
> Aaron, as resident TableGen guru do you have an idea what it'd take to get
> that set up? :-)

I've not worked on the diagnostic tablegenning stuff before, but I
would imagine this is a case where you'd simply add a field to the
diagnostics in the td file, update the DIAG macro definitions as
appropriate, and then update ClangDiagnosticsEmitter.cpp to handle the
new field and output properly for the DIAG macro. Then the diagnostic
emission code could check the flag as-needed to determine whether the
output should be suppressed or not. Note, this is based on very little
analysis on my part, so I could be wildly off-base too. ;-)

Long story short: seems doable at first blush.

~Aaron



More information about the cfe-commits mailing list