Chromium Code Reviews| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 return false; | 207 return false; |
| 208 } | 208 } |
| 209 | 209 |
| 210 bool IsBlacklistedFunctionName(llvm::StringRef name) { | 210 bool IsBlacklistedFunctionName(llvm::StringRef name) { |
| 211 // https://crbug.com/672902: Method names with an underscore are typically | 211 // https://crbug.com/672902: Method names with an underscore are typically |
| 212 // mimicked after std library / are typically not originating from Blink. | 212 // mimicked after std library / are typically not originating from Blink. |
| 213 // Do not rewrite such names (like push_back, emplace_back, etc.). | 213 // Do not rewrite such names (like push_back, emplace_back, etc.). |
| 214 if (name.find('_') != llvm::StringRef::npos) | 214 if (name.find('_') != llvm::StringRef::npos) |
| 215 return true; | 215 return true; |
| 216 | 216 |
| 217 // https://crbug.com/677166: Have to avoid renaming |hash| -> |Hash| to avoid | 217 return false; |
| 218 // colliding with a struct already named |Hash|. | |
| 219 return name == "hash"; | |
| 220 } | 218 } |
| 221 | 219 |
| 222 bool IsBlacklistedFreeFunctionName(llvm::StringRef name) { | 220 bool IsBlacklistedFreeFunctionName(llvm::StringRef name) { |
| 223 // swap() functions should match the signature of std::swap for ADL tricks. | 221 // swap() functions should match the signature of std::swap for ADL tricks. |
| 224 return name == "swap"; | 222 return name == "swap"; |
| 225 } | 223 } |
| 226 | 224 |
| 227 bool IsBlacklistedInstanceMethodName(llvm::StringRef name) { | 225 bool IsBlacklistedInstanceMethodName(llvm::StringRef name) { |
| 228 static const char* kBlacklistedNames[] = { | 226 static const char* kBlacklistedNames[] = { |
| 229 // We should avoid renaming the method names listed below, because | 227 // We should avoid renaming the method names listed below, because |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 "fileUtilities", | 375 "fileUtilities", |
| 378 "font", | 376 "font", |
| 379 "frame", | 377 "frame", |
| 380 "frameBlameContext", | 378 "frameBlameContext", |
| 381 "iconURL", | 379 "iconURL", |
| 382 "inputMethodController", | 380 "inputMethodController", |
| 383 "inputType", | 381 "inputType", |
| 384 "layout", | 382 "layout", |
| 385 "layoutBlock", | 383 "layoutBlock", |
| 386 "layoutObject", | 384 "layoutObject", |
| 387 "layoutSize", | 385 "layoutSize", |
|
Łukasz Anforowicz
2017/01/04 17:12:46
We need to add "hash" here, to force renaming into
nasko
2017/01/04 17:22:52
Done.
| |
| 388 "length", | 386 "length", |
| 389 "lineCap", | 387 "lineCap", |
| 388 "lineEndings", | |
| 390 "lineJoin", | 389 "lineJoin", |
| 390 "listItems", | |
| 391 "matchedProperties", | 391 "matchedProperties", |
| 392 "mouseEvent", | |
| 392 "name", | 393 "name", |
| 393 "navigationType", | 394 "navigationType", |
| 394 "node", | 395 "node", |
| 395 "outcome", | 396 "outcome", |
| 396 "pagePopup", | 397 "pagePopup", |
| 397 "paintWorklet", | 398 "paintWorklet", |
| 398 "path", | 399 "path", |
| 399 "processingInstruction", | 400 "processingInstruction", |
| 400 "readyState", | 401 "readyState", |
| 402 "relList", | |
| 401 "response", | 403 "response", |
| 402 "sandboxSupport", | 404 "sandboxSupport", |
| 403 "screenInfo", | 405 "screenInfo", |
| 404 "scrollAnimator", | 406 "scrollAnimator", |
| 405 "settings", | 407 "settings", |
| 406 "signalingState", | 408 "signalingState", |
| 407 "state", | 409 "state", |
| 410 "styleSheet", | |
| 408 "string", | 411 "string", |
| 409 "text", | 412 "text", |
| 410 "textAlign", | 413 "textAlign", |
| 411 "textBaseline", | 414 "textBaseline", |
| 412 "theme", | 415 "theme", |
| 416 "thread", | |
| 413 "timing", | 417 "timing", |
| 414 "topLevelBlameContext", | 418 "topLevelBlameContext", |
| 415 "widget", | 419 "widget", |
| 420 "wordBoundaries", | |
|
Łukasz Anforowicz
2017/01/04 17:12:46
Can you please also add method names from https://
nasko
2017/01/04 17:22:52
Done.
| |
| 416 }; | 421 }; |
| 417 for (const auto& conflicting_method : kConflictingMethods) { | 422 for (const auto& conflicting_method : kConflictingMethods) { |
| 418 if (old_method_name == conflicting_method) | 423 if (old_method_name == conflicting_method) |
| 419 return true; | 424 return true; |
| 420 } | 425 } |
| 421 | 426 |
| 422 return false; | 427 return false; |
| 423 } | 428 } |
| 424 | 429 |
| 425 AST_MATCHER(clang::FunctionDecl, shouldPrefixFunctionName) { | 430 AST_MATCHER(clang::FunctionDecl, shouldPrefixFunctionName) { |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1392 for (const auto& r : replacements) { | 1397 for (const auto& r : replacements) { |
| 1393 std::string replacement_text = r.getReplacementText().str(); | 1398 std::string replacement_text = r.getReplacementText().str(); |
| 1394 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); | 1399 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); |
| 1395 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() | 1400 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() |
| 1396 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; | 1401 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; |
| 1397 } | 1402 } |
| 1398 llvm::outs() << "==== END EDITS ====\n"; | 1403 llvm::outs() << "==== END EDITS ====\n"; |
| 1399 | 1404 |
| 1400 return 0; | 1405 return 0; |
| 1401 } | 1406 } |
| OLD | NEW |