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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 StringRef original_name = decl.getName(); | 104 StringRef original_name = decl.getName(); |
| 105 // Blink style field names are prefixed with `m_`. If this prefix isn't | 105 // Blink style field names are prefixed with `m_`. If this prefix isn't |
| 106 // present, assume it's already been converted to Google style. | 106 // present, assume it's already been converted to Google style. |
| 107 if (original_name.size() < strlen(kBlinkFieldPrefix) || | 107 if (original_name.size() < strlen(kBlinkFieldPrefix) || |
| 108 !original_name.startswith(kBlinkFieldPrefix)) | 108 !original_name.startswith(kBlinkFieldPrefix)) |
| 109 return false; | 109 return false; |
| 110 name = CamelCaseToUnderscoreCase( | 110 name = CamelCaseToUnderscoreCase( |
| 111 original_name.substr(strlen(kBlinkFieldPrefix))); | 111 original_name.substr(strlen(kBlinkFieldPrefix))); |
| 112 // The few examples I could find used struct-style naming with no `_` suffix | 112 // The few examples I could find used struct-style naming with no `_` suffix |
| 113 // for unions. | 113 // for unions. |
| 114 if (decl.getParent()->isClass()) | 114 bool c = decl.getParent()->isClass(); |
| 115 // There appears to be a GCC bug that makes this branch incorrectly if we | |
| 116 // don't use a temp variable!! Clang works right. crbug.com/580745 | |
| 117 if (c) | |
|
dcheng
2016/01/27 23:46:15
This gives me the heebie jeebies. I feel like we s
danakj
2016/01/27 23:51:01
Ya, I'm sure there's other bugs happening elsewher
| |
| 115 name += '_'; | 118 name += '_'; |
| 116 return true; | 119 return true; |
| 117 } | 120 } |
| 118 | 121 |
| 119 bool IsProbablyConst(const clang::VarDecl& decl, | 122 bool IsProbablyConst(const clang::VarDecl& decl, |
| 120 const clang::ASTContext& context) { | 123 const clang::ASTContext& context) { |
| 121 clang::QualType type = decl.getType(); | 124 clang::QualType type = decl.getType(); |
| 122 if (!type.isConstQualified()) | 125 if (!type.isConstQualified()) |
| 123 return false; | 126 return false; |
| 124 | 127 |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 for (const auto& r : replacements) { | 558 for (const auto& r : replacements) { |
| 556 std::string replacement_text = r.getReplacementText().str(); | 559 std::string replacement_text = r.getReplacementText().str(); |
| 557 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); | 560 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); |
| 558 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() | 561 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() |
| 559 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; | 562 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; |
| 560 } | 563 } |
| 561 llvm::outs() << "==== END EDITS ====\n"; | 564 llvm::outs() << "==== END EDITS ====\n"; |
| 562 | 565 |
| 563 return 0; | 566 return 0; |
| 564 } | 567 } |
| OLD | NEW |