OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Changes Blink-style names to Chrome-style names. Currently transforms: | 5 // Changes Blink-style names to Chrome-style names. Currently transforms: |
6 // fields: | 6 // fields: |
7 // int m_operationCount => int operation_count_ | 7 // int m_operationCount => int operation_count_ |
8 // variables (including parameters): | 8 // variables (including parameters): |
9 // int mySuperVariable => int my_super_variable | 9 // int mySuperVariable => int my_super_variable |
10 // constants: | 10 // constants: |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 return decl.getName() == "swap"; | 218 return decl.getName() == "swap"; |
219 } | 219 } |
220 | 220 |
221 bool IsBlacklistedMethod(const clang::CXXMethodDecl& decl) { | 221 bool IsBlacklistedMethod(const clang::CXXMethodDecl& decl) { |
222 if (decl.isStatic()) | 222 if (decl.isStatic()) |
223 return false; | 223 return false; |
224 | 224 |
225 clang::StringRef name = decl.getName(); | 225 clang::StringRef name = decl.getName(); |
226 | 226 |
227 // These methods should never be renamed. | 227 // These methods should never be renamed. |
228 static const char* kBlacklistMethods[] = {"trace", "traceImpl", "lock", | 228 static const char* kBlacklistMethods[] = {"trace", "traceImpl", "lock", |
229 "unlock", "try_lock"}; | 229 "unlock", "try_lock", "begin", |
| 230 "end", "rbegin", "rend"}; |
230 for (const auto& b : kBlacklistMethods) { | 231 for (const auto& b : kBlacklistMethods) { |
231 if (name == b) | 232 if (name == b) |
232 return true; | 233 return true; |
233 } | 234 } |
234 | 235 |
235 // Iterator methods shouldn't be renamed to work with stl and range-for | |
236 // loops. | |
237 std::string ret_type = decl.getReturnType().getAsString(); | |
238 if (ret_type.find("iterator") != std::string::npos || | |
239 ret_type.find("Iterator") != std::string::npos) { | |
240 static const char* kIteratorBlacklist[] = {"begin", "end", "rbegin", | |
241 "rend"}; | |
242 for (const auto& b : kIteratorBlacklist) { | |
243 if (name == b) | |
244 return true; | |
245 } | |
246 } | |
247 | |
248 // Subclasses of InspectorAgent will subclass "disable()" from both blink and | 236 // Subclasses of InspectorAgent will subclass "disable()" from both blink and |
249 // from gen/, which is problematic, but DevTools folks don't want to rename | 237 // from gen/, which is problematic, but DevTools folks don't want to rename |
250 // it or split this up. So don't rename it at all. | 238 // it or split this up. So don't rename it at all. |
251 if (name.equals("disable") && | 239 if (name.equals("disable") && |
252 IsMethodOverrideOf(decl, "blink::InspectorAgent")) | 240 IsMethodOverrideOf(decl, "blink::InspectorAgent")) |
253 return true; | 241 return true; |
254 | 242 |
255 return false; | 243 return false; |
256 } | 244 } |
257 | 245 |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 for (const auto& r : replacements) { | 1260 for (const auto& r : replacements) { |
1273 std::string replacement_text = r.getReplacementText().str(); | 1261 std::string replacement_text = r.getReplacementText().str(); |
1274 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); | 1262 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); |
1275 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() | 1263 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() |
1276 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; | 1264 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; |
1277 } | 1265 } |
1278 llvm::outs() << "==== END EDITS ====\n"; | 1266 llvm::outs() << "==== END EDITS ====\n"; |
1279 | 1267 |
1280 return 0; | 1268 return 0; |
1281 } | 1269 } |
OLD | NEW |