1*f4a2713aSLionel Sambuc========== 2*f4a2713aSLionel SambucClangCheck 3*f4a2713aSLionel Sambuc========== 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc`ClangCheck` is a small wrapper around :doc:`LibTooling` which can be used to 6*f4a2713aSLionel Sambucdo basic error checking and AST dumping. 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc.. code-block:: console 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuc $ cat <<EOF > snippet.cc 11*f4a2713aSLionel Sambuc > void f() { 12*f4a2713aSLionel Sambuc > int a = 0 13*f4a2713aSLionel Sambuc > } 14*f4a2713aSLionel Sambuc > EOF 15*f4a2713aSLionel Sambuc $ ~/clang/build/bin/clang-check snippet.cc -ast-dump -- 16*f4a2713aSLionel Sambuc Processing: /Users/danieljasper/clang/llvm/tools/clang/docs/snippet.cc. 17*f4a2713aSLionel Sambuc /Users/danieljasper/clang/llvm/tools/clang/docs/snippet.cc:2:12: error: expected ';' at end of 18*f4a2713aSLionel Sambuc declaration 19*f4a2713aSLionel Sambuc int a = 0 20*f4a2713aSLionel Sambuc ^ 21*f4a2713aSLionel Sambuc ; 22*f4a2713aSLionel Sambuc (TranslationUnitDecl 0x7ff3a3029ed0 <<invalid sloc>> 23*f4a2713aSLionel Sambuc (TypedefDecl 0x7ff3a302a410 <<invalid sloc>> __int128_t '__int128') 24*f4a2713aSLionel Sambuc (TypedefDecl 0x7ff3a302a470 <<invalid sloc>> __uint128_t 'unsigned __int128') 25*f4a2713aSLionel Sambuc (TypedefDecl 0x7ff3a302a830 <<invalid sloc>> __builtin_va_list '__va_list_tag [1]') 26*f4a2713aSLionel Sambuc (FunctionDecl 0x7ff3a302a8d0 </Users/danieljasper/clang/llvm/tools/clang/docs/snippet.cc:1:1, line:3:1> f 'void (void)' 27*f4a2713aSLionel Sambuc (CompoundStmt 0x7ff3a302aa10 <line:1:10, line:3:1> 28*f4a2713aSLionel Sambuc (DeclStmt 0x7ff3a302a9f8 <line:2:3, line:3:1> 29*f4a2713aSLionel Sambuc (VarDecl 0x7ff3a302a980 <line:2:3, col:11> a 'int' 30*f4a2713aSLionel Sambuc (IntegerLiteral 0x7ff3a302a9d8 <col:11> 'int' 0)))))) 31*f4a2713aSLionel Sambuc 1 error generated. 32*f4a2713aSLionel Sambuc Error while processing snippet.cc. 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel SambucThe '--' at the end is important as it prevents `clang-check` from search for a 35*f4a2713aSLionel Sambuccompilation database. For more information on how to setup and use `clang-check` 36*f4a2713aSLionel Sambucin a project, see :doc:`HowToSetupToolingForLLVM`. 37