OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This implements a Clang tool to convert all instances of std::string("") to | 5 // This implements a Clang tool to convert all instances of std::string("") to |
6 // std::string(). The latter is more efficient (as std::string doesn't have to | 6 // std::string(). The latter is more efficient (as std::string doesn't have to |
7 // take a copy of an empty string) and generates fewer instructions as well. It | 7 // take a copy of an empty string) and generates fewer instructions as well. It |
8 // should be run using the tools/clang/scripts/run_tool.py helper. | 8 // should be run using the tools/clang/scripts/run_tool.py helper. |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 // Each replacement line should have the following format: | 190 // Each replacement line should have the following format: |
191 // r:<file path>:<offset>:<length>:<replacement text> | 191 // r:<file path>:<offset>:<length>:<replacement text> |
192 // Only the <replacement text> field can contain embedded ":" characters. | 192 // Only the <replacement text> field can contain embedded ":" characters. |
193 // TODO(dcheng): Use a more clever serialization. Ideally we'd use the YAML | 193 // TODO(dcheng): Use a more clever serialization. Ideally we'd use the YAML |
194 // serialization and then use clang-apply-replacements, but that would require | 194 // serialization and then use clang-apply-replacements, but that would require |
195 // copying and pasting a larger amount of boilerplate for all Chrome clang | 195 // copying and pasting a larger amount of boilerplate for all Chrome clang |
196 // tools. | 196 // tools. |
197 llvm::outs() << "==== BEGIN EDITS ====\n"; | 197 llvm::outs() << "==== BEGIN EDITS ====\n"; |
198 for (const auto& r : replacements) { | 198 for (const auto& r : replacements) { |
199 llvm::outs() << "r:" << r.getFilePath() << ":" << r.getOffset() << ":" | 199 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() << ":::" |
200 << r.getLength() << ":" << r.getReplacementText() << "\n"; | 200 << r.getLength() << ":::" << r.getReplacementText() << "\n"; |
201 } | 201 } |
202 llvm::outs() << "==== END EDITS ====\n"; | 202 llvm::outs() << "==== END EDITS ====\n"; |
203 | 203 |
204 return 0; | 204 return 0; |
205 } | 205 } |
OLD | NEW |