Skip to content

Commit

Permalink
[clang-tidy] Another batch of checks to rename from misc- to bugprone-.
Browse files Browse the repository at this point in the history
Summary:
clang-tidy/rename_check.py {misc,bugprone}-suspicious-semicolon
clang-tidy/rename_check.py {misc,bugprone}-suspicious-string-compare
clang-tidy/rename_check.py {misc,bugprone}-swapped-arguments
clang-tidy/rename_check.py {misc,bugprone}-undelegated-constructor --check_class_name UndelegatedConstructor

Reviewers: hokein, sammccall, aaron.ballman

Subscribers: klimek, mgorny, xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D43870

llvm-svn: 326386
  • Loading branch information
alexfh committed Feb 28, 2018
1 parent 51ec5a9 commit eb9d944
Show file tree
Hide file tree
Showing 30 changed files with 104 additions and 94 deletions.
12 changes: 12 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
#include "SuspiciousEnumUsageCheck.h"
#include "SuspiciousMemsetUsageCheck.h"
#include "SuspiciousMissingCommaCheck.h"
#include "SuspiciousSemicolonCheck.h"
#include "SuspiciousStringCompareCheck.h"
#include "SwappedArgumentsCheck.h"
#include "ThrowKeywordMissingCheck.h"
#include "UndefinedMemoryManipulationCheck.h"
#include "UndelegatedConstructorCheck.h"
#include "UseAfterMoveCheck.h"
#include "VirtualNearMissCheck.h"

Expand Down Expand Up @@ -91,10 +95,18 @@ class BugproneModule : public ClangTidyModule {
"bugprone-suspicious-memset-usage");
CheckFactories.registerCheck<SuspiciousMissingCommaCheck>(
"bugprone-suspicious-missing-comma");
CheckFactories.registerCheck<SuspiciousSemicolonCheck>(
"bugprone-suspicious-semicolon");
CheckFactories.registerCheck<SuspiciousStringCompareCheck>(
"bugprone-suspicious-string-compare");
CheckFactories.registerCheck<SwappedArgumentsCheck>(
"bugprone-swapped-arguments");
CheckFactories.registerCheck<ThrowKeywordMissingCheck>(
"bugprone-throw-keyword-missing");
CheckFactories.registerCheck<UndefinedMemoryManipulationCheck>(
"bugprone-undefined-memory-manipulation");
CheckFactories.registerCheck<UndelegatedConstructorCheck>(
"bugprone-undelegated-constructor");
CheckFactories.registerCheck<UseAfterMoveCheck>(
"bugprone-use-after-move");
CheckFactories.registerCheck<VirtualNearMissCheck>(
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ add_clang_library(clangTidyBugproneModule
SuspiciousEnumUsageCheck.cpp
SuspiciousMemsetUsageCheck.cpp
SuspiciousMissingCommaCheck.cpp
SuspiciousSemicolonCheck.cpp
SuspiciousStringCompareCheck.cpp
SwappedArgumentsCheck.cpp
ThrowKeywordMissingCheck.cpp
UndefinedMemoryManipulationCheck.cpp
UndelegatedConstructorCheck.cpp
UseAfterMoveCheck.cpp
VirtualNearMissCheck.cpp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace misc {
namespace bugprone {

void SuspiciousSemicolonCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
Expand Down Expand Up @@ -72,6 +72,6 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) {
<< FixItHint::CreateRemoval(SourceRange(LocStart, LocEnd));
}

} // namespace misc
} // namespace bugprone
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_SEMICOLON_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_SEMICOLON_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSEMICOLONCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSEMICOLONCHECK_H

#include "../ClangTidy.h"

namespace clang {
namespace tidy {
namespace misc {
namespace bugprone {

/// This check finds semicolon that modifies the meaning of the program
/// unintendedly.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/misc-suspicious-semicolon.html
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-semicolon.html
class SuspiciousSemicolonCheck : public ClangTidyCheck {
public:
SuspiciousSemicolonCheck(StringRef Name, ClangTidyContext *Context)
Expand All @@ -29,8 +29,8 @@ class SuspiciousSemicolonCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace misc
} // namespace bugprone
} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_SEMICOLON_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSEMICOLONCHECK_H
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace misc {
namespace bugprone {

// Semicolon separated list of known string compare-like functions. The list
// must ends with a semicolon.
Expand Down Expand Up @@ -213,6 +213,6 @@ void SuspiciousStringCompareCheck::check(
}
}

} // namespace misc
} // namespace bugprone
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_STRING_COMPARE_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_STRING_COMPARE_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSTRINGCOMPARECHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSTRINGCOMPARECHECK_H

#include "../ClangTidy.h"

namespace clang {
namespace tidy {
namespace misc {
namespace bugprone {

/// Find suspicious calls to string compare functions.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/misc-suspicious-string-compare.html
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-string-compare.html
class SuspiciousStringCompareCheck : public ClangTidyCheck {
public:
SuspiciousStringCompareCheck(StringRef Name, ClangTidyContext *Context);
Expand All @@ -33,8 +33,8 @@ class SuspiciousStringCompareCheck : public ClangTidyCheck {
const std::string StringCompareLikeFunctions;
};

} // namespace misc
} // namespace bugprone
} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_STRING_COMPARE_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSTRINGCOMPARECHECK_H
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace misc {
namespace bugprone {

void SwappedArgumentsCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(callExpr().bind("call"), this);
Expand Down Expand Up @@ -97,6 +97,6 @@ void SwappedArgumentsCheck::check(const MatchFinder::MatchResult &Result) {
}
}

} // namespace misc
} // namespace bugprone
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SWAPPEDARGUMENTSCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SWAPPEDARGUMENTSCHECK_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SWAPPEDARGUMENTSCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SWAPPEDARGUMENTSCHECK_H

#include "../ClangTidy.h"

namespace clang {
namespace tidy {
namespace misc {
namespace bugprone {

/// Finds potentially swapped arguments by looking at implicit conversions.
class SwappedArgumentsCheck : public ClangTidyCheck {
Expand All @@ -25,8 +25,8 @@ class SwappedArgumentsCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace misc
} // namespace bugprone
} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SWAPPEDARGUMENTSCHECK_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SWAPPEDARGUMENTSCHECK_H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- UndelegatedConstructor.cpp - clang-tidy --------------------------===//
//===--- UndelegatedConstructorCheck.cpp - clang-tidy --------------------------===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -7,15 +7,15 @@
//
//===----------------------------------------------------------------------===//

#include "UndelegatedConstructor.h"
#include "UndelegatedConstructorCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/Lex/Lexer.h"

using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace misc {
namespace bugprone {

namespace {
AST_MATCHER_P(Stmt, ignoringTemporaryExpr,
Expand Down Expand Up @@ -79,6 +79,6 @@ void UndelegatedConstructorCheck::check(
"A temporary object is created here instead");
}

} // namespace misc
} // namespace bugprone
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- UndelegatedConstructor.h - clang-tidy ------------------*- C++ -*-===//
//===--- UndelegatedConstructorCheck.h - clang-tidy -------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -14,7 +14,7 @@

namespace clang {
namespace tidy {
namespace misc {
namespace bugprone {

/// Finds creation of temporary objects in constructors that look like a
/// function call to another constructor of the same class.
Expand All @@ -29,7 +29,7 @@ class UndelegatedConstructorCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace misc
} // namespace bugprone
} // namespace tidy
} // namespace clang

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "../google/ExplicitConstructorCheck.h"
#include "../misc/NewDeleteOverloadsCheck.h"
#include "../misc/StaticAssertCheck.h"
#include "../misc/UndelegatedConstructor.h"
#include "../bugprone/UndelegatedConstructorCheck.h"
#include "../modernize/DeprecatedHeadersCheck.h"
#include "../modernize/UseAutoCheck.h"
#include "../modernize/UseEmplaceCheck.h"
Expand Down Expand Up @@ -83,7 +83,7 @@ class HICPPModule : public ClangTidyModule {
CheckFactories.registerCheck<misc::StaticAssertCheck>(
"hicpp-static-assert");
CheckFactories.registerCheck<modernize::UseAutoCheck>("hicpp-use-auto");
CheckFactories.registerCheck<misc::UndelegatedConstructorCheck>(
CheckFactories.registerCheck<bugprone::UndelegatedConstructorCheck>(
"hicpp-undelegated-constructor");
CheckFactories.registerCheck<modernize::UseEmplaceCheck>(
"hicpp-use-emplace");
Expand Down
4 changes: 0 additions & 4 deletions clang-tools-extra/clang-tidy/misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ add_clang_library(clangTidyMiscModule
SizeofContainerCheck.cpp
SizeofExpressionCheck.cpp
StaticAssertCheck.cpp
SuspiciousSemicolonCheck.cpp
SuspiciousStringCompareCheck.cpp
SwappedArgumentsCheck.cpp
ThrowByValueCatchByReferenceCheck.cpp
UndelegatedConstructor.cpp
UniqueptrResetReleaseCheck.cpp
UnusedAliasDeclsCheck.cpp
UnusedParametersCheck.cpp
Expand Down
12 changes: 0 additions & 12 deletions clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
#include "SizeofContainerCheck.h"
#include "SizeofExpressionCheck.h"
#include "StaticAssertCheck.h"
#include "SuspiciousSemicolonCheck.h"
#include "SuspiciousStringCompareCheck.h"
#include "SwappedArgumentsCheck.h"
#include "ThrowByValueCatchByReferenceCheck.h"
#include "UnconventionalAssignOperatorCheck.h"
#include "UndelegatedConstructor.h"
#include "UniqueptrResetReleaseCheck.h"
#include "UnusedAliasDeclsCheck.h"
#include "UnusedParametersCheck.h"
Expand Down Expand Up @@ -55,16 +51,8 @@ class MiscModule : public ClangTidyModule {
CheckFactories.registerCheck<SizeofExpressionCheck>(
"misc-sizeof-expression");
CheckFactories.registerCheck<StaticAssertCheck>("misc-static-assert");
CheckFactories.registerCheck<SuspiciousSemicolonCheck>(
"misc-suspicious-semicolon");
CheckFactories.registerCheck<SuspiciousStringCompareCheck>(
"misc-suspicious-string-compare");
CheckFactories.registerCheck<SwappedArgumentsCheck>(
"misc-swapped-arguments");
CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
"misc-throw-by-value-catch-by-reference");
CheckFactories.registerCheck<UndelegatedConstructorCheck>(
"misc-undelegated-constructor");
CheckFactories.registerCheck<UniqueptrResetReleaseCheck>(
"misc-uniqueptr-reset-release");
CheckFactories.registerCheck<UnusedAliasDeclsCheck>(
Expand Down
12 changes: 12 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ Improvements to clang-tidy
- The 'misc-suspicious-missing-comma' check was renamed to `bugprone-suspicious-missing-comma
<http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-missing-comma.html>`_

- The 'misc-suspicious-semicolon' check was renamed to `bugprone-suspicious-semicolon
<http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-semicolon.html>`_

- The 'misc-suspicious-string-compare' check was renamed to `bugprone-suspicious-string-compare
<http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-string-compare.html>`_

- The 'misc-swapped-arguments' check was renamed to `bugprone-swapped-arguments
<http://clang.llvm.org/extra/clang-tidy/checks/bugprone-swapped-arguments.html>`_

- The 'misc-undelegated-constructor' check was renamed to `bugprone-undelegated-constructor
<http://clang.llvm.org/extra/clang-tidy/checks/bugprone-undelegated-constructor.html>`_

Improvements to include-fixer
-----------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. title:: clang-tidy - misc-suspicious-semicolon
.. title:: clang-tidy - bugprone-suspicious-semicolon

misc-suspicious-semicolon
=========================
bugprone-suspicious-semicolon
=============================

Finds most instances of stray semicolons that unexpectedly alter the meaning of
the code. More specifically, it looks for ``if``, ``while``, ``for`` and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. title:: clang-tidy - misc-suspicious-string-compare
.. title:: clang-tidy - bugprone-suspicious-string-compare

misc-suspicious-string-compare
==============================
bugprone-suspicious-string-compare
==================================

Find suspicious usage of runtime string comparison functions.
This check is valid in C and C++.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. title:: clang-tidy - bugprone-swapped-arguments

bugprone-swapped-arguments
==========================

Finds potentially swapped arguments by looking at implicit conversions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.. title:: clang-tidy - misc-undelegated-constructor

misc-undelegated-constructor
============================
.. title:: clang-tidy - bugprone-undelegated-constructor

bugprone-undelegated-constructor
================================

Finds creation of temporary objects in constructors that look like a
function call to another constructor of the same class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.. title:: clang-tidy - hicpp-undelegated-construtor
.. meta::
:http-equiv=refresh: 5;URL=misc-undelegated-constructor.html
:http-equiv=refresh: 5;URL=bugprone-undelegated-constructor.html

hicpp-undelegated-constructor
=============================

This check is an alias for `misc-undelegated-constructor <misc-undelegated-constructor.html>`_.
This check is an alias for `bugprone-undelegated-constructor <bugprone-undelegated-constructor.html>`_.
Partially implements `rule 12.4.5 <http://www.codingstandard.com/rule/12-4-5-use-delegating-constructors-to-reduce-code-duplication/>`_
to find misplaced constructor calls inside a constructor.

Expand Down

0 comments on commit eb9d944

Please sign in to comment.