Skip to content

Commit 458e895

Browse files
authored
merge main into amd-staging (llvm#4570)
2 parents 68893a9 + 7e6dfb0 commit 458e895

File tree

134 files changed

+3460
-2061
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+3460
-2061
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/android/CloexecCheck.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ using namespace clang::ast_matchers;
1616

1717
namespace clang::tidy::android {
1818

19-
namespace {
2019
// Helper function to form the correct string mode for Type3.
2120
// Build the replace text. If it's string constant, add <Mode> directly in the
2221
// end of the string. Else, add <Mode>.
23-
std::string buildFixMsgForStringFlag(const Expr *Arg, const SourceManager &SM,
24-
const LangOptions &LangOpts, char Mode) {
22+
static std::string buildFixMsgForStringFlag(const Expr *Arg,
23+
const SourceManager &SM,
24+
const LangOptions &LangOpts,
25+
char Mode) {
2526
if (Arg->getBeginLoc().isMacroID())
2627
return (Lexer::getSourceText(
2728
CharSourceRange::getTokenRange(Arg->getSourceRange()), SM,
@@ -32,11 +33,6 @@ std::string buildFixMsgForStringFlag(const Expr *Arg, const SourceManager &SM,
3233
StringRef SR = cast<StringLiteral>(Arg->IgnoreParenCasts())->getString();
3334
return ("\"" + SR + Twine(Mode) + "\"").str();
3435
}
35-
} // namespace
36-
37-
const char *CloexecCheck::FuncDeclBindingStr = "funcDecl";
38-
39-
const char *CloexecCheck::FuncBindingStr = "func";
4036

4137
void CloexecCheck::registerMatchersImpl(
4238
MatchFinder *Finder, internal::Matcher<FunctionDecl> Function) {

clang-tools-extra/clang-tidy/android/CloexecCheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ class CloexecCheck : public ClangTidyCheck {
8989
int N) const;
9090

9191
/// Binding name of the FuncDecl of a function call.
92-
static const char *FuncDeclBindingStr;
92+
static constexpr char FuncDeclBindingStr[] = "funcDecl";
9393

9494
/// Binding name of the function call expression.
95-
static const char *FuncBindingStr;
95+
static constexpr char FuncBindingStr[] = "func";
9696
};
9797

9898
} // namespace clang::tidy::android

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/SignalHandlerCheck.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,10 @@ struct OptionEnumMapping<
245245

246246
namespace bugprone {
247247

248-
namespace {
249-
250248
/// Returns if a function is declared inside a system header.
251249
/// These functions are considered to be "standard" (system-provided) library
252250
/// functions.
253-
bool isStandardFunction(const FunctionDecl *FD) {
251+
static bool isStandardFunction(const FunctionDecl *FD) {
254252
// Find a possible redeclaration in system header.
255253
// FIXME: Looking at the canonical declaration is not the most exact way
256254
// to do this.
@@ -284,7 +282,7 @@ bool isStandardFunction(const FunctionDecl *FD) {
284282
/// Check if a statement is "C++-only".
285283
/// This includes all statements that have a class name with "CXX" prefix
286284
/// and every other statement that is declared in file ExprCXX.h.
287-
bool isCXXOnlyStmt(const Stmt *S) {
285+
static bool isCXXOnlyStmt(const Stmt *S) {
288286
StringRef Name = S->getStmtClassName();
289287
if (Name.starts_with("CXX"))
290288
return true;
@@ -304,7 +302,8 @@ bool isCXXOnlyStmt(const Stmt *S) {
304302
/// called from \p Caller, get a \c CallExpr of the corresponding function call.
305303
/// It is unspecified which call is found if multiple calls exist, but the order
306304
/// should be deterministic (depend only on the AST).
307-
Expr *findCallExpr(const CallGraphNode *Caller, const CallGraphNode *Callee) {
305+
static Expr *findCallExpr(const CallGraphNode *Caller,
306+
const CallGraphNode *Callee) {
308307
const auto *FoundCallee = llvm::find_if(
309308
Caller->callees(), [Callee](const CallGraphNode::CallRecord &Call) {
310309
return Call.Callee == Callee;
@@ -314,7 +313,7 @@ Expr *findCallExpr(const CallGraphNode *Caller, const CallGraphNode *Callee) {
314313
return FoundCallee->CallExpr;
315314
}
316315

317-
SourceRange getSourceRangeOfStmt(const Stmt *S, ASTContext &Ctx) {
316+
static SourceRange getSourceRangeOfStmt(const Stmt *S, ASTContext &Ctx) {
318317
ParentMapContext &PM = Ctx.getParentMapContext();
319318
DynTypedNode P = DynTypedNode::create(*S);
320319
while (P.getSourceRange().isInvalid()) {
@@ -326,9 +325,9 @@ SourceRange getSourceRangeOfStmt(const Stmt *S, ASTContext &Ctx) {
326325
return P.getSourceRange();
327326
}
328327

329-
AST_MATCHER(FunctionDecl, isStandardFunction) {
330-
return isStandardFunction(&Node);
331-
}
328+
namespace {
329+
330+
AST_MATCHER(FunctionDecl, isStandard) { return isStandardFunction(&Node); }
332331

333332
} // namespace
334333

@@ -354,7 +353,7 @@ bool SignalHandlerCheck::isLanguageVersionSupported(
354353

355354
void SignalHandlerCheck::registerMatchers(MatchFinder *Finder) {
356355
auto SignalFunction = functionDecl(hasAnyName("::signal", "::std::signal"),
357-
parameterCountIs(2), isStandardFunction());
356+
parameterCountIs(2), isStandard());
358357
auto HandlerExpr =
359358
declRefExpr(hasDeclaration(functionDecl().bind("handler_decl")),
360359
unless(isExpandedFromMacro("SIG_IGN")),

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;

0 commit comments

Comments
 (0)