Skip to content

Instantly share code, notes, and snippets.

@estan
Created December 1, 2019 13:41

Revisions

  1. estan created this gist Dec 1, 2019.
    6 changes: 6 additions & 0 deletions CMakeLists.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    cmake_minimum_required(VERSION 3.10)
    project(tidytest)
    set(CMAKE_CXX_VERSION 17)
    add_executable(app app.cpp)
    unset(CMAKE_CXX_CLANG_TIDY)
    add_subdirectory(lib)
    2 changes: 2 additions & 0 deletions app.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    #include <cstdio>
    int main() { int *a; if (a == NULL) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
    1 change: 1 addition & 0 deletions lib-CMakeLists.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    add_library(lib STATIC lib.cpp)
    2 changes: 2 additions & 0 deletions lib-lib.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    #include <cstdio>
    int foo() { int *a; if (a == NULL) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
    48 changes: 48 additions & 0 deletions result.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    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
    [ 25%] Building CXX object CMakeFiles/app.dir/app.cpp.o
    /home/estan/tidytest/app.cpp:2:28: warning: The left operand of '==' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
    int main() { int *a; if (a == NULL) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
    ^
    /home/estan/tidytest/app.cpp:2:14: note: 'a' declared without an initial value
    int main() { int *a; if (a == NULL) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
    ^
    /home/estan/tidytest/app.cpp:2:28: note: The left operand of '==' is a garbage value
    int main() { int *a; if (a == NULL) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
    ^
    [ 50%] Linking CXX executable app
    [ 50%] Built target app
    Scanning dependencies of target lib
    [ 75%] Building CXX object lib/CMakeFiles/lib.dir/lib.cpp.o
    /home/estan/tidytest/lib/lib.cpp:2:27: warning: The left operand of '==' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
    int foo() { int *a; if (a == NULL) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
    ^
    /home/estan/tidytest/lib/lib.cpp:2:13: note: 'a' declared without an initial value
    int foo() { int *a; if (a == NULL) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
    ^
    /home/estan/tidytest/lib/lib.cpp:2:27: note: The left operand of '==' is a garbage value
    int foo() { int *a; if (a == NULL) return 0; return 1; } // clang-analyzer-core.UndefinedBinaryOperatorResult
    ^
    [100%] Linking CXX static library liblib.a
    [100%] Built target lib
    estan@edison:~/tidytest/build$