Index: clang-tidy/bugprone/BugproneTidyModule.cpp =================================================================== --- clang-tidy/bugprone/BugproneTidyModule.cpp +++ clang-tidy/bugprone/BugproneTidyModule.cpp @@ -11,6 +11,7 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "CopyConstructorInitCheck.h" +#include "DanglingHandleCheck.h" #include "IntegerDivisionCheck.h" #include "MisplacedOperatorInStrlenInAllocCheck.h" #include "StringConstructorCheck.h" @@ -26,6 +27,8 @@ void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck( "bugprone-copy-constructor-init"); + CheckFactories.registerCheck( + "bugprone-dangling-handle"); CheckFactories.registerCheck( "bugprone-integer-division"); CheckFactories.registerCheck( Index: clang-tidy/bugprone/CMakeLists.txt =================================================================== --- clang-tidy/bugprone/CMakeLists.txt +++ clang-tidy/bugprone/CMakeLists.txt @@ -3,6 +3,7 @@ add_clang_library(clangTidyBugproneModule BugproneTidyModule.cpp CopyConstructorInitCheck.cpp + DanglingHandleCheck.cpp IntegerDivisionCheck.cpp MisplacedOperatorInStrlenInAllocCheck.cpp StringConstructorCheck.cpp Index: clang-tidy/bugprone/DanglingHandleCheck.h =================================================================== --- clang-tidy/bugprone/DanglingHandleCheck.h +++ clang-tidy/bugprone/DanglingHandleCheck.h @@ -7,20 +7,20 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DANGLING_HANDLE_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DANGLING_HANDLE_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DANGLING_HANDLE_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DANGLING_HANDLE_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Detect dangling references in value handlers like /// std::experimental::string_view. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-dangling-handle.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-dangling-handle.html class DanglingHandleCheck : public ClangTidyCheck { public: DanglingHandleCheck(StringRef Name, ClangTidyContext *Context); @@ -36,8 +36,8 @@ const ast_matchers::internal::Matcher IsAHandle; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DANGLING_HANDLE_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DANGLING_HANDLE_H Index: clang-tidy/bugprone/DanglingHandleCheck.cpp =================================================================== --- clang-tidy/bugprone/DanglingHandleCheck.cpp +++ clang-tidy/bugprone/DanglingHandleCheck.cpp @@ -18,7 +18,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { @@ -179,6 +179,6 @@ << Handle->getQualifiedNameAsString(); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/misc/CMakeLists.txt =================================================================== --- clang-tidy/misc/CMakeLists.txt +++ clang-tidy/misc/CMakeLists.txt @@ -8,7 +8,6 @@ MisplacedConstCheck.cpp UnconventionalAssignOperatorCheck.cpp BoolPointerImplicitConversionCheck.cpp - DanglingHandleCheck.cpp DefinitionsInHeadersCheck.cpp FoldInitTypeCheck.cpp ForwardDeclarationNamespaceCheck.cpp Index: clang-tidy/misc/MiscTidyModule.cpp =================================================================== --- clang-tidy/misc/MiscTidyModule.cpp +++ clang-tidy/misc/MiscTidyModule.cpp @@ -13,7 +13,6 @@ #include "ArgumentCommentCheck.h" #include "AssertSideEffectCheck.h" #include "BoolPointerImplicitConversionCheck.h" -#include "DanglingHandleCheck.h" #include "DefinitionsInHeadersCheck.h" #include "FoldInitTypeCheck.h" #include "ForwardDeclarationNamespaceCheck.h" @@ -75,7 +74,6 @@ "misc-unconventional-assign-operator"); CheckFactories.registerCheck( "misc-bool-pointer-implicit-conversion"); - CheckFactories.registerCheck("misc-dangling-handle"); CheckFactories.registerCheck( "misc-definitions-in-headers"); CheckFactories.registerCheck("misc-fold-init-type"); Index: docs/ReleaseNotes.rst =================================================================== --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -57,6 +57,9 @@ Improvements to clang-tidy -------------------------- +- The 'misc-dangling-handle' check was renamed to `bugprone-dangling-handle + `_ + - The 'misc-string-constructor' check was renamed to `bugprone-string-constructor `_ Index: docs/clang-tidy/checks/bugprone-dangling-handle.rst =================================================================== --- docs/clang-tidy/checks/bugprone-dangling-handle.rst +++ docs/clang-tidy/checks/bugprone-dangling-handle.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-dangling-handle +.. title:: clang-tidy - bugprone-dangling-handle -misc-dangling-handle -==================== +bugprone-dangling-handle +======================== Detect dangling references in value handles like ``std::experimental::string_view``. Index: docs/clang-tidy/checks/list.rst =================================================================== --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -18,6 +18,7 @@ android-cloexec-socket boost-use-to-string bugprone-copy-constructor-init + bugprone-dangling-handle bugprone-integer-division bugprone-misplaced-operator-in-strlen-in-alloc bugprone-string-constructor @@ -108,7 +109,6 @@ misc-argument-comment misc-assert-side-effect misc-bool-pointer-implicit-conversion - misc-dangling-handle misc-definitions-in-headers misc-fold-init-type misc-forward-declaration-namespace Index: test/clang-tidy/bugprone-dangling-handle.cpp =================================================================== --- test/clang-tidy/bugprone-dangling-handle.cpp +++ test/clang-tidy/bugprone-dangling-handle.cpp @@ -1,6 +1,6 @@ -// RUN: %check_clang_tidy %s misc-dangling-handle %t -- \ +// RUN: %check_clang_tidy %s bugprone-dangling-handle %t -- \ // RUN: -config="{CheckOptions: \ -// RUN: [{key: misc-dangling-handle.HandleClasses, \ +// RUN: [{key: bugprone-dangling-handle.HandleClasses, \ // RUN: value: 'std::basic_string_view; ::llvm::StringRef;'}]}" \ // RUN: -- -std=c++11 @@ -79,7 +79,7 @@ void Positives() { std::string_view view1 = std::string(); - // CHECK-MESSAGES: [[@LINE-1]]:20: warning: std::basic_string_view outlives its value [misc-dangling-handle] + // CHECK-MESSAGES: [[@LINE-1]]:20: warning: std::basic_string_view outlives its value [bugprone-dangling-handle] std::string_view view_2 = ReturnsAString(); // CHECK-MESSAGES: [[@LINE-1]]:20: warning: std::basic_string_view outlives