I was trying to use scan-build with cmake.
Following scan-build make
after scan-build cmake
.
But when using scan-build, it is identifying CXX compiler as GNU 9.1.0. But if we don't use scan-build it properly identify CXX as clang. Because of CXX compiler identified as GNU 9.1.0, checks for some diagnostic flags in clang (eg, Wunreachable_code_break, Werror_range_loop_analysis
) are getting failed.
Output, while using scan-build:
scan-build: Using '../clang/9.0.0/bin/clang-9' for static analysis
-- The CXX compiler identification is GNU 9.1.0
-- Check for working CXX compiler: ../clang/9.0.0/libexec/c++-analyzer
-- Check for working CXX compiler: ../clang/9.0.0/libexec/c++-analyzer -- works
Output, without scan-build:
-- The CXX compiler identification is Clang 9.0.0
-- Check for working CXX compiler: ../clang/9.0.0/bin/clang++
-- Check for working CXX compiler: ../clang/9.0.0/bin/clang++ -- works
How to make sure scan-build have to identify clang as CXX compiler?