Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: docs/clang_tool_refactoring.md

Issue 2596383002: Update Windows-specific docs for the clang rewriting tool. (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Clang Tool Refactoring 1 # Clang Tool Refactoring
2 2
3 [TOC] 3 [TOC]
4 4
5 ## Introduction 5 ## Introduction
6 6
7 Clang tools can help with global refactorings of Chromium code. Clang tools can 7 Clang tools can help with global refactorings of Chromium code. Clang tools can
8 take advantage of clang's AST to perform refactorings that would be impossible 8 take advantage of clang's AST to perform refactorings that would be impossible
9 with a traditional find-and-replace regexp: 9 with a traditional find-and-replace regexp:
10 10
11 * Constructing `scoped_ptr<T>` from `NULL`: <https://crbug.com/173286> 11 * Constructing `scoped_ptr<T>` from `NULL`: <https://crbug.com/173286>
12 * Implicit conversions of `scoped_refptr<T>` to `T*`: <https://crbug.com/11061 0> 12 * Implicit conversions of `scoped_refptr<T>` to `T*`: <https://crbug.com/11061 0>
13 * Rename everything in Blink to follow Chromium style: <https://crbug.com/5637 93> 13 * Rename everything in Blink to follow Chromium style: <https://crbug.com/5637 93>
14 14
15 ## Caveats 15 ## Caveats
16 16
17 An invocation of the clang tool runs on one build config. Code that only 17 An invocation of the clang tool runs on one build config. Code that only
18 compiles on one platform or code that is guarded by a set of compile-time flags 18 compiles on one platform or code that is guarded by a set of compile-time flags
19 can be problematic. Performing a global refactoring typically requires running 19 can be problematic. Performing a global refactoring typically requires running
20 the tool once in each build config with code that needs to be updated. 20 the tool once in each build config with code that needs to be updated.
21 21
22 Other minor issues: 22 Other minor issues:
23 23
24 * Requires a git checkout. 24 * Requires a git checkout.
25 * Requires [some hacks to run on Windows](https://codereview.chromium.org/7188 73004).
26 25
27 ## Prerequisites 26 ## Prerequisites
28 27
29 A Chromium checkout created with `fetch` should have everything needed. 28 A Chromium checkout created with `fetch` should have everything needed.
30 29
31 For convenience, add `third_party/llvm-build/Release+Asserts/bin` to `$PATH`. 30 For convenience, add `third_party/llvm-build/Release+Asserts/bin` to `$PATH`.
32 31
33 ## Writing the tool 32 ## Writing the tool
34 33
35 LLVM uses C++11 and CMake. Source code for Chromium clang tools lives in 34 LLVM uses C++11 and CMake. Source code for Chromium clang tools lives in
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 Generally, `--tools` should always include `blink_gc_plugin` and `plugins`: othe rwise, Chromium won't build. 109 Generally, `--tools` should always include `blink_gc_plugin` and `plugins`: othe rwise, Chromium won't build.
111 110
112 It is important to use --bootstrap as there appear to be [bugs](https://crbug.co m/580745) 111 It is important to use --bootstrap as there appear to be [bugs](https://crbug.co m/580745)
113 in the clang library this script produces if you build it with gcc, which is the default. 112 in the clang library this script produces if you build it with gcc, which is the default.
114 113
115 ## Running 114 ## Running
116 First, build all Chromium targets to avoid failures due to missing dependencies 115 First, build all Chromium targets to avoid failures due to missing dependencies
117 that are generated as part of the build: 116 that are generated as part of the build:
118 117
119 ```shell 118 ```shell
120 ninja -C out/Debug 119 ninja -C out/Debug # For non-Windows
120 ninja -d keeprsp -C out/Debug # For Windows
121 ``` 121 ```
122 122
123 Then run the actual tool: 123 Then run the actual tool:
124 124
125 ```shell 125 ```shell
126 tools/clang/scripts/run_tool.py <toolname> \ 126 tools/clang/scripts/run_tool.py <toolname> \
127 --generate-compdb 127 --generate-compdb
128 out/Debug <path 1> <path 2> ... 128 out/Debug <path 1> <path 2> ...
129 ``` 129 ```
130 130
131 `--generate-compdb` can be omitted if the compile DB was already generated and 131 `--generate-compdb` can be omitted if the compile DB was already generated and
132 the list of build flags and source files has not changed since generation. 132 the list of build flags and source files has not changed since generation. NOTE:
133 On windows to avoid this flag, you must also run the
dcheng 2016/12/22 21:31:46 Nit: NOTE: On Windows, use generate_win_compdb.py
134 `tools/clang/scripts/generate_win_compdb.py` script after generating the compdb.
133 135
134 `<path 1>`, `<path 2>`, etc are optional arguments to filter the files to run 136 `<path 1>`, `<path 2>`, etc are optional arguments to filter the files to run
135 the tool across. This is helpful when sharding global refactorings into smaller 137 the tool across. This is helpful when sharding global refactorings into smaller
136 chunks. For example, the following command will run the `empty_string` tool 138 chunks. For example, the following command will run the `empty_string` tool
137 across just the files in `//base`: 139 across just the files in `//base`:
138 140
139 ```shell 141 ```shell
140 tools/clang/scripts/run_tool.py empty_string \ 142 tools/clang/scripts/run_tool.py empty_string \
141 --generated-compdb \ 143 --generated-compdb \
142 out/Debug base 144 out/Debug base
(...skipping 30 matching lines...) Expand all
173 175
174 ```shell 176 ```shell
175 tools/clang/scripts/test_tool.py <tool name> 177 tools/clang/scripts/test_tool.py <tool name>
176 ``` 178 ```
177 179
178 The name of the tool binary and the subdirectory for the tool in 180 The name of the tool binary and the subdirectory for the tool in
179 `//tools/clang` must match. The test runner finds all files that match the 181 `//tools/clang` must match. The test runner finds all files that match the
180 pattern `//tools/clang/<tool name>/tests/*-original.cc`, runs the tool across 182 pattern `//tools/clang/<tool name>/tests/*-original.cc`, runs the tool across
181 those files, and compared it to the `*-expected.cc` version. If there is a 183 those files, and compared it to the `*-expected.cc` version. If there is a
182 mismatch, the result is saved in `*-actual.cc`. 184 mismatch, the result is saved in `*-actual.cc`.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698