[PATCH] D95614: [clang-tidy] Applied clang-tidy fixes. NFC
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 28 15:51:23 PST 2021
alexfh added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp:96
void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
- for (auto ScaleName :
+ for (const auto *ScaleName :
{"Hours", "Minutes", "Seconds", "Millis", "Micros", "Nanos"}) {
----------------
Changing this to `const char *`.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp:283
continue;
- if (auto Template = Callee->getTemplateInstantiationPattern()) {
+ if (auto *Template = Callee->getTemplateInstantiationPattern()) {
// Don't warn on arguments for parameters instantiated from template
----------------
Changing this to `FunctionDecl *`.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp:191-194
+ auto *End = Branches.end();
+ auto *BeginCurrent = Branches.begin();
while (BeginCurrent < End) {
+ auto *EndCurrent = BeginCurrent + 1;
----------------
This comes from llvm-qualified-auto. Iterator being a pointer is an implementation detail, thus the fix is not helpful. Reverting it.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp:113
Diag << FixItHint::CreateInsertion(FixItLoc, FixItMsg);
-} // namespace misc
----------------
Removed this manually.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp:109-110
const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
- for (auto Iter = Ctor->param_begin() + 1; Iter != Ctor->param_end(); ++Iter) {
+ for (const auto *Iter = Ctor->param_begin() + 1; Iter != Ctor->param_end();
+ ++Iter) {
if (!(*Iter)->hasDefaultArg())
----------------
This comes from llvm-qualified-auto. Iterator being a pointer is an implementation detail, thus the fix is not helpful. Reverting it.
For the context:
using param_iterator = MutableArrayRef<ParmVarDecl *>::iterator;
...
param_iterator param_begin() ...
================
Comment at: clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:923
const auto *FunctionExpr = Result.Nodes.getNodeAs<CallExpr>(FunctionExprName);
- if (const auto GivenCL = dyn_cast<CharacterLiteral>(FunctionExpr->getArg(1)))
+ if (const auto *const GivenCL =
+ dyn_cast<CharacterLiteral>(FunctionExpr->getArg(1)))
----------------
Removing this const, since it doesn't bring anything here.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp:42
return M.matches(*UE->getSubExpr(), Finder, Builder);
} else if (const auto *BE = dyn_cast<BinaryOperator>(E)) {
const auto LHS = hasSizeOfDescendant(Depth - 1, InnerMatcher);
----------------
Removing this one too. The check outputs just one diagnostic per if - else if - else if chain for some reason.
================
Comment at: clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:88
return twoPow(Context.getTypeSize(T));
else
return 1;
----------------
Removing this one too. The llvm-else-after-return check outputs just one diagnostic per if - else if - else if chain for some reason.
================
Comment at: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:337
- auto MaxPlaceholderIt =
+ const auto *MaxPlaceholderIt =
std::max_element(Args.begin(), Args.end(),
----------------
Iterator being a pointer is an implementation detail. Reverting.
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp:62
if (Replacement) {
- auto FixName = *Replacement;
+ const auto *FixName = *Replacement;
auto Builder = diag(IoStateLoc, "'std::ios_base::%0' is deprecated; use "
----------------
Changing to `const char *`.
================
Comment at: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp:390-400
+ } // Direct initialization with ordinary constructors.
// struct S { S(int x); S(); };
// smart_ptr<S>(new S{5});
// smart_ptr<S>(new S{}); // use default constructor
// The arguments in the initialization list are going to be forwarded to
// the constructor, so this has to be replaced with:
// std::make_smart_ptr<S>(5);
----------------
Fixing indentation.
================
Comment at: clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp:175
ReplacementText = " " + OverrideSpelling;
- auto LastTokenIter = std::prev(Tokens.end());
+ auto *LastTokenIter = std::prev(Tokens.end());
// When try statement is used instead of compound statement as
----------------
Reverting this (iterator doesn't have to be a pointer).
================
Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:61
- auto printPolicy = PrintingPolicy(getLangOpts());
- printPolicy.SuppressScope = true;
- printPolicy.ConstantArraySizeAsWritten = true;
- printPolicy.UseVoidForZeroParams = false;
- printPolicy.PrintInjectedClassNameWithArguments = false;
+ auto PrintPolicy = PrintingPolicy(getLangOpts());
+ PrintPolicy.SuppressScope = true;
----------------
Removed the use of `auto` here.
================
Comment at: clang-tools-extra/clang-tidy/performance/InefficientStringConcatenationCheck.cpp:72
Result.Nodes.getNodeAs<CXXOperatorCallExpr>("plusOperator");
- const auto DiagMsg =
+ const auto *const DiagMsg =
"string concatenation results in allocation of unnecessary temporary "
----------------
Changing to `const char *`.
================
Comment at: clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp:42
// Create and set diagnostics engine
- auto ExternalDiagEngine = &Compiler.getDiagnostics();
- auto DiagConsumer =
+ auto *ExternalDiagEngine = &Compiler.getDiagnostics();
+ auto *DiagConsumer =
----------------
Removed this variable.
================
Comment at: clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp:108-109
- auto SourceParamIt = ParameterSourceDeclaration->param_begin();
- auto OtherParamIt = OtherDeclaration->param_begin();
+ const auto *SourceParamIt = ParameterSourceDeclaration->param_begin();
+ const auto *OtherParamIt = OtherDeclaration->param_begin();
----------------
Reverting.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95614/new/
https://reviews.llvm.org/D95614
More information about the cfe-commits
mailing list