Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp

Issue 1645243002: rewrite_to_chrome_style: Avoid asserts when checking for const-ness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/template-expected.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/template-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698