Skip to content

Instantly share code, notes, and snippets.

@Miliox
Last active August 29, 2015 14:13
Show Gist options
  • Save Miliox/9e58b68650cc38b94ed7 to your computer and use it in GitHub Desktop.
Save Miliox/9e58b68650cc38b94ed7 to your computer and use it in GitHub Desktop.

oclint 0.9 / [stackoverflow]

mkdir build; cd build
scan-build cmake ..

....

oclint-json-compilation-database -v oclint_args \
  "-allow-duplicated-violations -enable-clang-static-analyzer \
  -enable-global-analysis -list-enabled-rules \
  -report-type html -o oclint_result.html -p ."

oclint-json-compilation-database -v -- \
  -allow-duplicated-violations -enable-clang-static-analyzer \
  -enable-global-analysis -list-enabled-rules \
  -report-type html -o oclint_result.html -p .

oclint -allow-duplicated-violations -enable-clang-static-analyzer \
  -enable-global-analysis -list-enabled-rules \
  -report-type html -o oclint_result.html -p .

clang-modernizer

mkdir build; cd build
scan-build cmake ..
clang-modernize-3.5 -add-override -override-macros -use-nullptr \
     -loop-convert -for-compilers=clang-3.4,gcc-4.8 -risk=risky \
     -summary -exclude ../third-party -p . -include ..

clang-format

clang-format -style=[llvm|google|mozilla|webkit|chromium] path/fil

git diff -U0 master | clang-format-diff-3.5 -style LLVM

scan-build [download]

mkdir build; cd build
scan-build cmake ..
scan-build \
    -enable-checker alpha.deadcode.UnreachableCode -enable-checker alpha.core.SizeofPtr \
    -enable-checker alpha.cplusplus.NewDeleteLeaks \
    --override-compiler --use-analyzer=/usr/local/Cellar/llvm35/HEAD/bin
    -k -V -o report make -j4

P.S. http://polly.llvm.org/example_load_Polly_into_clang.html

Analyze #includes in C and C++ source files

Other:

#!/bin/sh
# Script generate cmake database (MacOSX 10.10 Yosemite)
#
# Analyzer Fuzzer tools attack application stability & security
# Fuzzer
# https://code.google.com/p/tmin/
# https://code.google.com/p/american-fuzzy-lop/
#
# ninja: cmake -G Ninja . ; ninja -j4 ; ninja install
# -DCMAKE_BUILD_TYPE=Debug|Release|RelWithDebInfo|MinSizeRel: Sets build type : Default: Release
# -DENABLE_ZEND_COMPAT=ON|OFF : Enable Zend source compatibility : Default: ON
# -DALWAYS_ASSERT=ON|OFF : Enabled asserts in a release build : Default: OFF
# -DDEBUG_APC_LEAK=ON|OFF : Allow easier debugging of apc leaks : Default: OFF
# -DDEBUG_MEMORY_LEAK=ON|OFF : Allow easier debugging of memory leaks : Default: OFF
# -DDISABLE_HARDWARE_COUNTERS=ON|OFF : Disable hardware counters (for XenU systems) : Default: OFF
# -DENABLE_COTIRE=ON|OFF : Speed up the build by precompiling headers : Default: OFF
# -DENABLE_FULL_SETLINE=ON|OFF : Enable full setline function for debugger and code-coverage : Default: OFF
# -DENABLE_TRACE=ON|OFF : Enable tracing in release build : Default: OFF
# -DEXECUTION_PROFILER=ON|OFF : Enable the execution profiler : Default: OFF
# -DHOTPROFILER=ON|OFF : Enable support for the hot-profiler : Default: OFF
# -DPACKED_TV=ON|OFF : Enable packed tv (typed value) compilation : Default: OFF
# -DUSE_GOOGLE_CPU_PROFILER=ON|OFF : Use Google cpu profiler : Default: OFF
# -DUSE_GOOGLE_HEAP_PROFILER=ON|OFF : Use Google heap profiler : Default: OFF
# -DUSE_JEMALLOC=ON|OFF : Use jemalloc : Default: ON
# -DUSE_TCMALLOC=ON|OFF : Use tcmalloc (if jemalloc is not used) : Default: ON
# Generate [cmake + ninja] -> compile_commands.json
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER=/usr/local/bin/g++-4.9 \
-DCMAKE_C_COMPILER=/usr/local/bin/gcc-4.9 \
-DCMAKE_ASM_COMPILER=/usr/local/bin/gcc-4.9 \
-DCMAKE_BUILD_TYPE=Debug \
-DLIBIBERTY_LIB=/usr/local/opt/binutilsfb/lib/x86_64/libiberty.a \
-DCMAKE_INCLUDE_PATH="/usr/local/include:/usr/include" \
-DCMAKE_LIBRARY_PATH="/usr/local/lib:/usr/lib" \
-DLIBEVENT_LIB=/usr/local/opt/libevent/lib/libevent.dylib \
-DLIBEVENT_INCLUDE_DIR=/usr/local/opt/libevent/include \
-DICU_INCLUDE_DIR=/usr/local/opt/icu4c/include \
-DICU_LIBRARY=/usr/local/opt/icu4c/lib/libicuuc.dylib \
-DICU_I18N_LIBRARY=/usr/local/opt/icu4c/lib/libicui18n.dylib \
-DICU_DATA_LIBRARY=/usr/local/opt/icu4c/lib/libicudata.dylib \
-DREADLINE_INCLUDE_DIR=/usr/local/opt/readline/include \
-DREADLINE_LIBRARY=/usr/local/opt/readline/lib/libreadline.dylib \
-DNCURSES_LIBRARY=/usr/local/opt/ncurses/lib/libncurses.dylib \
-DCURL_INCLUDE_DIR=/usr/local/opt/curl/include \
-DCURL_LIBRARY=/usr/local/opt/curl/lib/libcurl.dylib \
-DBOOST_INCLUDEDIR=/usr/local/opt/boostfb/include \
-DBOOST_LIBRARYDIR=/usr/local/opt/boostfb/lib \
-DBoost_USE_STATIC_LIBS=ON \
-DJEMALLOC_INCLUDE_DIR=/usr/local/opt/jemallocfb/include \
-DJEMALLOC_LIB=/usr/local/opt/jemallocfb/lib/libjemalloc.dylib \
-DLIBINTL_LIBRARIES=/usr/local/opt/gettext/lib/libintl.dylib \
-DLIBINTL_INCLUDE_DIR=/usr/local/opt/gettext/include \
-DLIBDWARF_LIBRARIES=/usr/local/opt/libdwarf/lib/libdwarf.3.dylib \
-DDWARF_INCLUDE_DIR=/usr/local/opt/libdwarf/include \
-DLIBELF_INCLUDE_DIRS=/usr/local/opt/libelf/include/libelf \
-DCMAKE_INCLUDE_PATH=/usr/local/opt/binutilsfb/include \
-DFBD_LIB=/usr/local/opt/binutilsfb/lib/libbfd.a \
-DBINUTIL_LIB=/usr/local/opt/binutilsfb/lib/libbfd.a \
-DCCLIENT_INCLUDE_PATH=/usr/local/opt/imap-uw/include/imap \
-DLIBGLOG_INCLUDE_DIR=/usr/local/opt/glog/include \
-DLIBJPEG_INCLUDE_DIRS=/usr/local/opt/jpeg/include \
-DLIBMEMCACHED_INCLUDE_DIR=/usr/local/opt/libmemcached/include \
-DLIBODBC_INCLUDE_DIRS=/usr/local/opt/unixodbc/include \
-DLIBPNG_INCLUDE_DIRS=/usr/local/opt/libpng/include \
-DMcrypt_INCLUDE_DIR=/usr/local/opt/mcrypt/include \
-DONIGURUMA_INCLUDE_DIR=/usr/local/opt/oniguruma/include \
-DPCRE_INCLUDE_DIR=/usr/local/opt/pcre/include \
-DTBB_INCLUDE_DIRS=/usr/local/opt/tbb/include \
-DTEST_TBB_INCLUDE_DIR=/usr/local/opt/tbb/include \
-DFREETYPE_INCLUDE_DIRS=/usr/local/opt/freetype/include/freetype2 \
-DLIBMAGICKWAND_INCLUDE_DIRS=/usr/local/opt/imagemagick/include/ImageMagick-6 \
-DLIBMAGICKWAND_LIBRARIES=/usr/local/opt/imagemagick/lib/libMagickWand-6.Q16.dylib \
-DMYSQL_INCLUDE_DIR=/usr/local/opt/mariadb/include/mysql \
-DMYSQL_LIB_DIR=/usr/local/opt/mariadb/lib \
-DCMAKE_INSTALL_PREFIX=. \
"."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment