Skip to content

Instantly share code, notes, and snippets.

@estan
Created December 1, 2019 13:16
Show Gist options
  • Save estan/a95cab6258a53691521a96a32d923758 to your computer and use it in GitHub Desktop.
Save estan/a95cab6258a53691521a96a32d923758 to your computer and use it in GitHub Desktop.
Unsetting CMAKE_CXX_CLANG_TIDY test case
int main() { int *a; if (a == 0) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
cmake_minimum_required(VERSION 3.10)
project(tidytest)
set(CMAKE_CXX_VERSION 17)
unset(CMAKE_CXX_CLANG_TIDY)
add_executable(app app.cpp)
estan@edison:~/tidytest$ mkdir build
estan@edison:~/tidytest$ cd build/
estan@edison:~/tidytest/build$ cmake -DCMAKE_CXX_CLANG_TIDY=clang-tidy-8 ..
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/estan/tidytest/build
estan@edison:~/tidytest/build$ make
Scanning dependencies of target app
[ 50%] Building CXX object CMakeFiles/app.dir/app.cpp.o
/home/estan/tidytest/app.cpp:1:28: warning: The left operand of '==' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
int main() { int *a; if (a == 0) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
^
/home/estan/tidytest/app.cpp:1:14: note: 'a' declared without an initial value
int main() { int *a; if (a == 0) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
^
/home/estan/tidytest/app.cpp:1:28: note: The left operand of '==' is a garbage value
int main() { int *a; if (a == 0) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
^
[100%] Linking CXX executable app
[100%] Built target app
estan@edison:~/tidytest/build$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment