Analysis may break compilation when project adds includes with -isystem
Describe the bug
One of the projects I work with uses a custom Boost version, as the version installed by the operating system is ancient. This custom version is included by adding the custom path with the -isystem directive, as including it with -I causes the compiler to issue warnings for Boost, which is obviously undesirable.
Unfortunately, the consequence is that the order of include directives for the compiler starts to matter. From what I can see, CodeChecker prepends implicit compiler header directories with -isystem before other compiler flags (here and here, for example)
Thus, we end up with a command like like ... -isystem /usr/include ... -isystem path/to/custom/boost/include ... file.cpp. When file.cpp includes the boost header with #include <boost/...hpp>, instead of finding the custom version, it will now find the version in /usr/include, and compilation/analysis will fail.
My impression is that compilers usually add their implicit include directories at the end of the search path, as regular compilation never picks up the system Boost version.
My suggestion would be either adding the compiler include paths after all user includes, or using -idirafter instead of -isystem. According to the documentation of GCC, which seems to apply to Clang as well, -idirafter directories are treated like -isystem directories for all purposes, but are only searched after them.
CodeChecker version 6.19.0 (26f7f42e9aec90953194cc6c0252dcd10ac8aa0a)
To Reproduce Steps to reproduce the behaviour:
- Add empty header file
string.hto subdirectorytest, define empty function within:inline void a() {}. Add directorytestto include path with-isystem test - In test file test.cpp, add
#include <string.h>and calla(). - Regular compilation succeeds:
clang++ -isystem test test.cpp - Trying to analyze
test.cppwith CodeChecker fails, because the system version ofstring.his found first.
Expected behaviour Files that compile within their regular project environments should also compile when analyzed with CodeChecker.
Desktop (please complete the following information)
- OS: Linux (CentOS 7)
- Browser: not applicable
- Version: not applicable