Skip to content

Commit 511e855

Browse files
committed
merge main into amd-staging
2 parents d7cdd82 + 84a796d commit 511e855

File tree

77 files changed

+948
-399
lines changed

Some content is hidden

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

77 files changed

+948
-399
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
#include "TaggedUnionMemberCountCheck.h"
8989
#include "TerminatingContinueCheck.h"
9090
#include "ThrowKeywordMissingCheck.h"
91+
#include "ThrowingStaticInitializationCheck.h"
9192
#include "TooSmallLoopVariableCheck.h"
9293
#include "UncheckedOptionalAccessCheck.h"
9394
#include "UncheckedStringToNumberConversionCheck.h"
@@ -261,6 +262,8 @@ class BugproneModule : public ClangTidyModule {
261262
"bugprone-terminating-continue");
262263
CheckFactories.registerCheck<ThrowKeywordMissingCheck>(
263264
"bugprone-throw-keyword-missing");
265+
CheckFactories.registerCheck<ThrowingStaticInitializationCheck>(
266+
"bugprone-throwing-static-initialization");
264267
CheckFactories.registerCheck<TooSmallLoopVariableCheck>(
265268
"bugprone-too-small-loop-variable");
266269
CheckFactories.registerCheck<UncheckedOptionalAccessCheck>(

clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ add_clang_library(clangTidyBugproneModule STATIC
9090
TaggedUnionMemberCountCheck.cpp
9191
TerminatingContinueCheck.cpp
9292
ThrowKeywordMissingCheck.cpp
93+
ThrowingStaticInitializationCheck.cpp
9394
TooSmallLoopVariableCheck.cpp
9495
UncheckedOptionalAccessCheck.cpp
9596
UncheckedStringToNumberConversionCheck.cpp

clang-tools-extra/clang-tidy/cert/StaticObjectExceptionCheck.cpp renamed to clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "StaticObjectExceptionCheck.h"
9+
#include "ThrowingStaticInitializationCheck.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/ASTMatchers/ASTMatchFinder.h"
1212

1313
using namespace clang::ast_matchers;
1414

15-
namespace clang::tidy::cert {
15+
namespace clang::tidy::bugprone {
1616

17-
void StaticObjectExceptionCheck::registerMatchers(MatchFinder *Finder) {
17+
void ThrowingStaticInitializationCheck::registerMatchers(MatchFinder *Finder) {
1818
// Match any static or thread_local variable declaration that has an
1919
// initializer that can throw.
2020
Finder->addMatcher(
@@ -34,7 +34,8 @@ void StaticObjectExceptionCheck::registerMatchers(MatchFinder *Finder) {
3434
this);
3535
}
3636

37-
void StaticObjectExceptionCheck::check(const MatchFinder::MatchResult &Result) {
37+
void ThrowingStaticInitializationCheck::check(
38+
const MatchFinder::MatchResult &Result) {
3839
const auto *VD = Result.Nodes.getNodeAs<VarDecl>("var");
3940
const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>("func");
4041

@@ -52,4 +53,4 @@ void StaticObjectExceptionCheck::check(const MatchFinder::MatchResult &Result) {
5253
}
5354
}
5455

55-
} // namespace clang::tidy::cert
56+
} // namespace clang::tidy::bugprone

clang-tools-extra/clang-tidy/cert/StaticObjectExceptionCheck.h renamed to clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_ERR58_CPP_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_ERR58_CPP_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_THROWINGSTATICINITIALIZATIONCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_THROWINGSTATICINITIALIZATIONCHECK_H
1111

1212
#include "../ClangTidyCheck.h"
1313

14-
namespace clang::tidy::cert {
14+
namespace clang::tidy::bugprone {
1515

1616
/// Checks whether the constructor for a static or thread_local object will
1717
/// throw.
1818
///
1919
/// For the user-facing documentation see:
20-
/// http://clang.llvm.org/extra/clang-tidy/checks/cert/err58-cpp.html
21-
class StaticObjectExceptionCheck : public ClangTidyCheck {
20+
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/throwing-static-initialization.html
21+
class ThrowingStaticInitializationCheck : public ClangTidyCheck {
2222
public:
23-
StaticObjectExceptionCheck(StringRef Name, ClangTidyContext *Context)
23+
ThrowingStaticInitializationCheck(StringRef Name, ClangTidyContext *Context)
2424
: ClangTidyCheck(Name, Context) {}
2525
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
2626
return getLangOpts().CPlusPlus && getLangOpts().CXXExceptions;
@@ -29,6 +29,6 @@ class StaticObjectExceptionCheck : public ClangTidyCheck {
2929
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3030
};
3131

32-
} // namespace clang::tidy::cert
32+
} // namespace clang::tidy::bugprone
3333

34-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_ERR58_CPP_H
34+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_THROWINGSTATICINITIALIZATIONCHECK_H

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "../bugprone/SizeofExpressionCheck.h"
1818
#include "../bugprone/SpuriouslyWakeUpFunctionsCheck.h"
1919
#include "../bugprone/SuspiciousMemoryComparisonCheck.h"
20+
#include "../bugprone/ThrowingStaticInitializationCheck.h"
2021
#include "../bugprone/UncheckedStringToNumberConversionCheck.h"
2122
#include "../bugprone/UnhandledSelfAssignmentCheck.h"
2223
#include "../bugprone/UnsafeFunctionsCheck.h"
@@ -27,6 +28,7 @@
2728
#include "../misc/NonCopyableObjects.h"
2829
#include "../misc/StaticAssertCheck.h"
2930
#include "../misc/ThrowByValueCatchByReferenceCheck.h"
31+
#include "../modernize/AvoidVariadicFunctionsCheck.h"
3032
#include "../performance/MoveConstructorInitCheck.h"
3133
#include "../readability/EnumInitialValueCheck.h"
3234
#include "../readability/UppercaseLiteralSuffixCheck.h"
@@ -39,9 +41,7 @@
3941
#include "NonTrivialTypesLibcMemoryCallsCheck.h"
4042
#include "ProperlySeededRandomGeneratorCheck.h"
4143
#include "SetLongJmpCheck.h"
42-
#include "StaticObjectExceptionCheck.h"
4344
#include "ThrownExceptionTypeCheck.h"
44-
#include "VariadicFunctionDefCheck.h"
4545

4646
namespace {
4747

@@ -245,7 +245,8 @@ class CERTModule : public ClangTidyModule {
245245
.registerCheck<bugprone::PointerArithmeticOnPolymorphicObjectCheck>(
246246
"cert-ctr56-cpp");
247247
// DCL
248-
CheckFactories.registerCheck<VariadicFunctionDefCheck>("cert-dcl50-cpp");
248+
CheckFactories.registerCheck<modernize::AvoidVariadicFunctionsCheck>(
249+
"cert-dcl50-cpp");
249250
CheckFactories.registerCheck<bugprone::ReservedIdentifierCheck>(
250251
"cert-dcl51-cpp");
251252
CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>(
@@ -257,7 +258,8 @@ class CERTModule : public ClangTidyModule {
257258
CheckFactories.registerCheck<misc::ThrowByValueCatchByReferenceCheck>(
258259
"cert-err09-cpp");
259260
CheckFactories.registerCheck<SetLongJmpCheck>("cert-err52-cpp");
260-
CheckFactories.registerCheck<StaticObjectExceptionCheck>("cert-err58-cpp");
261+
CheckFactories.registerCheck<bugprone::ThrowingStaticInitializationCheck>(
262+
"cert-err58-cpp");
261263
CheckFactories.registerCheck<ThrownExceptionTypeCheck>("cert-err60-cpp");
262264
CheckFactories.registerCheck<misc::ThrowByValueCatchByReferenceCheck>(
263265
"cert-err61-cpp");

clang-tools-extra/clang-tidy/cert/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ add_clang_library(clangTidyCERTModule STATIC
1414
NonTrivialTypesLibcMemoryCallsCheck.cpp
1515
ProperlySeededRandomGeneratorCheck.cpp
1616
SetLongJmpCheck.cpp
17-
StaticObjectExceptionCheck.cpp
1817
ThrownExceptionTypeCheck.cpp
19-
VariadicFunctionDefCheck.cpp
2018

2119
LINK_LIBS
2220
clangTidy
2321
clangTidyBugproneModule
2422
clangTidyConcurrencyModule
2523
clangTidyGoogleModule
2624
clangTidyMiscModule
25+
clangTidyModernizeModule
2726
clangTidyPerformanceModule
2827
clangTidyReadabilityModule
2928
clangTidyUtils

clang-tools-extra/clang-tidy/cert/VariadicFunctionDefCheck.cpp renamed to clang-tools-extra/clang-tidy/modernize/AvoidVariadicFunctionsCheck.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "VariadicFunctionDefCheck.h"
9+
#include "AvoidVariadicFunctionsCheck.h"
1010
#include "clang/ASTMatchers/ASTMatchFinder.h"
1111

1212
using namespace clang::ast_matchers;
1313

14-
namespace clang::tidy::cert {
14+
namespace clang::tidy::modernize {
1515

16-
void VariadicFunctionDefCheck::registerMatchers(MatchFinder *Finder) {
16+
void AvoidVariadicFunctionsCheck::registerMatchers(MatchFinder *Finder) {
1717
// We only care about function *definitions* that are variadic, and do not
1818
// have extern "C" language linkage.
1919
Finder->addMatcher(
@@ -22,12 +22,13 @@ void VariadicFunctionDefCheck::registerMatchers(MatchFinder *Finder) {
2222
this);
2323
}
2424

25-
void VariadicFunctionDefCheck::check(const MatchFinder::MatchResult &Result) {
25+
void AvoidVariadicFunctionsCheck::check(
26+
const MatchFinder::MatchResult &Result) {
2627
const auto *FD = Result.Nodes.getNodeAs<FunctionDecl>("func");
2728

2829
diag(FD->getLocation(),
2930
"do not define a C-style variadic function; consider using a function "
3031
"parameter pack or currying instead");
3132
}
3233

33-
} // namespace clang::tidy::cert
34+
} // namespace clang::tidy::modernize

clang-tools-extra/clang-tidy/cert/VariadicFunctionDefCheck.h renamed to clang-tools-extra/clang-tidy/modernize/AvoidVariadicFunctionsCheck.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_VARIADICFUNCTIONDEF_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_VARIADICFUNCTIONDEF_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_AVOIDVARIADICFUNCTIONSCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_AVOIDVARIADICFUNCTIONSCHECK_H
1111

1212
#include "../ClangTidyCheck.h"
1313

14-
namespace clang::tidy::cert {
14+
namespace clang::tidy::modernize {
1515

16-
/// Guards against any C-style variadic function definitions (not declarations).
16+
/// Find all function definitions of C-style variadic functions.
1717
///
1818
/// For the user-facing documentation see:
19-
/// http://clang.llvm.org/extra/clang-tidy/checks/cert/dcl50-cpp.html
20-
class VariadicFunctionDefCheck : public ClangTidyCheck {
19+
/// http://clang.llvm.org/extra/clang-tidy/checks/modernize/avoid-variadic-functions.html
20+
class AvoidVariadicFunctionsCheck : public ClangTidyCheck {
2121
public:
22-
VariadicFunctionDefCheck(StringRef Name, ClangTidyContext *Context)
22+
AvoidVariadicFunctionsCheck(StringRef Name, ClangTidyContext *Context)
2323
: ClangTidyCheck(Name, Context) {}
2424
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
2525
return LangOpts.CPlusPlus;
@@ -28,6 +28,6 @@ class VariadicFunctionDefCheck : public ClangTidyCheck {
2828
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
2929
};
3030

31-
} // namespace clang::tidy::cert
31+
} // namespace clang::tidy::modernize
3232

33-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_VARIADICFUNCTIONDEF_H
33+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_AVOIDVARIADICFUNCTIONSCHECK_H

clang-tools-extra/clang-tidy/modernize/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
66
add_clang_library(clangTidyModernizeModule STATIC
77
AvoidBindCheck.cpp
88
AvoidCArraysCheck.cpp
9+
AvoidVariadicFunctionsCheck.cpp
910
ConcatNestedNamespacesCheck.cpp
1011
DeprecatedHeadersCheck.cpp
1112
DeprecatedIosBaseAliasesCheck.cpp

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "../ClangTidyModuleRegistry.h"
1212
#include "AvoidBindCheck.h"
1313
#include "AvoidCArraysCheck.h"
14+
#include "AvoidVariadicFunctionsCheck.h"
1415
#include "ConcatNestedNamespacesCheck.h"
1516
#include "DeprecatedHeadersCheck.h"
1617
#include "DeprecatedIosBaseAliasesCheck.h"
@@ -63,6 +64,8 @@ class ModernizeModule : public ClangTidyModule {
6364
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
6465
CheckFactories.registerCheck<AvoidBindCheck>("modernize-avoid-bind");
6566
CheckFactories.registerCheck<AvoidCArraysCheck>("modernize-avoid-c-arrays");
67+
CheckFactories.registerCheck<AvoidVariadicFunctionsCheck>(
68+
"modernize-avoid-variadic-functions");
6669
CheckFactories.registerCheck<ConcatNestedNamespacesCheck>(
6770
"modernize-concat-nested-namespaces");
6871
CheckFactories.registerCheck<DeprecatedHeadersCheck>(

0 commit comments

Comments
 (0)