Try Documentalist, my app that offers fast, offline access to 190+ programmer API docs.

  • sanitizers
    • address sanitizer (memory corruptions), 2x slowdown
      Compile with: -O1 -g -fsanitize=address -fno-omit-frame-pointer
      Add -fno-optimize-sibling-calls for better callstacks
      Link with: -g -fsanitize=address
      • testing sanitizer is enabled
        It's good to verify that sanitizer is enabled and working. Add this snippet of code and call it from your code. It should trigger sanitizer
        void trigger_address_sanitizer() {
          char *a = (char*)malloc(4);
          char c = a[5]; /* this line should trigger sanitizer */
          printf("c: %d\n", (int)c);
          free((void*)a);
        }
  • on mac
    brew install llvm installs latest version (currently 5.0).
    To not conflict with XCode, binaries are in /usr/local/Cellar/llvm/5.0.0/bin/` e..g. /usr/local/Cellar/llvm/5.0.0/bin/clang
  • misc
    http://stackoverflow.com/questions/28203937/installing-llvm-libraries-along-with-xcode
    http://llvm.org/releases/3.8.0/tools/clang/docs/
    https://github.com/tpoechtrager/wclang - allows cross-compiling Windows code on Linux using clang wrapper
    http://eli.thegreenplace.net/2014/05/01/modern-source-to-source-transformation-with-clang-and-libtooling/
    http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/
    http://www.seethroughskin.com/blog/clang-ast-parsing-for-automated-code-generation/
    http://www.seethroughskin.com/blog/simplified-clang-python-bindings/
    http://seanhn.wordpress.com/2012/07/10/better-interpreter-fuzzing-with-clang/
    http://eli.thegreenplace.net/2014/07/29/ast-matchers-and-clang-refactoring-tools
    
    https://github.com/jeaye/color_coded
    https://github.com/Neopallium/lua-clang-cindex - luajit bindings
    https://github.com/llvm-mirror/clang/tree/master/bindings/python
    https://github.com/indygreg/clanalyze/
    https://github.com/sbinet/go-clang
    
    https://github.com/mjsabby/ClangSharp, http://www.clangsharp.org/
    https://github.com/SimonRichards/clang-sharp, https://github.com/SimonRichards/ClassMirror
    
    http://blog.quarkslab.com/clang-hardening-cheat-sheet.html
    
    ASAN:
    https://gist.github.com/kwk/4171e37f4bcdf7705329
    http://btorpey.github.io/blog/2014/03/27/using-clangs-address-sanitizer/
    
    
    https://alastairs-place.net/blog/2016/05/20/code-coverage-from-the-command-line-with-clang/
    
    On mac:
    
    brew install llvm --with-clang --with-clang-extra-tool --with-compiler-rt --with-libcxx --with-lld --with-lld --with-python --with-rtti --with-utils --HEAD
    
    
    /usr/local/opt/llvm/bin/clang
    
    mkdir -p ~/Library/Python/2.7/lib/python/site-packages
    echo '/usr/local/opt/llvm/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
    
    LD_LIBRARY_PATH=/usr/local/opt/llvm/lib ~/src/pyclang/cindex-dump.py draw_flood.c
    
    In each *.py tool:
        from clang.cindex import Config
        Config.set_library_path(LLVM_LIB_DIR)
    
    -std=c++11
    -std=gnu++11
    -Weverything
    -Wall
    
    -stdlib=libc++  : use clang's C++ library (as opposed to OS's libstdc++)

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:

Share on        

Need fast, offline access to 190+ programmer API docs? Try my app Documentalist for Windows