Skip to content

Commit

Permalink
[clang-tidy] rename_check.py misc-argument-comment bugprone-argument-…
Browse files Browse the repository at this point in the history
…comment

Summary: + manually convert the unit test to lit test.

Reviewers: hokein

Reviewed By: hokein

Subscribers: mgorny, xazax.hun, cfe-commits

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

llvm-svn: 318926
  • Loading branch information
alexfh committed Nov 23, 2017
1 parent adccab6 commit 6f67bcb
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 60 deletions.
Expand Up @@ -18,7 +18,7 @@ using namespace clang::ast_matchers;

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

ArgumentCommentCheck::ArgumentCommentCheck(StringRef Name,
ClangTidyContext *Context)
Expand Down Expand Up @@ -303,6 +303,6 @@ void ArgumentCommentCheck::check(const MatchFinder::MatchResult &Result) {
}
}

} // namespace misc
} // namespace bugprone
} // namespace tidy
} // namespace clang
Expand Up @@ -15,7 +15,7 @@

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

/// Checks that argument comments match parameter names.
///
Expand Down Expand Up @@ -48,7 +48,7 @@ class ArgumentCommentCheck : public ClangTidyCheck {
llvm::ArrayRef<const Expr *> Args);
};

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

Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
Expand Up @@ -10,6 +10,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "ArgumentCommentCheck.h"
#include "CopyConstructorInitCheck.h"
#include "IntegerDivisionCheck.h"
#include "MisplacedOperatorInStrlenInAllocCheck.h"
Expand All @@ -24,6 +25,8 @@ namespace bugprone {
class BugproneModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<ArgumentCommentCheck>(
"bugprone-argument-comment");
CheckFactories.registerCheck<CopyConstructorInitCheck>(
"bugprone-copy-constructor-init");
CheckFactories.registerCheck<IntegerDivisionCheck>(
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS support)

add_clang_library(clangTidyBugproneModule
ArgumentCommentCheck.cpp
BugproneTidyModule.cpp
CopyConstructorInitCheck.cpp
IntegerDivisionCheck.cpp
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -1,7 +1,6 @@
set(LLVM_LINK_COMPONENTS support)

add_clang_library(clangTidyMiscModule
ArgumentCommentCheck.cpp
AssertSideEffectCheck.cpp
ForwardingReferenceOverloadCheck.cpp
LambdaFunctionNameCheck.cpp
Expand Down
2 changes: 0 additions & 2 deletions clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
Expand Up @@ -10,7 +10,6 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "ArgumentCommentCheck.h"
#include "AssertSideEffectCheck.h"
#include "BoolPointerImplicitConversionCheck.h"
#include "DanglingHandleCheck.h"
Expand Down Expand Up @@ -63,7 +62,6 @@ namespace misc {
class MiscModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<ArgumentCommentCheck>("misc-argument-comment");
CheckFactories.registerCheck<AssertSideEffectCheck>(
"misc-assert-side-effect");
CheckFactories.registerCheck<ForwardingReferenceOverloadCheck>(
Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Expand Up @@ -57,6 +57,9 @@ The improvements are...
Improvements to clang-tidy
--------------------------

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

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

Expand Down
@@ -1,7 +1,7 @@
.. title:: clang-tidy - misc-argument-comment
.. title:: clang-tidy - bugprone-argument-comment

misc-argument-comment
=====================
bugprone-argument-comment
=========================

Checks that argument comments match parameter names.

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/docs/clang-tidy/checks/list.rst
Expand Up @@ -17,6 +17,7 @@ Clang-Tidy Checks
android-cloexec-open
android-cloexec-socket
boost-use-to-string
bugprone-argument-comment
bugprone-copy-constructor-init
bugprone-integer-division
bugprone-misplaced-operator-in-strlen-in-alloc
Expand Down Expand Up @@ -105,7 +106,6 @@ Clang-Tidy Checks
llvm-include-order
llvm-namespace-comment
llvm-twine-local
misc-argument-comment
misc-assert-side-effect
misc-bool-pointer-implicit-conversion
misc-dangling-handle
Expand Down
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s misc-argument-comment %t
// RUN: %check_clang_tidy %s bugprone-argument-comment %t

namespace testing {
namespace internal {
Expand Down
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s misc-argument-comment %t -- \
// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
// RUN: -config="{CheckOptions: [{key: StrictMode, value: 1}]}" --

void f(int _with_underscores_);
Expand Down
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s misc-argument-comment %t
// RUN: %check_clang_tidy %s bugprone-argument-comment %t

// FIXME: clang-tidy should provide a -verify mode to make writing these checks
// easier and more accurate.
Expand All @@ -14,9 +14,16 @@ void g() {
f(/*y=*/0, /*z=*/0);
// CHECK-FIXES: {{^}} f(/*y=*/0, /*z=*/0);

f(/*x=*/1, /*y=*/1);

ffff(0 /*aaaa=*/, /*bbbb*/ 0); // Unsupported formats.
}

struct C {
C(int x, int y);
};
C c(/*x=*/0, /*y=*/0);

struct Closure {};

template <typename T1, typename T2>
Expand Down Expand Up @@ -45,11 +52,38 @@ void templates() {

#define FALSE 0
void qqq(bool aaa);
void f() { qqq(/*bbb=*/FALSE); }
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: argument name 'bbb' in comment does not match parameter name 'aaa'
// CHECK-FIXES: void f() { qqq(/*bbb=*/FALSE); }
void f2() { qqq(/*bbb=*/FALSE); }
// CHECK-MESSAGES: [[@LINE-1]]:17: warning: argument name 'bbb' in comment does not match parameter name 'aaa'
// CHECK-FIXES: void f2() { qqq(/*bbb=*/FALSE); }

void f(bool _with_underscores_);
void f3(bool _with_underscores_);
void ignores_underscores() {
f(/*With_Underscores=*/false);
f3(/*With_Underscores=*/false);
}

namespace ThisEditDistanceAboveThreshold {
void f4(int xxx);
void g() { f4(/*xyz=*/0); }
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: argument name 'xyz' in comment does not match parameter name 'xxx'
// CHECK-FIXES: void g() { f4(/*xyz=*/0); }
}

namespace OtherEditDistanceAboveThreshold {
void f5(int xxx, int yyy);
void g() { f5(/*Zxx=*/0, 0); }
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
// CHECK-FIXES: void g() { f5(/*xxx=*/0, 0); }
struct C2 {
C2(int xxx, int yyy);
};
C2 c2(/*Zxx=*/0, 0);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
// CHECK-FIXES: C2 c2(/*xxx=*/0, 0);
}

namespace OtherEditDistanceBelowThreshold {
void f6(int xxx, int yyy);
void g() { f6(/*xxy=*/0, 0); }
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: argument name 'xxy' in comment does not match parameter name 'xxx'
// CHECK-FIXES: void g() { f6(/*xxy=*/0, 0); }
}
2 changes: 0 additions & 2 deletions clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
Expand Up @@ -12,7 +12,6 @@ add_extra_unittest(ClangTidyTests
IncludeInserterTest.cpp
GoogleModuleTest.cpp
LLVMModuleTest.cpp
MiscModuleTest.cpp
NamespaceAliaserTest.cpp
ObjCModuleTest.cpp
OverlappingReplacementsTest.cpp
Expand All @@ -29,7 +28,6 @@ target_link_libraries(ClangTidyTests
clangTidyAndroidModule
clangTidyGoogleModule
clangTidyLLVMModule
clangTidyMiscModule
clangTidyObjCModule
clangTidyReadabilityModule
clangTidyUtils
Expand Down
39 changes: 0 additions & 39 deletions clang-tools-extra/unittests/clang-tidy/MiscModuleTest.cpp

This file was deleted.

0 comments on commit 6f67bcb

Please sign in to comment.