https://github.com/IamYJLee updated https://github.com/llvm/llvm-project/pull/183474
>From 1c94a3dc9b1a9bbf9ac10e65e78565b0e9e63536 Mon Sep 17 00:00:00 2001 From: LeeYoungJoon <[email protected]> Date: Thu, 26 Feb 2026 17:16:46 +0900 Subject: [PATCH 1/6] [clang-tidy] Rename hicpp-exception-baseclass to bugprone-exception-baseclass --- .../clang-tidy/bugprone/BugproneTidyModule.cpp | 3 +++ clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt | 1 + .../{hicpp => bugprone}/ExceptionBaseclassCheck.cpp | 4 ++-- .../{hicpp => bugprone}/ExceptionBaseclassCheck.h | 10 +++++----- clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt | 1 - clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp | 4 +--- clang-tools-extra/clangd/TidyFastChecks.inc | 2 +- .../checks/{hicpp => bugprone}/exception-baseclass.rst | 4 ++-- clang-tools-extra/docs/clang-tidy/checks/list.rst | 2 +- .../clang-tidy/checkers/hicpp/exception-baseclass.cpp | 2 +- 10 files changed, 17 insertions(+), 16 deletions(-) rename clang-tools-extra/clang-tidy/{hicpp => bugprone}/ExceptionBaseclassCheck.cpp (97%) rename clang-tools-extra/clang-tidy/{hicpp => bugprone}/ExceptionBaseclassCheck.h (77%) rename clang-tools-extra/docs/clang-tidy/checks/{hicpp => bugprone}/exception-baseclass.rst (89%) diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp index 310184037afbd..45bce2aabbed0 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -29,6 +29,7 @@ #include "DynamicStaticInitializersCheck.h" #include "EasilySwappableParametersCheck.h" #include "EmptyCatchCheck.h" +#include "ExceptionBaseclassCheck.h" #include "ExceptionCopyConstructorThrowsCheck.h" #include "ExceptionEscapeCheck.h" #include "FloatLoopCounterCheck.h" @@ -158,6 +159,8 @@ class BugproneModule : public ClangTidyModule { CheckFactories.registerCheck<EasilySwappableParametersCheck>( "bugprone-easily-swappable-parameters"); CheckFactories.registerCheck<EmptyCatchCheck>("bugprone-empty-catch"); + CheckFactories.registerCheck<ExceptionBaseclassCheck>( + "bugprone-exception-baseclass"); CheckFactories.registerCheck<ExceptionCopyConstructorThrowsCheck>( "bugprone-exception-copy-constructor-throws"); CheckFactories.registerCheck<ExceptionEscapeCheck>( diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt index 96ad671d03b39..e272793b4b21f 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt @@ -26,6 +26,7 @@ add_clang_library(clangTidyBugproneModule STATIC DynamicStaticInitializersCheck.cpp EasilySwappableParametersCheck.cpp EmptyCatchCheck.cpp + ExceptionBaseclassCheck.cpp ExceptionCopyConstructorThrowsCheck.cpp ExceptionEscapeCheck.cpp FloatLoopCounterCheck.cpp diff --git a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp similarity index 97% rename from clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp index 71b82875c09a0..625ed48ef3cf5 100644 --- a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp @@ -12,7 +12,7 @@ using namespace clang::ast_matchers; -namespace clang::tidy::hicpp { +namespace clang::tidy::bugprone { void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( @@ -54,4 +54,4 @@ void ExceptionBaseclassCheck::check(const MatchFinder::MatchResult &Result) { diag(TypeDecl->getBeginLoc(), "type defined here", DiagnosticIDs::Note); } -} // namespace clang::tidy::hicpp +} // namespace clang::tidy::bugprone diff --git a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h similarity index 77% rename from clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h rename to clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h index 800e7ac9663d5..4a589aebde99f 100644 --- a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h @@ -6,12 +6,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTIONBASECLASSCHECK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTIONBASECLASSCHECK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H #include "../ClangTidyCheck.h" -namespace clang::tidy::hicpp { +namespace clang::tidy::bugprone { /// Check for thrown exceptions and enforce they are all derived from /// std::exception. @@ -29,6 +29,6 @@ class ExceptionBaseclassCheck : public ClangTidyCheck { void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace clang::tidy::hicpp +} // namespace clang::tidy::bugprone -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTIONBASECLASSCHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H diff --git a/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt b/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt index 2f31d168e65c0..e3fc26d662132 100644 --- a/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt @@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS ) add_clang_library(clangTidyHICPPModule STATIC - ExceptionBaseclassCheck.cpp HICPPTidyModule.cpp IgnoredRemoveResultCheck.cpp MultiwayPathsCoveredCheck.cpp diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp index 2e0e64fbcd2a1..4ea7eaf5b5973 100644 --- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp @@ -8,6 +8,7 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" +#include "../bugprone/ExceptionBaseclassCheck.h" #include "../bugprone/UndelegatedConstructorCheck.h" #include "../bugprone/UseAfterMoveCheck.h" #include "../cppcoreguidelines/AvoidGotoCheck.h" @@ -34,7 +35,6 @@ #include "../readability/FunctionSizeCheck.h" #include "../readability/NamedParameterCheck.h" #include "../readability/UppercaseLiteralSuffixCheck.h" -#include "ExceptionBaseclassCheck.h" #include "IgnoredRemoveResultCheck.h" #include "MultiwayPathsCoveredCheck.h" #include "NoAssemblerCheck.h" @@ -55,8 +55,6 @@ class HICPPModule : public ClangTidyModule { "hicpp-braces-around-statements"); CheckFactories.registerCheck<modernize::DeprecatedHeadersCheck>( "hicpp-deprecated-headers"); - CheckFactories.registerCheck<ExceptionBaseclassCheck>( - "hicpp-exception-baseclass"); CheckFactories.registerCheck<IgnoredRemoveResultCheck>( "hicpp-ignored-remove-result"); CheckFactories.registerCheck<MultiwayPathsCoveredCheck>( diff --git a/clang-tools-extra/clangd/TidyFastChecks.inc b/clang-tools-extra/clangd/TidyFastChecks.inc index de1a025602fa9..e5d7711b201cb 100644 --- a/clang-tools-extra/clangd/TidyFastChecks.inc +++ b/clang-tools-extra/clangd/TidyFastChecks.inc @@ -63,6 +63,7 @@ FAST(bugprone-dangling-handle, -0.0) FAST(bugprone-dynamic-static-initializers, 0.0) FAST(bugprone-easily-swappable-parameters, 2.0) FAST(bugprone-empty-catch, 1.0) +FAST(bugprone-exception-baseclass, -1.0) FAST(bugprone-exception-escape, 0.0) FAST(bugprone-fold-init-type, 1.0) FAST(bugprone-forward-declaration-namespace, 0.0) @@ -247,7 +248,6 @@ FAST(hicpp-avoid-c-arrays, 1.0) FAST(hicpp-avoid-goto, -0.0) FAST(hicpp-braces-around-statements, 0.0) FAST(hicpp-deprecated-headers, 1.0) -FAST(hicpp-exception-baseclass, -1.0) FAST(hicpp-explicit-conversions, 1.0) FAST(hicpp-function-size, 1.0) FAST(hicpp-ignored-remove-result, 3.0) diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst similarity index 89% rename from clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst rename to clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst index 7a1c1a07c49e3..b166df8897f8b 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst @@ -1,6 +1,6 @@ -.. title:: clang-tidy - hicpp-exception-baseclass +.. title:: clang-tidy - bugprone-exception-baseclass -hicpp-exception-baseclass +bugprone-exception-baseclass ========================= Ensure that every value that in a ``throw`` expression is an instance of diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index c475870ed7b31..e81ec6a85419d 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -99,6 +99,7 @@ Clang-Tidy Checks :doc:`bugprone-dynamic-static-initializers <bugprone/dynamic-static-initializers>`, :doc:`bugprone-easily-swappable-parameters <bugprone/easily-swappable-parameters>`, :doc:`bugprone-empty-catch <bugprone/empty-catch>`, + :doc:`bugprone-exception-baseclass <bugprone/exception-baseclass>`, :doc:`bugprone-exception-copy-constructor-throws <bugprone/exception-copy-constructor-throws>`, :doc:`bugprone-exception-escape <bugprone/exception-escape>`, :doc:`bugprone-float-loop-counter <bugprone/float-loop-counter>`, @@ -240,7 +241,6 @@ Clang-Tidy Checks :doc:`google-runtime-int <google/runtime-int>`, :doc:`google-runtime-operator <google/runtime-operator>`, :doc:`google-upgrade-googletest-case <google/upgrade-googletest-case>`, "Yes" - :doc:`hicpp-exception-baseclass <hicpp/exception-baseclass>`, :doc:`hicpp-ignored-remove-result <hicpp/ignored-remove-result>`, :doc:`hicpp-multiway-paths-covered <hicpp/multiway-paths-covered>`, :doc:`hicpp-no-assembler <hicpp/no-assembler>`, diff --git a/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp b/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp index b5e405a691848..4bf52936c0b63 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s hicpp-exception-baseclass %t -- -- -fcxx-exceptions +// RUN: %check_clang_tidy %s bugprone-exception-baseclass %t -- -- -fcxx-exceptions namespace std { class exception {}; >From 1aee8d157e4eb6d4b130e1419da21c45179ecc66 Mon Sep 17 00:00:00 2001 From: LeeYoungJoon <[email protected]> Date: Thu, 26 Feb 2026 17:28:42 +0900 Subject: [PATCH 2/6] [clang-tidy] Move test case --- .../checkers/{hicpp => bugprone}/exception-baseclass.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename clang-tools-extra/test/clang-tidy/checkers/{hicpp => bugprone}/exception-baseclass.cpp (100%) diff --git a/clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp similarity index 100% rename from clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp rename to clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp >From 11835363d91476369c5e2fe76d06b761fb8bc421 Mon Sep 17 00:00:00 2001 From: LeeYoungJoon <[email protected]> Date: Fri, 27 Feb 2026 11:18:37 +0900 Subject: [PATCH 3/6] [clang-tidy] Address review feedback: keep alias --- .../clang-tidy/bugprone/ExceptionBaseclassCheck.h | 2 +- clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp | 2 ++ clang-tools-extra/clangd/TidyFastChecks.inc | 2 +- .../clang-tidy/checks/bugprone/exception-baseclass.rst | 5 +---- .../clang-tidy/checks/hicpp/exception-baseclass.rst | 10 ++++++++++ clang-tools-extra/docs/clang-tidy/checks/list.rst | 1 + 6 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h index 4a589aebde99f..d5728b843ec19 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h @@ -17,7 +17,7 @@ namespace clang::tidy::bugprone { /// std::exception. /// /// For the user-facing documentation see: -/// https://clang.llvm.org/extra/clang-tidy/checks/hicpp/exception-baseclass.html +/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/exception-baseclass.html class ExceptionBaseclassCheck : public ClangTidyCheck { public: ExceptionBaseclassCheck(StringRef Name, ClangTidyContext *Context) diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp index 4ea7eaf5b5973..11f1c7fb82678 100644 --- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp @@ -55,6 +55,8 @@ class HICPPModule : public ClangTidyModule { "hicpp-braces-around-statements"); CheckFactories.registerCheck<modernize::DeprecatedHeadersCheck>( "hicpp-deprecated-headers"); + CheckFactories.registerCheck<bugprone::ExceptionBaseclassCheck>( + "hicpp-exception-baseclass"); CheckFactories.registerCheck<IgnoredRemoveResultCheck>( "hicpp-ignored-remove-result"); CheckFactories.registerCheck<MultiwayPathsCoveredCheck>( diff --git a/clang-tools-extra/clangd/TidyFastChecks.inc b/clang-tools-extra/clangd/TidyFastChecks.inc index e5d7711b201cb..de1a025602fa9 100644 --- a/clang-tools-extra/clangd/TidyFastChecks.inc +++ b/clang-tools-extra/clangd/TidyFastChecks.inc @@ -63,7 +63,6 @@ FAST(bugprone-dangling-handle, -0.0) FAST(bugprone-dynamic-static-initializers, 0.0) FAST(bugprone-easily-swappable-parameters, 2.0) FAST(bugprone-empty-catch, 1.0) -FAST(bugprone-exception-baseclass, -1.0) FAST(bugprone-exception-escape, 0.0) FAST(bugprone-fold-init-type, 1.0) FAST(bugprone-forward-declaration-namespace, 0.0) @@ -248,6 +247,7 @@ FAST(hicpp-avoid-c-arrays, 1.0) FAST(hicpp-avoid-goto, -0.0) FAST(hicpp-braces-around-statements, 0.0) FAST(hicpp-deprecated-headers, 1.0) +FAST(hicpp-exception-baseclass, -1.0) FAST(hicpp-explicit-conversions, 1.0) FAST(hicpp-function-size, 1.0) FAST(hicpp-ignored-remove-result, 3.0) diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst index b166df8897f8b..8fd9c6093a3f4 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst @@ -1,14 +1,11 @@ .. title:: clang-tidy - bugprone-exception-baseclass bugprone-exception-baseclass -========================= +============================ Ensure that every value that in a ``throw`` expression is an instance of ``std::exception``. -This enforces `rule 15.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-rules>`_ -of the High Integrity C++ Coding Standard. - .. code-block:: c++ class custom_exception {}; diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst new file mode 100644 index 0000000000000..e7e25b0aa4a87 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst @@ -0,0 +1,10 @@ +.. title:: clang-tidy - hicpp-exception-baseclass +.. meta:: + :http-equiv=refresh: 5;URL=../bugprone/exception-baseclass.html + +hicpp-exception-baseclass +========================= + +The `hicpp-exception-baseclass` check is an alias, please see +`bugprone-exception-baseclass <../bugprone/exception-baseclass.html>`_ +for more information. \ No newline at end of file diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index e81ec6a85419d..c2f6aa1b8b2df 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -599,6 +599,7 @@ Check aliases :doc:`hicpp-avoid-goto <hicpp/avoid-goto>`, :doc:`cppcoreguidelines-avoid-goto <cppcoreguidelines/avoid-goto>`, :doc:`hicpp-braces-around-statements <hicpp/braces-around-statements>`, :doc:`readability-braces-around-statements <readability/braces-around-statements>`, "Yes" :doc:`hicpp-deprecated-headers <hicpp/deprecated-headers>`, :doc:`modernize-deprecated-headers <modernize/deprecated-headers>`, "Yes" + :doc:`hicpp-exception-baseclass <hicpp/exception-baseclass>`, :doc:`bugprone-exception-baseclass <bugprone/exception-baseclass>`, :doc:`hicpp-explicit-conversions <hicpp/explicit-conversions>`, :doc:`google-explicit-constructor <google/explicit-constructor>`, "Yes" :doc:`hicpp-function-size <hicpp/function-size>`, :doc:`readability-function-size <readability/function-size>`, :doc:`hicpp-invalid-access-moved <hicpp/invalid-access-moved>`, :doc:`bugprone-use-after-move <bugprone/use-after-move>`, >From 95907750931e950a822d1852059aeac54955a230 Mon Sep 17 00:00:00 2001 From: LeeYoungJoon <[email protected]> Date: Fri, 27 Feb 2026 11:39:42 +0900 Subject: [PATCH 4/6] [clang-tidy] Fix RST documentation linter issues --- .../docs/clang-tidy/checks/hicpp/exception-baseclass.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst index e7e25b0aa4a87..bb570d618093e 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst @@ -1,10 +1,10 @@ .. title:: clang-tidy - hicpp-exception-baseclass .. meta:: - :http-equiv=refresh: 5;URL=../bugprone/exception-baseclass.html + :http-equiv=refresh: 5;URL=../bugprone/exception-baseclass.html hicpp-exception-baseclass ========================= The `hicpp-exception-baseclass` check is an alias, please see `bugprone-exception-baseclass <../bugprone/exception-baseclass.html>`_ -for more information. \ No newline at end of file +for more information. >From 6b5c047c099056afe8dce6ce5c402bbe69c40d88 Mon Sep 17 00:00:00 2001 From: LeeYoungJoon <[email protected]> Date: Tue, 3 Mar 2026 12:30:47 +0900 Subject: [PATCH 5/6] [clang-tidy] Add 'Std' prefix to related files and tests --- .../clang-tidy/bugprone/BugproneTidyModule.cpp | 6 +++--- clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt | 2 +- ...classCheck.cpp => StdExceptionBaseclassCheck.cpp} | 6 +++--- ...BaseclassCheck.h => StdExceptionBaseclassCheck.h} | 12 ++++++------ .../clang-tidy/hicpp/HICPPTidyModule.cpp | 4 ++-- ...ion-baseclass.rst => std-exception-baseclass.rst} | 6 +++--- .../clang-tidy/checks/hicpp/exception-baseclass.rst | 4 ++-- clang-tools-extra/docs/clang-tidy/checks/list.rst | 4 ++-- ...ion-baseclass.cpp => std-exception-baseclass.cpp} | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) rename clang-tools-extra/clang-tidy/bugprone/{ExceptionBaseclassCheck.cpp => StdExceptionBaseclassCheck.cpp} (92%) rename clang-tools-extra/clang-tidy/bugprone/{ExceptionBaseclassCheck.h => StdExceptionBaseclassCheck.h} (66%) rename clang-tools-extra/docs/clang-tidy/checks/bugprone/{exception-baseclass.rst => std-exception-baseclass.rst} (80%) rename clang-tools-extra/test/clang-tidy/checkers/bugprone/{exception-baseclass.cpp => std-exception-baseclass.cpp} (99%) diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp index 45bce2aabbed0..c6a6eac988c1e 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -29,7 +29,6 @@ #include "DynamicStaticInitializersCheck.h" #include "EasilySwappableParametersCheck.h" #include "EmptyCatchCheck.h" -#include "ExceptionBaseclassCheck.h" #include "ExceptionCopyConstructorThrowsCheck.h" #include "ExceptionEscapeCheck.h" #include "FloatLoopCounterCheck.h" @@ -77,6 +76,7 @@ #include "SizeofExpressionCheck.h" #include "SpuriouslyWakeUpFunctionsCheck.h" #include "StandaloneEmptyCheck.h" +#include "StdExceptionBaseclassCheck.h" #include "StdNamespaceModificationCheck.h" #include "StringConstructorCheck.h" #include "StringIntegerAssignmentCheck.h" @@ -159,8 +159,8 @@ class BugproneModule : public ClangTidyModule { CheckFactories.registerCheck<EasilySwappableParametersCheck>( "bugprone-easily-swappable-parameters"); CheckFactories.registerCheck<EmptyCatchCheck>("bugprone-empty-catch"); - CheckFactories.registerCheck<ExceptionBaseclassCheck>( - "bugprone-exception-baseclass"); + CheckFactories.registerCheck<StdExceptionBaseclassCheck>( + "bugprone-std-exception-baseclass"); CheckFactories.registerCheck<ExceptionCopyConstructorThrowsCheck>( "bugprone-exception-copy-constructor-throws"); CheckFactories.registerCheck<ExceptionEscapeCheck>( diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt index e272793b4b21f..f7f185d53b269 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt @@ -26,7 +26,6 @@ add_clang_library(clangTidyBugproneModule STATIC DynamicStaticInitializersCheck.cpp EasilySwappableParametersCheck.cpp EmptyCatchCheck.cpp - ExceptionBaseclassCheck.cpp ExceptionCopyConstructorThrowsCheck.cpp ExceptionEscapeCheck.cpp FloatLoopCounterCheck.cpp @@ -40,6 +39,7 @@ add_clang_library(clangTidyBugproneModule STATIC InvalidEnumDefaultInitializationCheck.cpp UnintendedCharOstreamOutputCheck.cpp ReturnConstRefFromParameterCheck.cpp + StdExceptionBaseclassCheck.cpp SuspiciousStringviewDataUsageCheck.cpp SwitchMissingDefaultCaseCheck.cpp IncDecInConditionsCheck.cpp diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp similarity index 92% rename from clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp index 625ed48ef3cf5..24a11dd266f8e 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "ExceptionBaseclassCheck.h" +#include "StdExceptionBaseclassCheck.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" @@ -14,7 +14,7 @@ using namespace clang::ast_matchers; namespace clang::tidy::bugprone { -void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) { +void StdExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( cxxThrowExpr( unless(has(expr(anyOf(isTypeDependent(), isValueDependent())))), @@ -34,7 +34,7 @@ void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) { this); } -void ExceptionBaseclassCheck::check(const MatchFinder::MatchResult &Result) { +void StdExceptionBaseclassCheck::check(const MatchFinder::MatchResult &Result) { const auto *BadThrow = Result.Nodes.getNodeAs<CXXThrowExpr>("bad_throw"); assert(BadThrow && "Did not match the throw expression"); diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h similarity index 66% rename from clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h rename to clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h index d5728b843ec19..717e1b7878546 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ExceptionBaseclassCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H #include "../ClangTidyCheck.h" @@ -17,10 +17,10 @@ namespace clang::tidy::bugprone { /// std::exception. /// /// For the user-facing documentation see: -/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/exception-baseclass.html -class ExceptionBaseclassCheck : public ClangTidyCheck { +/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/std-exception-baseclass.html +class StdExceptionBaseclassCheck : public ClangTidyCheck { public: - ExceptionBaseclassCheck(StringRef Name, ClangTidyContext *Context) + StdExceptionBaseclassCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context) {} bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { return LangOpts.CPlusPlus; @@ -31,4 +31,4 @@ class ExceptionBaseclassCheck : public ClangTidyCheck { } // namespace clang::tidy::bugprone -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTIONBASECLASSCHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp index 11f1c7fb82678..f9aa4a233a399 100644 --- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp @@ -8,7 +8,7 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" -#include "../bugprone/ExceptionBaseclassCheck.h" +#include "../bugprone/StdExceptionBaseclassCheck.h" #include "../bugprone/UndelegatedConstructorCheck.h" #include "../bugprone/UseAfterMoveCheck.h" #include "../cppcoreguidelines/AvoidGotoCheck.h" @@ -55,7 +55,7 @@ class HICPPModule : public ClangTidyModule { "hicpp-braces-around-statements"); CheckFactories.registerCheck<modernize::DeprecatedHeadersCheck>( "hicpp-deprecated-headers"); - CheckFactories.registerCheck<bugprone::ExceptionBaseclassCheck>( + CheckFactories.registerCheck<bugprone::StdExceptionBaseclassCheck>( "hicpp-exception-baseclass"); CheckFactories.registerCheck<IgnoredRemoveResultCheck>( "hicpp-ignored-remove-result"); diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst similarity index 80% rename from clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst rename to clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst index 8fd9c6093a3f4..68d13169ebeb5 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-baseclass.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - bugprone-exception-baseclass +.. title:: clang-tidy - bugprone-std-exception-baseclass -bugprone-exception-baseclass -============================ +bugprone-std-exception-baseclass +================================ Ensure that every value that in a ``throw`` expression is an instance of ``std::exception``. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst index bb570d618093e..df92f8407d5d7 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst @@ -1,10 +1,10 @@ .. title:: clang-tidy - hicpp-exception-baseclass .. meta:: - :http-equiv=refresh: 5;URL=../bugprone/exception-baseclass.html + :http-equiv=refresh: 5;URL=../bugprone/std-exception-baseclass.html hicpp-exception-baseclass ========================= The `hicpp-exception-baseclass` check is an alias, please see -`bugprone-exception-baseclass <../bugprone/exception-baseclass.html>`_ +`bugprone-std-exception-baseclass <../bugprone/std-exception-baseclass.html>`_ for more information. diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index c2f6aa1b8b2df..4377284db50bf 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -99,7 +99,6 @@ Clang-Tidy Checks :doc:`bugprone-dynamic-static-initializers <bugprone/dynamic-static-initializers>`, :doc:`bugprone-easily-swappable-parameters <bugprone/easily-swappable-parameters>`, :doc:`bugprone-empty-catch <bugprone/empty-catch>`, - :doc:`bugprone-exception-baseclass <bugprone/exception-baseclass>`, :doc:`bugprone-exception-copy-constructor-throws <bugprone/exception-copy-constructor-throws>`, :doc:`bugprone-exception-escape <bugprone/exception-escape>`, :doc:`bugprone-float-loop-counter <bugprone/float-loop-counter>`, @@ -147,6 +146,7 @@ Clang-Tidy Checks :doc:`bugprone-sizeof-expression <bugprone/sizeof-expression>`, :doc:`bugprone-spuriously-wake-up-functions <bugprone/spuriously-wake-up-functions>`, :doc:`bugprone-standalone-empty <bugprone/standalone-empty>`, "Yes" + :doc:`bugprone-std-exception-baseclass <bugprone/std-exception-baseclass>`, :doc:`bugprone-std-namespace-modification <bugprone/std-namespace-modification>`, :doc:`bugprone-string-constructor <bugprone/string-constructor>`, "Yes" :doc:`bugprone-string-integer-assignment <bugprone/string-integer-assignment>`, "Yes" @@ -599,7 +599,7 @@ Check aliases :doc:`hicpp-avoid-goto <hicpp/avoid-goto>`, :doc:`cppcoreguidelines-avoid-goto <cppcoreguidelines/avoid-goto>`, :doc:`hicpp-braces-around-statements <hicpp/braces-around-statements>`, :doc:`readability-braces-around-statements <readability/braces-around-statements>`, "Yes" :doc:`hicpp-deprecated-headers <hicpp/deprecated-headers>`, :doc:`modernize-deprecated-headers <modernize/deprecated-headers>`, "Yes" - :doc:`hicpp-exception-baseclass <hicpp/exception-baseclass>`, :doc:`bugprone-exception-baseclass <bugprone/exception-baseclass>`, + :doc:`hicpp-exception-baseclass <hicpp/exception-baseclass>`, :doc:`bugprone-std-exception-baseclass <bugprone/std-exception-baseclass>`, :doc:`hicpp-explicit-conversions <hicpp/explicit-conversions>`, :doc:`google-explicit-constructor <google/explicit-constructor>`, "Yes" :doc:`hicpp-function-size <hicpp/function-size>`, :doc:`readability-function-size <readability/function-size>`, :doc:`hicpp-invalid-access-moved <hicpp/invalid-access-moved>`, :doc:`bugprone-use-after-move <bugprone/use-after-move>`, diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/std-exception-baseclass.cpp similarity index 99% rename from clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp rename to clang-tools-extra/test/clang-tidy/checkers/bugprone/std-exception-baseclass.cpp index 4bf52936c0b63..56a85f282c0e7 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-baseclass.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/std-exception-baseclass.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s bugprone-exception-baseclass %t -- -- -fcxx-exceptions +// RUN: %check_clang_tidy %s bugprone-std-exception-baseclass %t -- -- -fcxx-exceptions namespace std { class exception {}; >From 311ea383b074397503168badc9bb809e9431ca89 Mon Sep 17 00:00:00 2001 From: LeeYoungJoon <[email protected]> Date: Tue, 3 Mar 2026 12:41:19 +0900 Subject: [PATCH 6/6] [clang-tidy] Fix header guard --- .../clang-tidy/bugprone/StdExceptionBaseclassCheck.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h index 717e1b7878546..42e96822b97d8 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDEXCEPTIONBASECLASSCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDEXCEPTIONBASECLASSCHECK_H #include "../ClangTidyCheck.h" @@ -31,4 +31,4 @@ class StdExceptionBaseclassCheck : public ClangTidyCheck { } // namespace clang::tidy::bugprone -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STD_EXCEPTIONBASECLASSCHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDEXCEPTIONBASECLASSCHECK_H _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
