Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling Clang Warnings

Tags:

llvm

clang

I've compiled the SQLite amalgamation source into my iOS project, and clang throws a warning on this line

mask = (sizeof(long)==8) ? LARGEST_INT64 : 0x7fffffff;

with the following warning:

Implicit conversion from 'long long' to 'long' changes value from
9223372036854775807 to -1
[warn_impcast_integer_precision_constant]

I've enabled -fdiagnostics-show-name to show the name (warn_impcast_integer_precision_constant).

I certainly don't want to change anything in the SQLite source, since I don't want to introduce unforseen side effects, so I'd like to disable this specific warning just for that one line. The warning is certainly valid, but cannot occur anyway with the sizeof check in place.

To make this process reproducible for other warnings and diagnostics, is there a method to find out the specific warning class and disable them for one line? Unfortunately I can't find anything in the so called clang/llvm "documentation".

like image 205
Era Avatar asked Sep 18 '11 10:09

Era


1 Answers

Any remotely recent version of clang should be printing the flag associated with a given warning along with the warning (in this case -Wconstant-conversion); not sure why you are not seeing this. And to turn it off, you can use #pragma clang diagnostic ignored "-Wconstant-conversion".

like image 168
servn Avatar answered Oct 06 '22 04:10

servn