Skip to content

Commit d6992d8

Browse files
authored
merge main into amd-staging (llvm#3696)
2 parents 5b2283d + 8076a02 commit d6992d8

File tree

258 files changed

+47053
-12130
lines changed

Some content is hidden

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

258 files changed

+47053
-12130
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ using namespace clang::ast_matchers;
1515

1616
namespace clang::tidy::bugprone {
1717

18-
namespace {
19-
2018
// Determine if the result of an expression is "stored" in some way.
2119
// It is true if the value is stored into a variable or used as initialization
2220
// or passed to a function or constructor.
2321
// For this use case compound assignments are not counted as a "store" (the 'E'
2422
// expression should have pointer type).
25-
bool isExprValueStored(const Expr *E, ASTContext &C) {
23+
static bool isExprValueStored(const Expr *E, ASTContext &C) {
2624
E = E->IgnoreParenCasts();
2725
// Get first non-paren, non-cast parent.
2826
ParentMapContext &PMap = C.getParentMapContext();
@@ -49,6 +47,8 @@ bool isExprValueStored(const Expr *E, ASTContext &C) {
4947
return isa<CallExpr, CXXConstructExpr>(ParentE);
5048
}
5149

50+
namespace {
51+
5252
AST_MATCHER_P(CXXTryStmt, hasHandlerFor,
5353
ast_matchers::internal::Matcher<QualType>, InnerMatcher) {
5454
for (unsigned NH = Node.getNumHandlers(), I = 0; I < NH; ++I) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ using namespace clang::ast_matchers;
1414

1515
namespace clang::tidy::bugprone {
1616

17-
namespace {
18-
19-
bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx,
20-
const StringLiteral *Lit) {
17+
static bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx,
18+
const StringLiteral *Lit) {
2119
// String literals surrounded by parentheses are assumed to be on purpose.
2220
// i.e.: const char* Array[] = { ("a" "b" "c"), "d", [...] };
2321

@@ -58,6 +56,8 @@ bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx,
5856
return false;
5957
}
6058

59+
namespace {
60+
6161
AST_MATCHER_P(StringLiteral, isConcatenatedLiteral, unsigned,
6262
MaxConcatenatedTokens) {
6363
return Node.getNumConcatenated() > 1 &&

clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ enum class ConversionKind {
4646
ToLongDouble
4747
};
4848

49-
ConversionKind classifyConversionFunc(const FunctionDecl *FD) {
49+
} // namespace
50+
51+
static ConversionKind classifyConversionFunc(const FunctionDecl *FD) {
5052
return llvm::StringSwitch<ConversionKind>(FD->getName())
5153
.Cases("atoi", "atol", ConversionKind::ToInt)
5254
.Case("atoll", ConversionKind::ToLongInt)
5355
.Case("atof", ConversionKind::ToDouble)
5456
.Default(ConversionKind::None);
5557
}
5658

57-
ConversionKind classifyFormatString(StringRef Fmt, const LangOptions &LO,
58-
const TargetInfo &TI) {
59+
static ConversionKind classifyFormatString(StringRef Fmt, const LangOptions &LO,
60+
const TargetInfo &TI) {
5961
// Scan the format string for the first problematic format specifier, then
6062
// report that as the conversion type. This will miss additional conversion
6163
// specifiers, but that is acceptable behavior.
@@ -128,7 +130,7 @@ ConversionKind classifyFormatString(StringRef Fmt, const LangOptions &LO,
128130
return H.get();
129131
}
130132

131-
StringRef classifyConversionType(ConversionKind K) {
133+
static StringRef classifyConversionType(ConversionKind K) {
132134
switch (K) {
133135
case ConversionKind::None:
134136
llvm_unreachable("Unexpected conversion kind");
@@ -148,7 +150,7 @@ StringRef classifyConversionType(ConversionKind K) {
148150
llvm_unreachable("Unknown conversion kind");
149151
}
150152

151-
StringRef classifyReplacement(ConversionKind K) {
153+
static StringRef classifyReplacement(ConversionKind K) {
152154
switch (K) {
153155
case ConversionKind::None:
154156
llvm_unreachable("Unexpected conversion kind");
@@ -173,7 +175,6 @@ StringRef classifyReplacement(ConversionKind K) {
173175
}
174176
llvm_unreachable("Unknown conversion kind");
175177
}
176-
} // unnamed namespace
177178

178179
void StrToNumCheck::check(const MatchFinder::MatchResult &Result) {
179180
const auto *Call = Result.Nodes.getNodeAs<CallExpr>("expr");

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ AST_MATCHER(FunctionDecl, isPlacementOverload) {
5959
return true;
6060
}
6161

62-
OverloadedOperatorKind getCorrespondingOverload(const FunctionDecl *FD) {
62+
} // namespace
63+
64+
static OverloadedOperatorKind getCorrespondingOverload(const FunctionDecl *FD) {
6365
switch (FD->getOverloadedOperator()) {
6466
default:
6567
break;
@@ -75,7 +77,7 @@ OverloadedOperatorKind getCorrespondingOverload(const FunctionDecl *FD) {
7577
llvm_unreachable("Not an overloaded allocation operator");
7678
}
7779

78-
const char *getOperatorName(OverloadedOperatorKind K) {
80+
static const char *getOperatorName(OverloadedOperatorKind K) {
7981
switch (K) {
8082
default:
8183
break;
@@ -91,13 +93,14 @@ const char *getOperatorName(OverloadedOperatorKind K) {
9193
llvm_unreachable("Not an overloaded allocation operator");
9294
}
9395

94-
bool areCorrespondingOverloads(const FunctionDecl *LHS,
95-
const FunctionDecl *RHS) {
96+
static bool areCorrespondingOverloads(const FunctionDecl *LHS,
97+
const FunctionDecl *RHS) {
9698
return RHS->getOverloadedOperator() == getCorrespondingOverload(LHS);
9799
}
98100

99-
bool hasCorrespondingOverloadInBaseClass(const CXXMethodDecl *MD,
100-
const CXXRecordDecl *RD = nullptr) {
101+
static bool
102+
hasCorrespondingOverloadInBaseClass(const CXXMethodDecl *MD,
103+
const CXXRecordDecl *RD = nullptr) {
101104
if (RD) {
102105
// Check the methods in the given class and accessible to derived classes.
103106
for (const auto *BMD : RD->methods())
@@ -124,8 +127,6 @@ bool hasCorrespondingOverloadInBaseClass(const CXXMethodDecl *MD,
124127
return false;
125128
}
126129

127-
} // anonymous namespace
128-
129130
void NewDeleteOverloadsCheck::registerMatchers(MatchFinder *Finder) {
130131
// Match all operator new and operator delete overloads (including the array
131132
// forms). Do not match implicit operators, placement operators, or

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,12 @@ void MacroToEnumCallbacks::Endif(SourceLocation Loc, SourceLocation IfLoc) {
395395
--CurrentFile->ConditionScopes;
396396
}
397397

398-
namespace {
399-
400398
template <size_t N>
401-
bool textEquals(const char (&Needle)[N], const char *HayStack) {
399+
static bool textEquals(const char (&Needle)[N], const char *HayStack) {
402400
return StringRef{HayStack, N - 1} == Needle;
403401
}
404402

405-
template <size_t N> size_t len(const char (&)[N]) { return N - 1; }
406-
407-
} // namespace
403+
template <size_t N> static size_t len(const char (&)[N]) { return N - 1; }
408404

409405
void MacroToEnumCallbacks::PragmaDirective(SourceLocation Loc,
410406
PragmaIntroducerKind Introducer) {

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ using namespace clang::ast_matchers;
1616

1717
namespace clang::tidy::modernize {
1818

19-
namespace {
19+
static constexpr char ConstructorCall[] = "constructorCall";
20+
static constexpr char ResetCall[] = "resetCall";
21+
static constexpr char NewExpression[] = "newExpression";
2022

21-
constexpr char ConstructorCall[] = "constructorCall";
22-
constexpr char ResetCall[] = "resetCall";
23-
constexpr char NewExpression[] = "newExpression";
24-
25-
std::string getNewExprName(const CXXNewExpr *NewExpr, const SourceManager &SM,
26-
const LangOptions &Lang) {
23+
static std::string getNewExprName(const CXXNewExpr *NewExpr,
24+
const SourceManager &SM,
25+
const LangOptions &Lang) {
2726
StringRef WrittenName = Lexer::getSourceText(
2827
CharSourceRange::getTokenRange(
2928
NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
@@ -34,8 +33,6 @@ std::string getNewExprName(const CXXNewExpr *NewExpr, const SourceManager &SM,
3433
return WrittenName.str();
3534
}
3635

37-
} // namespace
38-
3936
const char MakeSmartPtrCheck::PointerType[] = "pointerType";
4037

4138
MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ using namespace clang::ast_matchers;
1919

2020
namespace clang::tidy::modernize {
2121

22-
namespace {
23-
24-
bool containsEscapes(StringRef HayStack, StringRef Escapes) {
22+
static bool containsEscapes(StringRef HayStack, StringRef Escapes) {
2523
size_t BackSlash = HayStack.find('\\');
2624
if (BackSlash == StringRef::npos)
2725
return false;
@@ -35,16 +33,16 @@ bool containsEscapes(StringRef HayStack, StringRef Escapes) {
3533
return true;
3634
}
3735

38-
bool isRawStringLiteral(StringRef Text) {
36+
static bool isRawStringLiteral(StringRef Text) {
3937
// Already a raw string literal if R comes before ".
4038
const size_t QuotePos = Text.find('"');
4139
assert(QuotePos != StringRef::npos);
4240
return (QuotePos > 0) && (Text[QuotePos - 1] == 'R');
4341
}
4442

45-
bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
46-
const StringLiteral *Literal,
47-
const CharsBitSet &DisallowedChars) {
43+
static bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
44+
const StringLiteral *Literal,
45+
const CharsBitSet &DisallowedChars) {
4846
// FIXME: Handle L"", u8"", u"" and U"" literals.
4947
if (!Literal->isOrdinary())
5048
return false;
@@ -64,14 +62,12 @@ bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
6462
return containsEscapes(Text, R"('\"?x01)");
6563
}
6664

67-
bool containsDelimiter(StringRef Bytes, const std::string &Delimiter) {
65+
static bool containsDelimiter(StringRef Bytes, const std::string &Delimiter) {
6866
return Bytes.find(Delimiter.empty()
6967
? std::string(R"lit()")lit")
7068
: (")" + Delimiter + R"(")")) != StringRef::npos;
7169
}
7270

73-
} // namespace
74-
7571
RawStringLiteralCheck::RawStringLiteralCheck(StringRef Name,
7672
ClangTidyContext *Context)
7773
: ClangTidyCheck(Name, Context),

clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@
2929
using namespace clang::ast_matchers;
3030

3131
namespace clang::tidy::objc {
32-
namespace {
3332

3433
static constexpr StringRef WeakText = "__weak";
3534
static constexpr StringRef StrongText = "__strong";
3635
static constexpr StringRef UnsafeUnretainedText = "__unsafe_unretained";
3736

37+
namespace {
38+
3839
/// Matches ObjCIvarRefExpr, DeclRefExpr, or MemberExpr that reference
3940
/// Objective-C object (or block) variables or fields whose object lifetimes
4041
/// are not __unsafe_unretained.
@@ -49,6 +50,8 @@ AST_POLYMORPHIC_MATCHER(isObjCManagedLifetime,
4950
QT.getQualifiers().getObjCLifetime() > Qualifiers::OCL_ExplicitNone;
5051
}
5152

53+
} // namespace
54+
5255
static std::optional<FixItHint>
5356
fixItHintReplacementForOwnershipString(StringRef Text, CharSourceRange Range,
5457
StringRef Ownership) {
@@ -93,8 +96,6 @@ fixItHintForVarDecl(const VarDecl *VD, const SourceManager &SM,
9396
return FixItHint::CreateInsertion(Range.getBegin(), "__unsafe_unretained ");
9497
}
9598

96-
} // namespace
97-
9899
void NSInvocationArgumentLifetimeCheck::registerMatchers(MatchFinder *Finder) {
99100
Finder->addMatcher(
100101
traverse(

clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ enum NamingStyle {
2727
CategoryProperty = 2,
2828
};
2929

30+
} // namespace
31+
3032
/// For now we will only fix 'CamelCase' or 'abc_CamelCase' property to
3133
/// 'camelCase' or 'abc_camelCase'. For other cases the users need to
3234
/// come up with a proper name by their own.
3335
/// FIXME: provide fix for snake_case to snakeCase
34-
FixItHint generateFixItHint(const ObjCPropertyDecl *Decl, NamingStyle Style) {
36+
static FixItHint generateFixItHint(const ObjCPropertyDecl *Decl,
37+
NamingStyle Style) {
3538
auto Name = Decl->getName();
3639
auto NewName = Decl->getName().str();
3740
size_t Index = 0;
@@ -50,7 +53,7 @@ FixItHint generateFixItHint(const ObjCPropertyDecl *Decl, NamingStyle Style) {
5053
return {};
5154
}
5255

53-
std::string validPropertyNameRegex(bool UsedInMatcher) {
56+
static std::string validPropertyNameRegex(bool UsedInMatcher) {
5457
// Allow any of these names:
5558
// foo
5659
// fooBar
@@ -72,13 +75,13 @@ std::string validPropertyNameRegex(bool UsedInMatcher) {
7275
return StartMatcher + "([a-z]|[A-Z][A-Z0-9])[a-z0-9A-Z]*$";
7376
}
7477

75-
bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
78+
static bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
7679
auto RegexExp =
7780
llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
7881
return RegexExp.match(PropertyName);
7982
}
8083

81-
bool prefixedPropertyNameValid(llvm::StringRef PropertyName) {
84+
static bool prefixedPropertyNameValid(llvm::StringRef PropertyName) {
8285
size_t Start = PropertyName.find_first_of('_');
8386
assert(Start != llvm::StringRef::npos && Start + 1 < PropertyName.size());
8487
auto Prefix = PropertyName.substr(0, Start);
@@ -88,7 +91,6 @@ bool prefixedPropertyNameValid(llvm::StringRef PropertyName) {
8891
auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
8992
return RegexExp.match(PropertyName.substr(Start + 1));
9093
}
91-
} // namespace
9294

9395
void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
9496
Finder->addMatcher(objcPropertyDecl(

0 commit comments

Comments
 (0)