Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ template <> struct ScalarEnumerationTraits<clang::DiagnosticIDs::Level> {
}
};
template <> struct SequenceElementTraits<ClangTidyOptions::CustomCheckDiag> {
// NOLINTNEXTLINE(readability-identifier-naming) Defined by YAMLTraits.h
static const bool flow = false;
};
template <> struct MappingTraits<ClangTidyOptions::CustomCheckDiag> {
Expand All @@ -165,6 +166,7 @@ template <> struct MappingTraits<ClangTidyOptions::CustomCheckDiag> {
}
};
template <> struct SequenceElementTraits<ClangTidyOptions::CustomCheckValue> {
// NOLINTNEXTLINE(readability-identifier-naming) Defined by YAMLTraits.h
static const bool flow = false;
};
template <> struct MappingTraits<ClangTidyOptions::CustomCheckValue> {
Expand Down
8 changes: 4 additions & 4 deletions clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt *Statement,
break;
case (BO_MulAssign):
Iterations =
1 + (std::log((double)EndValue) - std::log((double)InitValue)) /
std::log((double)ConstantValue);
1 + ((std::log((double)EndValue) - std::log((double)InitValue)) /
std::log((double)ConstantValue));
break;
case (BO_DivAssign):
Iterations =
1 + (std::log((double)InitValue) - std::log((double)EndValue)) /
std::log((double)ConstantValue);
1 + ((std::log((double)InitValue) - std::log((double)EndValue)) /
std::log((double)ConstantValue));
break;
default:
// All other operators are not handled; assume large bounds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
WorkType = To;
}

if (Ctx.hasSameType(WorkType, To)) {
if (ASTContext::hasSameType(WorkType, To)) {
LLVM_DEBUG(llvm::dbgs() << "<<< approximateStdConv. Reached 'To' type.\n");
return {Ctx.getCommonSugaredType(WorkType, To)};
}
Expand Down
12 changes: 6 additions & 6 deletions clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
"suspicious usage of 'sizeof(array)/sizeof(...)';"
" denominator differs from the size of array elements")
<< E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();
} else if (NumTy && DenomTy && Ctx.hasSameType(NumTy, DenomTy) &&
} else if (NumTy && DenomTy && ASTContext::hasSameType(NumTy, DenomTy) &&
!NumTy->isDependentType()) {
// Dependent type should not be compared.
diag(E->getOperatorLoc(),
Expand All @@ -433,7 +433,7 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
<< E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();
} else if (!WarnOnSizeOfPointer) {
// When 'WarnOnSizeOfPointer' is enabled, these messages become redundant:
if (PointedTy && DenomTy && Ctx.hasSameType(PointedTy, DenomTy)) {
if (PointedTy && DenomTy && ASTContext::hasSameType(PointedTy, DenomTy)) {
diag(E->getOperatorLoc(),
"suspicious usage of 'sizeof(...)/sizeof(...)'; size of pointer "
"is divided by size of pointed type")
Expand Down Expand Up @@ -462,8 +462,8 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
const auto *SizeOfExpr =
Result.Nodes.getNodeAs<UnaryExprOrTypeTraitExpr>("sizeof-ptr-mul-expr");

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

if (Ctx.hasSameType(LPtrTy, RPtrTy) &&
Ctx.hasSameType(LPtrTy, SizeofArgTy)) {
if (ASTContext::hasSameType(LPtrTy, RPtrTy) &&
ASTContext::hasSameType(LPtrTy, SizeofArgTy)) {
diag(SizeOfExpr->getBeginLoc(), "suspicious usage of 'sizeof(...)' in "
"pointer arithmetic")
<< SizeOfExpr->getSourceRange() << E->getOperatorLoc()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static bool checkOverridingFunctionReturnType(const ASTContext *Context,
return false;

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

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

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

// Check ambiguity.
if (Paths.isAmbiguous(Context->getCanonicalType(BTy).getUnqualifiedType()))
if (Paths.isAmbiguous(
ASTContext::getCanonicalType(BTy).getUnqualifiedType()))
return false;

// Check accessibility.
Expand Down
10 changes: 5 additions & 5 deletions clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ EditGenerator rewrite(RangeSelector Call, RangeSelector Builder,
}

RewriteRuleWith<std::string> useNewMlirOpBuilderCheckRule() {
Stencil message = cat("use 'OpType::create(builder, ...)' instead of "
Stencil Message = cat("use 'OpType::create(builder, ...)' instead of "
"'builder.create<OpType>(...)'");
// Match a create call on an OpBuilder.
ast_matchers::internal::Matcher<Stmt> base =
ast_matchers::internal::Matcher<Stmt> Base =
cxxMemberCallExpr(
on(expr(hasType(
cxxRecordDecl(isSameOrDerivedFrom("::mlir::OpBuilder"))))
Expand All @@ -124,10 +124,10 @@ RewriteRuleWith<std::string> useNewMlirOpBuilderCheckRule() {
.bind("call");
return applyFirst(
// Attempt rewrite given an lvalue builder, else just warn.
{makeRule(cxxMemberCallExpr(unless(on(cxxTemporaryObjectExpr())), base),
{makeRule(cxxMemberCallExpr(unless(on(cxxTemporaryObjectExpr())), Base),
rewrite(node("call"), node("builder"), callArgs("call")),
message),
makeRule(base, noopEdit(node("call")), message)});
Message),
makeRule(Base, noopEdit(node("call")), Message)});
}
} // namespace

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ AST_MATCHER(FunctionDecl, isPlacementOverload) {
const auto *FPT = Node.getType()->castAs<FunctionProtoType>();
ASTContext &Ctx = Node.getASTContext();
if (Ctx.getLangOpts().SizedDeallocation &&
Ctx.hasSameType(FPT->getParamType(1), Ctx.getSizeType()))
ASTContext::hasSameType(FPT->getParamType(1), Ctx.getSizeType()))
return false;

return true;
Expand Down
7 changes: 4 additions & 3 deletions clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ static bool canBeModified(ASTContext *Context, const Expr *E) {
return true;
if (const auto *Cast = Parents[0].get<ImplicitCastExpr>()) {
if ((Cast->getCastKind() == CK_NoOp &&
Context->hasSameType(Cast->getType(), E->getType().withConst())) ||
ASTContext::hasSameType(Cast->getType(), E->getType().withConst())) ||
(Cast->getCastKind() == CK_LValueToRValue &&
!Cast->getType().isNull() && Cast->getType()->isFundamentalType()))
return false;
Expand Down Expand Up @@ -664,7 +664,8 @@ void LoopConvertCheck::doConversion(
AliasVarIsRef = true;
}
if (Descriptor.ElemType.isNull() ||
!Context->hasSameUnqualifiedType(AliasVarType, Descriptor.ElemType))
!ASTContext::hasSameUnqualifiedType(AliasVarType,
Descriptor.ElemType))
Descriptor.ElemType = AliasVarType;
}

Expand Down Expand Up @@ -944,7 +945,7 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context,
CanonicalInitVarType->isPointerType()) {
// If the initializer and the variable are both pointers check if the
// un-qualified pointee types match, otherwise we don't use auto.
return Context->hasSameUnqualifiedType(
return ASTContext::hasSameUnqualifiedType(
CanonicalBeginType->getPointeeType(),
CanonicalInitVarType->getPointeeType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static bool isAliasDecl(ASTContext *Context, const Decl *TheDecl,
DeclarationType = DeclarationType.getNonReferenceType();

if (InitType.isNull() || DeclarationType.isNull() ||
!Context->hasSameUnqualifiedType(DeclarationType, InitType))
!ASTContext::hasSameUnqualifiedType(DeclarationType, InitType))
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void UseAutoCheck::replaceIterators(const DeclStmt *D, ASTContext *Context) {
if (NestedConstruct->getConstructor()->isConvertingConstructor(false))
return;
}
if (!Context->hasSameType(V->getType(), E->getType()))
if (!ASTContext::hasSameType(V->getType(), E->getType()))
return;
}

Expand Down Expand Up @@ -378,7 +378,7 @@ void UseAutoCheck::replaceExpr(
return;

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

// All subsequent variables in this declaration should have the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static StringRef getZeroLiteralToCompareWithForType(CastKind CastExprKind,
return Type->isUnsignedIntegerType() ? "0u" : "0";

case CK_FloatingToBoolean:
return Context.hasSameType(Type, Context.FloatTy) ? "0.0f" : "0.0";
return ASTContext::hasSameType(Type, Context.FloatTy) ? "0.0f" : "0.0";

case CK_PointerToBoolean:
case CK_MemberPointerToBoolean: // Fall-through on purpose.
Expand Down Expand Up @@ -215,7 +215,7 @@ getEquivalentForBoolLiteral(const CXXBoolLiteralExpr *BoolLiteral,
}

if (DestType->isFloatingType()) {
if (Context.hasSameType(DestType, Context.FloatTy)) {
if (ASTContext::hasSameType(DestType, Context.FloatTy)) {
return BoolLiteral->getValue() ? "1.0f" : "0.0f";
}
return BoolLiteral->getValue() ? "1.0" : "0.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,11 @@ void QualifiedAutoCheck::registerMatchers(MatchFinder *Finder) {
if (this->IgnoreAliasing) {
return qualType(
hasUnqualifiedDesugaredType(pointerType(pointee(InnerMatchers...))));
} else {
return qualType(
anyOf(qualType(pointerType(pointee(InnerMatchers...))),
qualType(substTemplateTypeParmType(hasReplacementType(
pointerType(pointee(InnerMatchers...)))))));
}
return qualType(anyOf(qualType(pointerType(pointee(InnerMatchers...))),
qualType(substTemplateTypeParmType(hasReplacementType(
pointerType(pointee(InnerMatchers...)))))));

};

auto IsAutoDeducedToPointer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ static bool applyDiceHeuristic(StringRef Arg, StringRef Param,
std::size_t Intersection = 0;

// Find the intersection between the two sets.
for (auto IT = ParamBigrams.begin(); IT != ParamBigrams.end(); ++IT)
Intersection += ArgBigrams.count((IT->getKey()));
for (const auto &[Key, _] : ParamBigrams)
Intersection += ArgBigrams.count(Key);

// Calculate Dice coefficient.
return percentage(Intersection * 2.0,
Expand Down