diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-12-15 21:10:51 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-12-15 21:10:51 +0000 |
commit | 7ac0cc3698f2a2ee2b10219d9e5dc3f119152f93 (patch) | |
tree | b826f8a6c1eb04d18a9645f49883cf277721572f /clang/docs/HowToSetupToolingForLLVM.rst | |
parent | d9d26072d6458924176664c21c4b4c752588f4fa (diff) | |
download | bcm5719-llvm-7ac0cc3698f2a2ee2b10219d9e5dc3f119152f93.tar.gz bcm5719-llvm-7ac0cc3698f2a2ee2b10219d9e5dc3f119152f93.zip |
Documentation: random cleanups. Use monospaced font where appropriate,
highlight console output with "code-block:: console", etc.
llvm-svn: 170276
Diffstat (limited to 'clang/docs/HowToSetupToolingForLLVM.rst')
-rw-r--r-- | clang/docs/HowToSetupToolingForLLVM.rst | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/clang/docs/HowToSetupToolingForLLVM.rst b/clang/docs/HowToSetupToolingForLLVM.rst index 0c4cccafca5..70685f33943 100644 --- a/clang/docs/HowToSetupToolingForLLVM.rst +++ b/clang/docs/HowToSetupToolingForLLVM.rst @@ -28,45 +28,44 @@ later installed (can be found `here <http://cmake.org>`_). First, you need to generate Makefiles for LLVM with CMake. You need to make a build directory and run CMake from it: -:: +.. code-block:: console - mkdir your/build/directory - cd your/build/directory - cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON path/to/llvm/sources + $ mkdir your/build/directory + $ cd your/build/directory + $ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON path/to/llvm/sources If you want to use clang instead of GCC, you can add -``-DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++``. -You can also use ccmake, which provides a curses interface to configure +``-DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++``. +You can also use ``ccmake``, which provides a curses interface to configure CMake variables for lazy people. As a result, the new ``compile_commands.json`` file should appear in the current directory. You should link it to the LLVM source tree so that Clang Tooling is able to use it: -:: +.. code-block:: console - ln -s $PWD/compile_commands.json path/to/llvm/source/ + $ ln -s $PWD/compile_commands.json path/to/llvm/source/ Now you are ready to build and test LLVM using make: -:: +.. code-block:: console - make check-all + $ make check-all Using Clang Tools ================= -After you completed the previous steps, you are ready to run clang -tools. If you have a recent clang installed, you should have -``clang-check`` in $PATH. Try to run it on any .cpp file inside the LLVM -source tree: +After you completed the previous steps, you are ready to run clang tools. If +you have a recent clang installed, you should have ``clang-check`` in +``$PATH``. Try to run it on any ``.cpp`` file inside the LLVM source tree: -:: +.. code-block:: console - clang-check tools/clang/lib/Tooling/CompilationDatabase.cpp + $ clang-check tools/clang/lib/Tooling/CompilationDatabase.cpp If you're using vim, it's convenient to have clang-check integrated. Put -this into your .vimrc: +this into your ``.vimrc``: :: @@ -106,39 +105,39 @@ automatically when clang-check finds errors, and can be re-opened with Other ``clang-check`` options that can be useful when working with clang AST: -- ``-ast-print`` - Build ASTs and then pretty-print them. -- ``-ast-dump`` - Build ASTs and then debug dump them. -- ``-ast-dump-filter=<string>`` - Use with ``-ast-dump`` or - ``-ast-print`` to dump/print only AST declaration nodes having a - certain substring in a qualified name. Use ``-ast-list`` to list all - filterable declaration node names. -- ``-ast-list`` - Build ASTs and print the list of declaration node - qualified names. +* ``-ast-print`` --- Build ASTs and then pretty-print them. +* ``-ast-dump`` --- Build ASTs and then debug dump them. +* ``-ast-dump-filter=<string>`` --- Use with ``-ast-dump`` or ``-ast-print`` to + dump/print only AST declaration nodes having a certain substring in a + qualified name. Use ``-ast-list`` to list all filterable declaration node + names. +* ``-ast-list`` --- Build ASTs and print the list of declaration node qualified + names. Examples: -:: - - $ clang-check tools/clang/tools/clang-check/ClangCheck.cpp -ast-dump -ast-dump-filter ActionFactory::newASTConsumer - Processing: tools/clang/tools/clang-check/ClangCheck.cpp. - Dumping ::ActionFactory::newASTConsumer: - clang::ASTConsumer *newASTConsumer() (CompoundStmt 0x44da290 </home/alexfh/local/llvm/tools/clang/tools/clang-check/ClangCheck.cpp:64:40, line:72:3> - (IfStmt 0x44d97c8 <line:65:5, line:66:45> - <<<NULL>>> - (ImplicitCastExpr 0x44d96d0 <line:65:9> '_Bool':'_Bool' <UserDefinedConversion> - ... - $ clang-check tools/clang/tools/clang-check/ClangCheck.cpp -ast-print -ast-dump-filter ActionFactory::newASTConsumer - Processing: tools/clang/tools/clang-check/ClangCheck.cpp. - Printing <anonymous namespace>::ActionFactory::newASTConsumer: - clang::ASTConsumer *newASTConsumer() { - if (this->ASTList.operator _Bool()) - return clang::CreateASTDeclNodeLister(); - if (this->ASTDump.operator _Bool()) - return clang::CreateASTDumper(this->ASTDumpFilter); - if (this->ASTPrint.operator _Bool()) - return clang::CreateASTPrinter(&llvm::outs(), this->ASTDumpFilter); - return new clang::ASTConsumer(); - } +.. code-block:: console + + $ clang-check tools/clang/tools/clang-check/ClangCheck.cpp -ast-dump -ast-dump-filter ActionFactory::newASTConsumer + Processing: tools/clang/tools/clang-check/ClangCheck.cpp. + Dumping ::ActionFactory::newASTConsumer: + clang::ASTConsumer *newASTConsumer() (CompoundStmt 0x44da290 </home/alexfh/local/llvm/tools/clang/tools/clang-check/ClangCheck.cpp:64:40, line:72:3> + (IfStmt 0x44d97c8 <line:65:5, line:66:45> + <<<NULL>>> + (ImplicitCastExpr 0x44d96d0 <line:65:9> '_Bool':'_Bool' <UserDefinedConversion> + ... + $ clang-check tools/clang/tools/clang-check/ClangCheck.cpp -ast-print -ast-dump-filter ActionFactory::newASTConsumer + Processing: tools/clang/tools/clang-check/ClangCheck.cpp. + Printing <anonymous namespace>::ActionFactory::newASTConsumer: + clang::ASTConsumer *newASTConsumer() { + if (this->ASTList.operator _Bool()) + return clang::CreateASTDeclNodeLister(); + if (this->ASTDump.operator _Bool()) + return clang::CreateASTDumper(this->ASTDumpFilter); + if (this->ASTPrint.operator _Bool()) + return clang::CreateASTPrinter(&llvm::outs(), this->ASTDumpFilter); + return new clang::ASTConsumer(); + } (Experimental) Using Ninja Build System ======================================= @@ -153,59 +152,60 @@ at least CMake 2.8.9. At the moment CMake 2.8.9 is still under development, so you can get latest development sources and build it yourself: -:: +.. code-block:: console - git clone git://cmake.org/cmake.git - cd cmake - ./bootstrap - make - sudo make install + $ git clone git://cmake.org/cmake.git + $ cd cmake + $ ./bootstrap + $ make + $ sudo make install Having the correct version of CMake, you can clone the Ninja git repository and build Ninja from sources: -:: +.. code-block:: console - git clone git://github.com/martine/ninja.git - cd ninja/ - ./bootstrap.py + $ git clone git://github.com/martine/ninja.git + $ cd ninja/ + $ ./bootstrap.py This will result in a single binary ``ninja`` in the current directory. It doesn't require installation and can just be copied to any location inside ``$PATH``, say ``/usr/local/bin/``: -:: +.. code-block:: console - sudo cp ninja /usr/local/bin/ - sudo chmod a+rx /usr/local/bin/ninja + $ sudo cp ninja /usr/local/bin/ + $ sudo chmod a+rx /usr/local/bin/ninja After doing all of this, you'll need to generate Ninja build files for LLVM with CMake. You need to make a build directory and run CMake from it: -:: +.. code-block:: console - mkdir your/build/directory - cd your/build/directory - cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON path/to/llvm/sources + $ mkdir your/build/directory + $ cd your/build/directory + $ cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON path/to/llvm/sources If you want to use clang instead of GCC, you can add -``-DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++``. -You can also use ccmake, which provides a curses interface to configure +``-DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++``. +You can also use ``ccmake``, which provides a curses interface to configure CMake variables in an interactive manner. As a result, the new ``compile_commands.json`` file should appear in the current directory. You should link it to the LLVM source tree so that Clang Tooling is able to use it: -:: +.. code-block:: console - ln -s $PWD/compile_commands.json path/to/llvm/source/ + $ ln -s $PWD/compile_commands.json path/to/llvm/source/ Now you are ready to build and test LLVM using Ninja: -:: +.. code-block:: console - ninja check-all + $ ninja check-all Other target names can be used in the same way as with make. + |