Author: LeeYoungJoon
Date: 2026-03-11T08:49:37+03:00
New Revision: 49c714ecd731d9f27a885b55ccc2901e5b586a97

URL: 
https://github.com/llvm/llvm-project/commit/49c714ecd731d9f27a885b55ccc2901e5b586a97
DIFF: 
https://github.com/llvm/llvm-project/commit/49c714ecd731d9f27a885b55ccc2901e5b586a97.diff

LOG: [clang-tidy] Rename hicpp-exception-baseclass to 
bugprone-exception-baseclass (#183474)

Part of the work in https://github.com/llvm/llvm-project/issues/183462.

Closes https://github.com/llvm/llvm-project/issues/183463.

Added: 
    clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp
    clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h
    
clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst
    
clang-tools-extra/test/clang-tidy/checkers/bugprone/std-exception-baseclass.cpp

Modified: 
    clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
    clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
    clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
    clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
    clang-tools-extra/docs/ReleaseNotes.rst
    clang-tools-extra/docs/clang-tidy/checks/hicpp/exception-baseclass.rst
    clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 
    clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
    clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h
    clang-tools-extra/test/clang-tidy/checkers/hicpp/exception-baseclass.cpp


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 310184037afbd..b39aea62a9546 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -76,6 +76,7 @@
 #include "SizeofExpressionCheck.h"
 #include "SpuriouslyWakeUpFunctionsCheck.h"
 #include "StandaloneEmptyCheck.h"
+#include "StdExceptionBaseclassCheck.h"
 #include "StdNamespaceModificationCheck.h"
 #include "StringConstructorCheck.h"
 #include "StringIntegerAssignmentCheck.h"
@@ -181,6 +182,8 @@ class BugproneModule : public ClangTidyModule {
         "bugprone-unintended-char-ostream-output");
     CheckFactories.registerCheck<ReturnConstRefFromParameterCheck>(
         "bugprone-return-const-ref-from-parameter");
+    CheckFactories.registerCheck<StdExceptionBaseclassCheck>(
+        "bugprone-std-exception-baseclass");
     CheckFactories.registerCheck<SwitchMissingDefaultCaseCheck>(
         "bugprone-switch-missing-default-case");
     CheckFactories.registerCheck<IncDecInConditionsCheck>(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 96ad671d03b39..f7f185d53b269 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -39,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/hicpp/ExceptionBaseclassCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp
similarity index 89%
rename from clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
rename to clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp
index 71b82875c09a0..24a11dd266f8e 100644
--- a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.cpp
@@ -6,15 +6,15 @@
 //
 
//===----------------------------------------------------------------------===//
 
-#include "ExceptionBaseclassCheck.h"
+#include "StdExceptionBaseclassCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
 using namespace clang::ast_matchers;
 
-namespace clang::tidy::hicpp {
+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");
 
@@ -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/StdExceptionBaseclassCheck.h
similarity index 61%
rename from clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h
rename to clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h
index 800e7ac9663d5..42e96822b97d8 100644
--- a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/StdExceptionBaseclassCheck.h
@@ -6,21 +6,21 @@
 //
 
//===----------------------------------------------------------------------===//
 
-#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_STDEXCEPTIONBASECLASSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STDEXCEPTIONBASECLASSCHECK_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.
 ///
 /// For the user-facing documentation see:
-/// 
https://clang.llvm.org/extra/clang-tidy/checks/hicpp/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;
@@ -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_STDEXCEPTIONBASECLASSCHECK_H

diff  --git a/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
index e8401e750642d..b5bcbf389b4ae 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
   MultiwayPathsCoveredCheck.cpp
   SignedBitwiseCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp 
b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
index 3eb6d5de39d04..38d9235878e62 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/StdExceptionBaseclassCheck.h"
 #include "../bugprone/UndelegatedConstructorCheck.h"
 #include "../bugprone/UnusedReturnValueCheck.h"
 #include "../bugprone/UseAfterMoveCheck.h"
@@ -36,7 +37,6 @@
 #include "../readability/FunctionSizeCheck.h"
 #include "../readability/NamedParameterCheck.h"
 #include "../readability/UppercaseLiteralSuffixCheck.h"
-#include "ExceptionBaseclassCheck.h"
 #include "MultiwayPathsCoveredCheck.h"
 #include "SignedBitwiseCheck.h"
 
@@ -55,7 +55,7 @@ class HICPPModule : public ClangTidyModule {
         "hicpp-braces-around-statements");
     CheckFactories.registerCheck<modernize::DeprecatedHeadersCheck>(
         "hicpp-deprecated-headers");
-    CheckFactories.registerCheck<ExceptionBaseclassCheck>(
+    CheckFactories.registerCheck<bugprone::StdExceptionBaseclassCheck>(
         "hicpp-exception-baseclass");
     CheckFactories.registerCheck<bugprone::UnusedReturnValueCheck>(
         "hicpp-ignored-remove-result");

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 077335c16c331..6995e02247861 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -163,6 +163,12 @@ New checks
 New check aliases
 ^^^^^^^^^^^^^^^^^
 
+- Renamed :doc:`hicpp-exception-baseclass
+  <clang-tidy/checks/hicpp/exception-baseclass>`
+  to :doc:`bugprone-std-exception-baseclass
+  <clang-tidy/checks/bugprone/std-exception-baseclass>`.
+  The `hicpp-exception-baseclass` name is kept as an alias.
+
 - Renamed :doc:`hicpp-ignored-remove-result
   <clang-tidy/checks/hicpp/ignored-remove-result>`
   to :doc:`bugprone-unused-return-value

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst
new file mode 100644
index 0000000000000..41b14537eb36f
--- /dev/null
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-exception-baseclass.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - bugprone-std-exception-baseclass
+
+bugprone-std-exception-baseclass
+================================
+
+Ensure that every value that in a ``throw`` expression is an instance of
+``std::exception``.
+
+Deriving all exceptions from ``std::exception`` allows callers to catch
+all exceptions with a single catch block and provides access to the
+``what()`` method for diagnostics. Throwing arbitrary types creates
+hidden contracts, reduces interoperability with the standard library,
+and may result in program termination.
+
+.. code-block:: c++
+
+  class custom_exception {};
+
+  void throwing() noexcept(false) {
+    // Problematic throw expressions.
+    throw int(42);
+    throw custom_exception();
+  }
+
+  class mathematical_error : public std::exception {};
+
+  void throwing2() noexcept(false) {
+    // These kind of throws are ok.
+    throw mathematical_error();
+    throw std::runtime_error();
+    throw 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 7a1c1a07c49e3..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,29 +1,10 @@
 .. title:: clang-tidy - hicpp-exception-baseclass
+.. meta::
+   :http-equiv=refresh: 5;URL=../bugprone/std-exception-baseclass.html
 
 hicpp-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 {};
-
-  void throwing() noexcept(false) {
-    // Problematic throw expressions.
-    throw int(42);
-    throw custom_exception();
-  }
-
-  class mathematical_error : public std::exception {};
-
-  void throwing2() noexcept(false) {
-    // These kind of throws are ok.
-    throw mathematical_error();
-    throw std::runtime_error();
-    throw std::exception();
-  }
+The `hicpp-exception-baseclass` check is an alias, please see
+`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 362455796bd50..fcde0ea474913 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -146,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"
@@ -600,6 +601,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-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-ignored-remove-result <hicpp/ignored-remove-result>`, 
:doc:`bugprone-unused-return-value <bugprone/unused-return-value>`,

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/hicpp/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/hicpp/exception-baseclass.cpp
rename to 
clang-tools-extra/test/clang-tidy/checkers/bugprone/std-exception-baseclass.cpp
index b5e405a691848..56a85f282c0e7 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/hicpp/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 hicpp-exception-baseclass %t -- -- 
-fcxx-exceptions
+// RUN: %check_clang_tidy %s bugprone-std-exception-baseclass %t -- -- 
-fcxx-exceptions
 
 namespace std {
 class exception {};


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to