| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 // http://google.github.io/styleguide/cppguide.html#Constant_Names | 144 // http://google.github.io/styleguide/cppguide.html#Constant_Names |
| 145 // Static variables that are const-qualified should use kConstantStyle naming. | 145 // Static variables that are const-qualified should use kConstantStyle naming. |
| 146 if (decl.getStorageDuration() == clang::SD_Static) | 146 if (decl.getStorageDuration() == clang::SD_Static) |
| 147 return true; | 147 return true; |
| 148 | 148 |
| 149 const clang::Expr* initializer = decl.getInit(); | 149 const clang::Expr* initializer = decl.getInit(); |
| 150 if (!initializer) | 150 if (!initializer) |
| 151 return false; | 151 return false; |
| 152 | 152 |
| 153 // If the expression is dependent on a template input, then we are not |
| 154 // sure if it can be compile-time generated as calling isEvaluatable() is |
| 155 // not valid on |initializer|. |
| 156 // TODO(crbug.com/581218): We could probably look at each compiled |
| 157 // instantiation of the template and see if they are all compile-time |
| 158 // isEvaluable(). |
| 159 if (initializer->isInstantiationDependent()) |
| 160 return false; |
| 161 |
| 153 // If the expression can be evaluated at compile time, then it should have a | 162 // If the expression can be evaluated at compile time, then it should have a |
| 154 // kFoo style name. Otherwise, not. | 163 // kFoo style name. Otherwise, not. |
| 155 return initializer->isEvaluatable(context); | 164 return initializer->isEvaluatable(context); |
| 156 } | 165 } |
| 157 | 166 |
| 158 bool GetNameForDecl(const clang::VarDecl& decl, | 167 bool GetNameForDecl(const clang::VarDecl& decl, |
| 159 const clang::ASTContext& context, | 168 const clang::ASTContext& context, |
| 160 std::string& name) { | 169 std::string& name) { |
| 161 StringRef original_name = decl.getName(); | 170 StringRef original_name = decl.getName(); |
| 162 | 171 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 for (const auto& r : replacements) { | 583 for (const auto& r : replacements) { |
| 575 std::string replacement_text = r.getReplacementText().str(); | 584 std::string replacement_text = r.getReplacementText().str(); |
| 576 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); | 585 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); |
| 577 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() | 586 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() |
| 578 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; | 587 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; |
| 579 } | 588 } |
| 580 llvm::outs() << "==== END EDITS ====\n"; | 589 llvm::outs() << "==== END EDITS ====\n"; |
| 581 | 590 |
| 582 return 0; | 591 return 0; |
| 583 } | 592 } |
| OLD | NEW |