Skip to content

Commit ad56841

Browse files
vbvictorlocalspook
authored andcommitted
Automerge: [clang-tidy][NFC] Fix miscellaneous clang-tidy warnings over codebase (#164096)
Co-authored-by: Victor Chernyakin <[email protected]>
2 parents 1269230 + cb79d8f commit ad56841

13 files changed

+38
-35
lines changed

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ template <> struct ScalarEnumerationTraits<clang::DiagnosticIDs::Level> {
154154
}
155155
};
156156
template <> struct SequenceElementTraits<ClangTidyOptions::CustomCheckDiag> {
157+
// NOLINTNEXTLINE(readability-identifier-naming) Defined by YAMLTraits.h
157158
static const bool flow = false;
158159
};
159160
template <> struct MappingTraits<ClangTidyOptions::CustomCheckDiag> {
@@ -165,6 +166,7 @@ template <> struct MappingTraits<ClangTidyOptions::CustomCheckDiag> {
165166
}
166167
};
167168
template <> struct SequenceElementTraits<ClangTidyOptions::CustomCheckValue> {
169+
// NOLINTNEXTLINE(readability-identifier-naming) Defined by YAMLTraits.h
168170
static const bool flow = false;
169171
};
170172
template <> struct MappingTraits<ClangTidyOptions::CustomCheckValue> {

clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt *Statement,
215215
break;
216216
case (BO_MulAssign):
217217
Iterations =
218-
1 + (std::log((double)EndValue) - std::log((double)InitValue)) /
219-
std::log((double)ConstantValue);
218+
1 + ((std::log((double)EndValue) - std::log((double)InitValue)) /
219+
std::log((double)ConstantValue));
220220
break;
221221
case (BO_DivAssign):
222222
Iterations =
223-
1 + (std::log((double)InitValue) - std::log((double)EndValue)) /
224-
std::log((double)ConstantValue);
223+
1 + ((std::log((double)InitValue) - std::log((double)EndValue)) /
224+
std::log((double)ConstantValue));
225225
break;
226226
default:
227227
// All other operators are not handled; assume large bounds.

clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
10741074
WorkType = To;
10751075
}
10761076

1077-
if (Ctx.hasSameType(WorkType, To)) {
1077+
if (ASTContext::hasSameType(WorkType, To)) {
10781078
LLVM_DEBUG(llvm::dbgs() << "<<< approximateStdConv. Reached 'To' type.\n");
10791079
return {Ctx.getCommonSugaredType(WorkType, To)};
10801080
}

clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
424424
"suspicious usage of 'sizeof(array)/sizeof(...)';"
425425
" denominator differs from the size of array elements")
426426
<< E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();
427-
} else if (NumTy && DenomTy && Ctx.hasSameType(NumTy, DenomTy) &&
427+
} else if (NumTy && DenomTy && ASTContext::hasSameType(NumTy, DenomTy) &&
428428
!NumTy->isDependentType()) {
429429
// Dependent type should not be compared.
430430
diag(E->getOperatorLoc(),
@@ -433,7 +433,7 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
433433
<< E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();
434434
} else if (!WarnOnSizeOfPointer) {
435435
// When 'WarnOnSizeOfPointer' is enabled, these messages become redundant:
436-
if (PointedTy && DenomTy && Ctx.hasSameType(PointedTy, DenomTy)) {
436+
if (PointedTy && DenomTy && ASTContext::hasSameType(PointedTy, DenomTy)) {
437437
diag(E->getOperatorLoc(),
438438
"suspicious usage of 'sizeof(...)/sizeof(...)'; size of pointer "
439439
"is divided by size of pointed type")
@@ -462,8 +462,8 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
462462
const auto *SizeOfExpr =
463463
Result.Nodes.getNodeAs<UnaryExprOrTypeTraitExpr>("sizeof-ptr-mul-expr");
464464

465-
if (Ctx.hasSameType(LPtrTy, RPtrTy) &&
466-
Ctx.hasSameType(LPtrTy, SizeofArgTy)) {
465+
if (ASTContext::hasSameType(LPtrTy, RPtrTy) &&
466+
ASTContext::hasSameType(LPtrTy, SizeofArgTy)) {
467467
diag(SizeOfExpr->getBeginLoc(), "suspicious usage of 'sizeof(...)' in "
468468
"pointer arithmetic")
469469
<< SizeOfExpr->getSourceRange() << E->getOperatorLoc()
@@ -477,8 +477,8 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
477477
const auto *SizeOfExpr =
478478
Result.Nodes.getNodeAs<UnaryExprOrTypeTraitExpr>("sizeof-ptr-div-expr");
479479

480-
if (Ctx.hasSameType(LPtrTy, RPtrTy) &&
481-
Ctx.hasSameType(LPtrTy, SizeofArgTy)) {
480+
if (ASTContext::hasSameType(LPtrTy, RPtrTy) &&
481+
ASTContext::hasSameType(LPtrTy, SizeofArgTy)) {
482482
diag(SizeOfExpr->getBeginLoc(), "suspicious usage of 'sizeof(...)' in "
483483
"pointer arithmetic")
484484
<< SizeOfExpr->getSourceRange() << E->getOperatorLoc()

clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static bool checkOverridingFunctionReturnType(const ASTContext *Context,
5050
return false;
5151

5252
// Check if return types are identical.
53-
if (Context->hasSameType(DerivedReturnTy, BaseReturnTy))
53+
if (ASTContext::hasSameType(DerivedReturnTy, BaseReturnTy))
5454
return true;
5555

5656
/// Check if the return types are covariant.
@@ -77,7 +77,7 @@ static bool checkOverridingFunctionReturnType(const ASTContext *Context,
7777
if (DRD == BRD)
7878
return true;
7979

80-
if (!Context->hasSameUnqualifiedType(DTy, BTy)) {
80+
if (!ASTContext::hasSameUnqualifiedType(DTy, BTy)) {
8181
// Begin checking whether the conversion from D to B is valid.
8282
CXXBasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/true,
8383
/*DetectVirtual=*/false);
@@ -87,7 +87,8 @@ static bool checkOverridingFunctionReturnType(const ASTContext *Context,
8787
return false;
8888

8989
// Check ambiguity.
90-
if (Paths.isAmbiguous(Context->getCanonicalType(BTy).getUnqualifiedType()))
90+
if (Paths.isAmbiguous(
91+
ASTContext::getCanonicalType(BTy).getUnqualifiedType()))
9192
return false;
9293

9394
// Check accessibility.

clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ EditGenerator rewrite(RangeSelector Call, RangeSelector Builder,
111111
}
112112

113113
RewriteRuleWith<std::string> useNewMlirOpBuilderCheckRule() {
114-
Stencil message = cat("use 'OpType::create(builder, ...)' instead of "
114+
Stencil Message = cat("use 'OpType::create(builder, ...)' instead of "
115115
"'builder.create<OpType>(...)'");
116116
// Match a create call on an OpBuilder.
117-
ast_matchers::internal::Matcher<Stmt> base =
117+
ast_matchers::internal::Matcher<Stmt> Base =
118118
cxxMemberCallExpr(
119119
on(expr(hasType(
120120
cxxRecordDecl(isSameOrDerivedFrom("::mlir::OpBuilder"))))
@@ -124,10 +124,10 @@ RewriteRuleWith<std::string> useNewMlirOpBuilderCheckRule() {
124124
.bind("call");
125125
return applyFirst(
126126
// Attempt rewrite given an lvalue builder, else just warn.
127-
{makeRule(cxxMemberCallExpr(unless(on(cxxTemporaryObjectExpr())), base),
127+
{makeRule(cxxMemberCallExpr(unless(on(cxxTemporaryObjectExpr())), Base),
128128
rewrite(node("call"), node("builder"), callArgs("call")),
129-
message),
130-
makeRule(base, noopEdit(node("call")), message)});
129+
Message),
130+
makeRule(Base, noopEdit(node("call")), Message)});
131131
}
132132
} // namespace
133133

clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ AST_MATCHER(FunctionDecl, isPlacementOverload) {
5353
const auto *FPT = Node.getType()->castAs<FunctionProtoType>();
5454
ASTContext &Ctx = Node.getASTContext();
5555
if (Ctx.getLangOpts().SizedDeallocation &&
56-
Ctx.hasSameType(FPT->getParamType(1), Ctx.getSizeType()))
56+
ASTContext::hasSameType(FPT->getParamType(1), Ctx.getSizeType()))
5757
return false;
5858

5959
return true;

clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ static bool canBeModified(ASTContext *Context, const Expr *E) {
499499
return true;
500500
if (const auto *Cast = Parents[0].get<ImplicitCastExpr>()) {
501501
if ((Cast->getCastKind() == CK_NoOp &&
502-
Context->hasSameType(Cast->getType(), E->getType().withConst())) ||
502+
ASTContext::hasSameType(Cast->getType(), E->getType().withConst())) ||
503503
(Cast->getCastKind() == CK_LValueToRValue &&
504504
!Cast->getType().isNull() && Cast->getType()->isFundamentalType()))
505505
return false;
@@ -664,7 +664,8 @@ void LoopConvertCheck::doConversion(
664664
AliasVarIsRef = true;
665665
}
666666
if (Descriptor.ElemType.isNull() ||
667-
!Context->hasSameUnqualifiedType(AliasVarType, Descriptor.ElemType))
667+
!ASTContext::hasSameUnqualifiedType(AliasVarType,
668+
Descriptor.ElemType))
668669
Descriptor.ElemType = AliasVarType;
669670
}
670671

@@ -944,7 +945,7 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context,
944945
CanonicalInitVarType->isPointerType()) {
945946
// If the initializer and the variable are both pointers check if the
946947
// un-qualified pointee types match, otherwise we don't use auto.
947-
return Context->hasSameUnqualifiedType(
948+
return ASTContext::hasSameUnqualifiedType(
948949
CanonicalBeginType->getPointeeType(),
949950
CanonicalInitVarType->getPointeeType());
950951
}

clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static bool isAliasDecl(ASTContext *Context, const Decl *TheDecl,
370370
DeclarationType = DeclarationType.getNonReferenceType();
371371

372372
if (InitType.isNull() || DeclarationType.isNull() ||
373-
!Context->hasSameUnqualifiedType(DeclarationType, InitType))
373+
!ASTContext::hasSameUnqualifiedType(DeclarationType, InitType))
374374
return false;
375375
}
376376

clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ void UseAutoCheck::replaceIterators(const DeclStmt *D, ASTContext *Context) {
316316
if (NestedConstruct->getConstructor()->isConvertingConstructor(false))
317317
return;
318318
}
319-
if (!Context->hasSameType(V->getType(), E->getType()))
319+
if (!ASTContext::hasSameType(V->getType(), E->getType()))
320320
return;
321321
}
322322

@@ -378,7 +378,7 @@ void UseAutoCheck::replaceExpr(
378378
return;
379379

380380
// If VarDecl and Initializer have mismatching unqualified types.
381-
if (!Context->hasSameUnqualifiedType(V->getType(), GetType(Expr)))
381+
if (!ASTContext::hasSameUnqualifiedType(V->getType(), GetType(Expr)))
382382
return;
383383

384384
// All subsequent variables in this declaration should have the same

0 commit comments

Comments
 (0)