https://github.com/zeitcsabi updated https://github.com/llvm/llvm-project/pull/213015
>From 4164089cc249d2215b736aca0382290aec5767b7 Mon Sep 17 00:00:00 2001 From: Csaba Zeitvogel <[email protected]> Date: Thu, 30 Jul 2026 14:45:34 +0200 Subject: [PATCH 1/2] [clang-tidy] Add cerrno check to bugprone This simple check is based on the cerrno portion of MSC38-C. --- .../bugprone/BugproneTidyModule.cpp | 3 ++ .../clang-tidy/bugprone/CMakeLists.txt | 1 + .../clang-tidy/bugprone/CerrnoCheck.cpp | 38 +++++++++++++++++++ .../clang-tidy/bugprone/CerrnoCheck.h | 35 +++++++++++++++++ clang-tools-extra/docs/ReleaseNotes.rst | 5 +++ .../clang-tidy/checks/bugprone/cerrno.rst | 17 +++++++++ .../docs/clang-tidy/checks/list.rst | 1 + .../clang-tidy/checkers/bugprone/cerrno.cpp | 25 ++++++++++++ 8 files changed, 125 insertions(+) create mode 100644 clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.cpp create mode 100644 clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.h create mode 100644 clang-tools-extra/docs/clang-tidy/checks/bugprone/cerrno.rst create mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/cerrno.cpp diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp index 3aa39d10ceb5d..54f0e7345ff97 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -18,6 +18,7 @@ #include "BranchCloneCheck.h" #include "CapturingThisInMemberVariableCheck.h" #include "CastingThroughVoidCheck.h" +#include "CerrnoCheck.h" #include "ChainedComparisonCheck.h" #include "CommandProcessorCheck.h" #include "ComparePointerToMemberVirtualFunctionCheck.h" @@ -144,6 +145,8 @@ class BugproneModule : public ClangTidyModule { "bugprone-capturing-this-in-member-variable"); CheckFactories.registerCheck<CastingThroughVoidCheck>( "bugprone-casting-through-void"); + CheckFactories.registerCheck<CerrnoCheck>( + "bugprone-cerrno"); CheckFactories.registerCheck<ChainedComparisonCheck>( "bugprone-chained-comparison"); CheckFactories.registerCheck<CommandProcessorCheck>( diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt index 43e85b1407f21..6345e61b3b126 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt @@ -15,6 +15,7 @@ add_clang_library(clangTidyBugproneModule STATIC BugproneTidyModule.cpp CapturingThisInMemberVariableCheck.cpp CastingThroughVoidCheck.cpp + CerrnoCheck.cpp ChainedComparisonCheck.cpp CommandProcessorCheck.cpp ComparePointerToMemberVirtualFunctionCheck.cpp diff --git a/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.cpp new file mode 100644 index 0000000000000..8dbb685662084 --- /dev/null +++ b/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "CerrnoCheck.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +void CerrnoCheck::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher(varDecl(hasType(asString("int")), hasName("errno"), hasExternalFormalLinkage()).bind("errnoDecl"), this); +} + +void CerrnoCheck::check(const MatchFinder::MatchResult &Result) { + const auto *MatchedDecl = Result.Nodes.getNodeAs<VarDecl>("errnoDecl"); // NULL? + const SourceManager &SM = *Result.SourceManager; + const auto Location = MatchedDecl->getLocation(); + const auto FileID = SM.getFileID(Location); + + unsigned Line = SM.getSpellingLineNumber(MatchedDecl->getBeginLoc()); + + const auto Diag = diag(Location, "errno declaration detected, include cerrno instead") + << FixItHint::CreateRemoval(CharSourceRange::getCharRange(SM.translateLineCol(FileID, Line, 1), SM.translateLineCol(FileID, Line + 1, 1))); + + if (alreadyInserted) + return; + + Diag << FixItHint::CreateInsertion(SM.getLocForStartOfFile(FileID), "#include <cerrno>\n"); + alreadyInserted = true; +} + +} // namespace clang::tidy::bugprone diff --git a/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.h b/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.h new file mode 100644 index 0000000000000..7517acd28a49f --- /dev/null +++ b/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.h @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CERRNOCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CERRNOCHECK_H + +#include "../ClangTidyCheck.h" + +namespace clang::tidy::bugprone { + +/// Warns if you declare an extern int variable named 'errno'. +/// +/// For the user-facing documentation see: +/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/cerrno.html +class CerrnoCheck : public ClangTidyCheck { +public: + CerrnoCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; + bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { + return LangOpts.CPlusPlus; + } +private: + bool alreadyInserted = false; +}; + +} // namespace clang::tidy::bugprone + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CERRNOCHECK_H diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 2581a9d3c5657..e3a19dffc931a 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -224,6 +224,11 @@ New checks Finds assignments within selection statements. +- New :doc:`bugprone-cerrno + <clang-tidy/checks/bugprone/cerrno>` check. + + Warns if you declare an extern int variable named 'errno'. + - New :doc:`bugprone-missing-end-comparison <clang-tidy/checks/bugprone/missing-end-comparison>` check. diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/cerrno.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/cerrno.rst new file mode 100644 index 0000000000000..73ec1c76901af --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/cerrno.rst @@ -0,0 +1,17 @@ +.. title:: clang-tidy - bugprone-cerrno + +bugprone-cerrno +=============== + +Warns if you declare an ``extern int`` variable named ``errno`` instead of including ``<cerrno>``. +It is able to fix the problem by removing the line of the declaration and inserting ``#include <cerrno>`` +at the top of the file. + +For further reading, see `the page of SEI CERT C Coding Standard +<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/miscellaneous-msc/msc38-c/>`_. + +Example: + +.. code-block:: c++ + + extern int errno; diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index 2a44dc78fbc89..355401cbdccc6 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -87,6 +87,7 @@ Clang-Tidy Checks :doc:`bugprone-branch-clone <bugprone/branch-clone>`, :doc:`bugprone-capturing-this-in-member-variable <bugprone/capturing-this-in-member-variable>`, :doc:`bugprone-casting-through-void <bugprone/casting-through-void>`, + :doc:`bugprone-cerrno <bugprone/cerrno>`, "Yes" :doc:`bugprone-chained-comparison <bugprone/chained-comparison>`, :doc:`bugprone-command-processor <bugprone/command-processor>`, :doc:`bugprone-compare-pointer-to-member-virtual-function <bugprone/compare-pointer-to-member-virtual-function>`, diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/cerrno.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/cerrno.cpp new file mode 100644 index 0000000000000..40109d31aa26b --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/cerrno.cpp @@ -0,0 +1,25 @@ +// RUN: %check_clang_tidy %s bugprone-cerrno %t + +namespace cerrno_test_0 { + extern int errno; + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: errno declaration detected, include cerrno instead [bugprone-cerrno] + // CHECK-FIXES: {{^}}{{$}} +} // namespace cerrno_test_0 + +namespace cerrno_test_1 { + extern "C" int errno; + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: errno declaration detected, include cerrno instead [bugprone-cerrno] + // CHECK-FIXES: {{^}}{{$}} +} // namespace cerrno_test_1 + +namespace cerrno_test_2 { // all cases should be ignored in this namespace + extern bool errno; + + void foo(int errno) {} + + int fooo() + { + int errno = 0; + return errno; + } +} // namespace cerrno_test_2 >From ef8ad55e1ec4c047c23ea2a0bcb6ca2f07dabc09 Mon Sep 17 00:00:00 2001 From: Csaba Zeitvogel <[email protected]> Date: Sat, 1 Aug 2026 14:24:09 +0200 Subject: [PATCH 2/2] Apply requested changes The check has been renamed, the documentation has been converted to Markdown format, etc. --- .../clang-tidy/bugprone/BugproneTidyModule.cpp | 6 +++--- .../clang-tidy/bugprone/CMakeLists.txt | 2 +- ...heck.cpp => CustomErrnoDeclarationCheck.cpp} | 6 +++--- ...rnoCheck.h => CustomErrnoDeclarationCheck.h} | 12 ++++++------ clang-tools-extra/docs/ReleaseNotes.rst | 6 +++--- .../docs/clang-tidy/checks/bugprone/cerrno.rst | 17 ----------------- .../checks/bugprone/custom-errno-declaration.md | 14 ++++++++++++++ .../docs/clang-tidy/checks/list.rst | 2 +- ...{cerrno.cpp => custom-errno-declaration.cpp} | 6 +++--- 9 files changed, 34 insertions(+), 37 deletions(-) rename clang-tools-extra/clang-tidy/bugprone/{CerrnoCheck.cpp => CustomErrnoDeclarationCheck.cpp} (87%) rename clang-tools-extra/clang-tidy/bugprone/{CerrnoCheck.h => CustomErrnoDeclarationCheck.h} (66%) delete mode 100644 clang-tools-extra/docs/clang-tidy/checks/bugprone/cerrno.rst create mode 100644 clang-tools-extra/docs/clang-tidy/checks/bugprone/custom-errno-declaration.md rename clang-tools-extra/test/clang-tidy/checkers/bugprone/{cerrno.cpp => custom-errno-declaration.cpp} (73%) diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp index 54f0e7345ff97..e550433ddacd2 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -18,7 +18,7 @@ #include "BranchCloneCheck.h" #include "CapturingThisInMemberVariableCheck.h" #include "CastingThroughVoidCheck.h" -#include "CerrnoCheck.h" +#include "CustomErrnoDeclarationCheck.h" #include "ChainedComparisonCheck.h" #include "CommandProcessorCheck.h" #include "ComparePointerToMemberVirtualFunctionCheck.h" @@ -145,8 +145,8 @@ class BugproneModule : public ClangTidyModule { "bugprone-capturing-this-in-member-variable"); CheckFactories.registerCheck<CastingThroughVoidCheck>( "bugprone-casting-through-void"); - CheckFactories.registerCheck<CerrnoCheck>( - "bugprone-cerrno"); + CheckFactories.registerCheck<CustomErrnoDeclarationCheck>( + "bugprone-custom-errno-declaration"); CheckFactories.registerCheck<ChainedComparisonCheck>( "bugprone-chained-comparison"); CheckFactories.registerCheck<CommandProcessorCheck>( diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt index 6345e61b3b126..8cf6e6f86cd36 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt @@ -15,7 +15,7 @@ add_clang_library(clangTidyBugproneModule STATIC BugproneTidyModule.cpp CapturingThisInMemberVariableCheck.cpp CastingThroughVoidCheck.cpp - CerrnoCheck.cpp + CustomErrnoDeclarationCheck.cpp ChainedComparisonCheck.cpp CommandProcessorCheck.cpp ComparePointerToMemberVirtualFunctionCheck.cpp diff --git a/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CustomErrnoDeclarationCheck.cpp similarity index 87% rename from clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/CustomErrnoDeclarationCheck.cpp index 8dbb685662084..e3b6e8f51bb3b 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/CustomErrnoDeclarationCheck.cpp @@ -6,18 +6,18 @@ // //===----------------------------------------------------------------------===// -#include "CerrnoCheck.h" +#include "CustomErrnoDeclarationCheck.h" #include "clang/ASTMatchers/ASTMatchFinder.h" using namespace clang::ast_matchers; namespace clang::tidy::bugprone { -void CerrnoCheck::registerMatchers(MatchFinder *Finder) { +void CustomErrnoDeclarationCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher(varDecl(hasType(asString("int")), hasName("errno"), hasExternalFormalLinkage()).bind("errnoDecl"), this); } -void CerrnoCheck::check(const MatchFinder::MatchResult &Result) { +void CustomErrnoDeclarationCheck::check(const MatchFinder::MatchResult &Result) { const auto *MatchedDecl = Result.Nodes.getNodeAs<VarDecl>("errnoDecl"); // NULL? const SourceManager &SM = *Result.SourceManager; const auto Location = MatchedDecl->getLocation(); diff --git a/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.h b/clang-tools-extra/clang-tidy/bugprone/CustomErrnoDeclarationCheck.h similarity index 66% rename from clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.h rename to clang-tools-extra/clang-tidy/bugprone/CustomErrnoDeclarationCheck.h index 7517acd28a49f..a1e16d412db49 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CerrnoCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/CustomErrnoDeclarationCheck.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CERRNOCHECK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CERRNOCHECK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CUSTOMERRNODECLARATIONCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CUSTOMERRNODECLARATIONCHECK_H #include "../ClangTidyCheck.h" @@ -16,10 +16,10 @@ namespace clang::tidy::bugprone { /// Warns if you declare an extern int variable named 'errno'. /// /// For the user-facing documentation see: -/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/cerrno.html -class CerrnoCheck : public ClangTidyCheck { +/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/custom-errno-declaration.html +class CustomErrnoDeclarationCheck : public ClangTidyCheck { public: - CerrnoCheck(StringRef Name, ClangTidyContext *Context) + CustomErrnoDeclarationCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context) {} void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; @@ -32,4 +32,4 @@ class CerrnoCheck : public ClangTidyCheck { } // namespace clang::tidy::bugprone -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CERRNOCHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CUSTOMERRNODECLARATIONCHECK_H diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index e3a19dffc931a..9d348501a89b6 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -224,10 +224,10 @@ New checks Finds assignments within selection statements. -- New :doc:`bugprone-cerrno - <clang-tidy/checks/bugprone/cerrno>` check. +- New :doc:`bugprone-custom-errno-declaration + <clang-tidy/checks/bugprone/custom-errno-declaration>` check. - Warns if you declare an extern int variable named 'errno'. + Finds custom declarations of ``extern int`` variable named ``errno``. - New :doc:`bugprone-missing-end-comparison <clang-tidy/checks/bugprone/missing-end-comparison>` check. diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/cerrno.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/cerrno.rst deleted file mode 100644 index 73ec1c76901af..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/cerrno.rst +++ /dev/null @@ -1,17 +0,0 @@ -.. title:: clang-tidy - bugprone-cerrno - -bugprone-cerrno -=============== - -Warns if you declare an ``extern int`` variable named ``errno`` instead of including ``<cerrno>``. -It is able to fix the problem by removing the line of the declaration and inserting ``#include <cerrno>`` -at the top of the file. - -For further reading, see `the page of SEI CERT C Coding Standard -<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/miscellaneous-msc/msc38-c/>`_. - -Example: - -.. code-block:: c++ - - extern int errno; diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/custom-errno-declaration.md b/clang-tools-extra/docs/clang-tidy/checks/bugprone/custom-errno-declaration.md new file mode 100644 index 0000000000000..2fd9f51a56688 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/custom-errno-declaration.md @@ -0,0 +1,14 @@ +# bugprone-custom-errno-declaration + +Finds custom declarations of `extern int` variable named `errno`. +It is able to fix the problem by removing the line of the declaration and inserting `#include <cerrno>` +at the top of the file. + +For further reading, see [the page of SEI CERT C Coding Standard] +(https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/miscellaneous-msc/msc38-c/). + +Example: + +```cpp +extern int errno; +``` diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index 355401cbdccc6..6401d99ca43a0 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -87,13 +87,13 @@ Clang-Tidy Checks :doc:`bugprone-branch-clone <bugprone/branch-clone>`, :doc:`bugprone-capturing-this-in-member-variable <bugprone/capturing-this-in-member-variable>`, :doc:`bugprone-casting-through-void <bugprone/casting-through-void>`, - :doc:`bugprone-cerrno <bugprone/cerrno>`, "Yes" :doc:`bugprone-chained-comparison <bugprone/chained-comparison>`, :doc:`bugprone-command-processor <bugprone/command-processor>`, :doc:`bugprone-compare-pointer-to-member-virtual-function <bugprone/compare-pointer-to-member-virtual-function>`, :doc:`bugprone-copy-constructor-init <bugprone/copy-constructor-init>`, "Yes" :doc:`bugprone-copy-constructor-mutates-argument <bugprone/copy-constructor-mutates-argument>`, :doc:`bugprone-crtp-constructor-accessibility <bugprone/crtp-constructor-accessibility>`, "Yes" + :doc:`bugprone-custom-errno-declaration <bugprone/custom-errno-declaration>`, "Yes" :doc:`bugprone-dangling-handle <bugprone/dangling-handle>`, :doc:`bugprone-default-operator-new-on-overaligned-type <bugprone/default-operator-new-on-overaligned-type>`, :doc:`bugprone-derived-method-shadowing-base-method <bugprone/derived-method-shadowing-base-method>`, diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/cerrno.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/custom-errno-declaration.cpp similarity index 73% rename from clang-tools-extra/test/clang-tidy/checkers/bugprone/cerrno.cpp rename to clang-tools-extra/test/clang-tidy/checkers/bugprone/custom-errno-declaration.cpp index 40109d31aa26b..0d87784e4d252 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/cerrno.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/custom-errno-declaration.cpp @@ -1,14 +1,14 @@ -// RUN: %check_clang_tidy %s bugprone-cerrno %t +// RUN: %check_clang_tidy %s bugprone-custom-errno-declaration %t namespace cerrno_test_0 { extern int errno; - // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: errno declaration detected, include cerrno instead [bugprone-cerrno] + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: errno declaration detected, include cerrno instead [bugprone-custom-errno-declaration] // CHECK-FIXES: {{^}}{{$}} } // namespace cerrno_test_0 namespace cerrno_test_1 { extern "C" int errno; - // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: errno declaration detected, include cerrno instead [bugprone-cerrno] + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: errno declaration detected, include cerrno instead [bugprone-custom-errno-declaration] // CHECK-FIXES: {{^}}{{$}} } // namespace cerrno_test_1 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
