[cfe-dev] clang-tidy misc-macro-parentheses
Alfred Zien via cfe-dev
cfe-dev at lists.llvm.org
Thu Dec 22 07:35:43 PST 2016
I can totally understand why such definition is bad. Unfortunately, I can't change it, because it is part of very big project (chromium, https://chromium.googlesource.com/chromium/src/build/config/+/master/compiler/BUILD.gn <https://chromium.googlesource.com/chromium/src/build/config/+/master/compiler/BUILD.gn>, search for CR_CLANG_REVISION, it is result of script execution, in my case, it is 282487-1, and I get -DCR_CLANG_REVISION=282487-1), that propagates it in every file, that is building with their config.
So, I can only try to suppress it, or abandon that check completely.
> On 22 Dec 2016, at 17:50, Aaron Ballman <aaron at aaronballman.com> wrote:
>
> On Thu, Dec 22, 2016 at 7:43 AM, Alfred Zien via cfe-dev
> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
>> Hi!
>>
>> clang-tidy misc-macro-parentheses checks macros that supplied with
>> command-line arguments.
>>
>> Lets say I have simple foo.c:
>> int main() {};
>>
>> And I write to console:
>>
>> clang-tidy foo.c -checks=misc-macro-parentheses -- -DVERSION=1.23-5
>>
>> It prints out
>>
>> warning: macro replacement list should be enclosed in parentheses
>> [misc-macro-parentheses]
>>
>> Firstly, it is very hard to find out why it occurs. Secondly, I couldn't
>> figure out how to suppress it. Anybody knows good way to do it? Apart from
>> this. this seems to be a very good check.
>
> I can see how that would be difficult to discover why the diagnostic
> is triggering; there's no source location for the macro. Perhaps there
> is a way to improve the diagnostic in that case.
>
> The diagnostic is triggered because you are using a subtraction
> expression as the macro definition, so if you were to use this in an
> integer expression, you may get the wrong results. If your version
> isn't meant to be treated as an integral value, perhaps you could make
> it into a string literal instead? That would silence the diagnostic
> without requiring parens.
>
> ~Aaron
>
>>
>> I'm using compile_commands.json in my project, so I can't control compiler
>> arguments directly.
>>
>> Thanks for any help!
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161222/e1acb2e4/attachment.html>
More information about the cfe-dev
mailing list