You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following simple example clang-tidy will output a warning when the check cppcoreguidelines-narrowing-conversions is enabled.
intmain() {
long x = 123;
int y = x;
}
$ clang-tidy --checks='cppcoreguidelines-narrowing-conversions' main.cppError while trying to load a compilation database:Could not auto-detect compilation database for file "main.cpp"No compilation database found in /home/user/programming_test or any parent directoryfixed-compilation-database: Error while opening fixed database: No such file or directoryjson-compilation-database: Error while opening JSON database: No such file or directoryRunning without flags.2 warnings generated./home/user/programming_test/main.cpp:3:7: warning: Value stored to 'y' during its initialization is never read [clang-analyzer-deadcode.DeadStores] int y = x; ^ ~/home/user/programming_test/main.cpp:3:7: note: Value stored to 'y' during its initialization is never read int y = x; ^ ~/home/user/programming_test/main.cpp:3:11: warning: narrowing conversion from 'long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions] int y = x; ^
This is as expected. However, if I run the same check but with IgnoreConversionFromTypes set to 'long' it still outputs the same warning:
$ clang-tidy --checks='cppcoreguidelines-narrowing-conversions' -config="{CheckOptions: [ {key: cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes, value: 'long'} ]}" main.cppError while trying to load a compilation database:Could not auto-detect compilation database for file "main.cpp"No compilation database found in /home/user/programming_test or any parent directoryfixed-compilation-database: Error while opening fixed database: No such file or directoryjson-compilation-database: Error while opening JSON database: No such file or directoryRunning without flags.2 warnings generated./home/user/programming_test/main.cpp:3:7: warning: Value stored to 'y' during its initialization is never read [clang-analyzer-deadcode.DeadStores] int y = x; ^ ~/home/user/programming_test/main.cpp:3:7: note: Value stored to 'y' during its initialization is never read int y = x; ^ ~/home/user/programming_test/main.cpp:3:11: warning: narrowing conversion from 'long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions] int y = x; ^
It seems to only happen with the type long, if I run the same example but replace long x = 123; with size_t x = 123; then it works to set IgnoreConversionFromTypes to 'size_t'.
This is running Ubuntu 22.04 with clang-tidy installed with apt install:
jarledo
changed the title
IgnoreConversionFromTypes has no effect when set to 'long'
clang-tidy: IgnoreConversionFromTypes has no effect when set to 'long'
Nov 4, 2022
In the following simple example clang-tidy will output a warning when the check
cppcoreguidelines-narrowing-conversions
is enabled.This is as expected. However, if I run the same check but with
IgnoreConversionFromTypes
set to'long'
it still outputs the same warning:It seems to only happen with the type
long
, if I run the same example but replacelong x = 123;
withsize_t x = 123;
then it works to setIgnoreConversionFromTypes
to'size_t'
.This is running Ubuntu 22.04 with clang-tidy installed with
apt install
:The text was updated successfully, but these errors were encountered: