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

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

Issue 2618543002: ParamVarDecl should never be renamed to kConstantStyle. (Closed)
Patch Set: Using: clang::isa<clang::ParmVarDecl>(&decl) 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/constants-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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 323
324 bool IsProbablyConst(const clang::VarDecl& decl, 324 bool IsProbablyConst(const clang::VarDecl& decl,
325 const clang::ASTContext& context) { 325 const clang::ASTContext& context) {
326 clang::QualType type = decl.getType(); 326 clang::QualType type = decl.getType();
327 if (!type.isConstQualified()) 327 if (!type.isConstQualified())
328 return false; 328 return false;
329 329
330 if (type.isVolatileQualified()) 330 if (type.isVolatileQualified())
331 return false; 331 return false;
332 332
333 // Parameters should not be renamed to |kFooBar| style (even if they are
334 // const and have an initializer (aka default value)).
335 if (clang::isa<clang::ParmVarDecl>(&decl))
336 return false;
337
333 // http://google.github.io/styleguide/cppguide.html#Constant_Names 338 // http://google.github.io/styleguide/cppguide.html#Constant_Names
334 // Static variables that are const-qualified should use kConstantStyle naming. 339 // Static variables that are const-qualified should use kConstantStyle naming.
335 if (decl.getStorageDuration() == clang::SD_Static) 340 if (decl.getStorageDuration() == clang::SD_Static)
336 return true; 341 return true;
337 342
338 const clang::Expr* initializer = decl.getInit(); 343 const clang::Expr* initializer = decl.getInit();
339 if (!initializer) 344 if (!initializer)
340 return false; 345 return false;
341 346
342 // If the expression is dependent on a template input, then we are not 347 // If the expression is dependent on a template input, then we are not
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/constants-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698