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

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

Issue 2624253002: rewrite_to_chrome_style: Make const decisions aware of const variables (Closed)
Patch Set: consistent-consts-3: Created 3 years, 11 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // We do our best to figure out special cases as we come across them here, for 402 // We do our best to figure out special cases as we come across them here, for
403 // template dependent situations. Some cases in code are only considered 403 // template dependent situations. Some cases in code are only considered
404 // instantiation dependent for some template instantiations! Which is 404 // instantiation dependent for some template instantiations! Which is
405 // terrible! So most importantly we try to match isEvaluatable in those cases. 405 // terrible! So most importantly we try to match isEvaluatable in those cases.
406 switch (expr->getStmtClass()) { 406 switch (expr->getStmtClass()) {
407 case clang::Stmt::CXXThisExprClass: 407 case clang::Stmt::CXXThisExprClass:
408 return false; 408 return false;
409 case clang::Stmt::DeclRefExprClass: { 409 case clang::Stmt::DeclRefExprClass: {
410 auto* declref = clang::dyn_cast<clang::DeclRefExpr>(expr); 410 auto* declref = clang::dyn_cast<clang::DeclRefExpr>(expr);
411 auto* decl = declref->getDecl(); 411 auto* decl = declref->getDecl();
412 if (clang::dyn_cast<clang::VarDecl>(decl)) 412 if (auto* vardecl = clang::dyn_cast<clang::VarDecl>(decl)) {
413 if (auto* initializer = vardecl->getInit())
414 return CanBeEvaluatedAtCompileTime(initializer, context);
413 return false; 415 return false;
416 }
414 break; 417 break;
415 } 418 }
416 419
417 default: 420 default:
418 break; 421 break;
419 } 422 }
420 423
421 // Otherwise, we consider depending on template parameters to not interfere 424 // Otherwise, we consider depending on template parameters to not interfere
422 // with being const.. with exceptions hopefully covered above. 425 // with being const.. with exceptions hopefully covered above.
423 return true; 426 return true;
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 for (const auto& r : replacements) { 1511 for (const auto& r : replacements) {
1509 std::string replacement_text = r.getReplacementText().str(); 1512 std::string replacement_text = r.getReplacementText().str();
1510 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 1513 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
1511 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() 1514 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset()
1512 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; 1515 << ":::" << r.getLength() << ":::" << replacement_text << "\n";
1513 } 1516 }
1514 llvm::outs() << "==== END EDITS ====\n"; 1517 llvm::outs() << "==== END EDITS ====\n";
1515 1518
1516 return 0; 1519 return 0;
1517 } 1520 }
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