diff --git a/doc/cn/Developer_Guide.md b/doc/cn/Developer_Guide.md index 7a07e51494a21f4d866e878f9801d61db8903751..ef8afa20398dad90c7b92c309860749dffc91d36 100644 --- a/doc/cn/Developer_Guide.md +++ b/doc/cn/Developer_Guide.md @@ -71,11 +71,11 @@ make 静态源码检查之前,需要先编译出OpenArkCompiler。此后,以检查src/maple_driver源码为例,在openarkcompiler目录下执行以下命令: ``` -cp out/compile_commands.json ./ +cp output/compile_commands.json ./ ./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/share/clang/run-clang-tidy.py -clang-tidy-binary='./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-tidy' -clang-apply-replacements-binary='./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-apply-replacements' src/maple_driver/ ``` 命令说明: -- `cp out/compile_commands.json ./` 将out目录之下的compile_commands.json复制到当前目录之下,它是clang-tidy运行所需要的编译命令; +- `cp output/compile_commands.json ./` 将output目录之下的compile_commands.json复制到当前目录之下,它是clang-tidy运行所需要的编译命令; - `./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/share/clang/run-clang-tidy.py` 调用clang-tidy进行批量检查的脚本run-clang-tidy.py,其中 `./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/`目录是之前配置的clang编译器的发行包主目录; `-clang-tidy-binary` 是指明clang-tidy的具体位置; `-clang-apply-replacements-binary` 是指明run-clang-tidy.py所依赖的clang-apply-replacements的位置; `src/maple_driver/` 是要进行源码检查的目录。 diff --git a/doc/en/Developer_Guide.md b/doc/en/Developer_Guide.md index b366eb323d9d7b7a16785193b5725aaaa8a44871..569757600e48d20d57270195b89e37d69cd0fffd 100644 --- a/doc/en/Developer_Guide.md +++ b/doc/en/Developer_Guide.md @@ -1,6 +1,6 @@ # Developer Guide -By referring to this document, you can download the OpenArkCompiler source code to compile it. +By referring to this document, you can download the OpenArkCompiler source code to compile it. At the same time, this document also provide the guide of static code analysis to developers. ## Prerequisites @@ -64,3 +64,19 @@ make cd samples/helloworld/ make ``` + +## Static code analysis + +This part will guide you to do the static code analysis by using the clang-tidy. After the code is changed, the static code analysis will check the coding specifications to improve the code quality. + +Before the static code analysis, we need compiled the OpenArkCompiler. After that, using the code of src/maple_driver as the tested directory, run the following commands in the openarkcompiler directory: + +``` +cp output/compile_commands.json ./ +./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/share/clang/run-clang-tidy.py -clang-tidy-binary='./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-tidy' -clang-apply-replacements-binary='./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-apply-replacements' src/maple_driver/ +``` +Command description: + +- `cp output/compile_commands.json ./`: Copy the compile_commands.json in the output directory to the openarkcompiler directory, it is required by the clang-tidy, it contains the compile commands of OpenArkCompiler. + +- `./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/share/clang/run-clang-tidy.py`: Call the run-clang-tidy.py which is the parallel clang-tidy runner. The `./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/` directory is the directory of the release package of clang compiler. The `-clang-tidy-binary` set the path of clang-tidy binary. The `-clang-apply-replacements-binary` set the path of the clang-apply-replacements binary which is requried by the run-clang-tidy.py. The `src/maple_driver/` is the tested code directory.