[clang-tools-extra] r220631 - [clang-tidy] Bring order to check registration.
Alexander Kornienko
alexfh at google.com
Sat Oct 25 18:41:15 PDT 2014
Author: alexfh
Date: Sat Oct 25 20:41:14 2014
New Revision: 220631
URL: http://llvm.org/viewvc/llvm-project?rev=220631&view=rev
Log:
[clang-tidy] Bring order to check registration.
Summary:
Register readability checks in a separate module. Renamed the checks
and test file names accordingly.
Reviewers: djasper, klimek
Reviewed By: klimek
Subscribers: curdeius, cfe-commits
Differential Revision: http://reviews.llvm.org/D5936
Added:
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.c
- copied unchanged from r220628, clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.c
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp
- copied unchanged from r220482, clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
- copied unchanged from r220482, clang-tools-extra/trunk/test/clang-tidy/use-override.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-few-lines.cpp
- copied, changed from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-few-lines.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-same-line.cpp
- copied, changed from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-same-line.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-single-line.cpp
- copied, changed from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-single-line.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
- copied, changed from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp
- copied, changed from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-function-size.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
- copied, changed from r220482, clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp
- copied unchanged from r220482, clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityChecksTest.cpp
Removed:
clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.c
clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-few-lines.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-same-line.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-single-line.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-function-size.cpp
clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp
clang-tools-extra/trunk/test/clang-tidy/use-override.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityChecksTest.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/llvm/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/test/clang-tidy/google-module.cpp
clang-tools-extra/trunk/unittests/clang-tidy/CMakeLists.txt
Modified: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt Sat Oct 25 20:41:14 2014
@@ -20,5 +20,5 @@ add_clang_library(clangTidyGoogleModule
clangBasic
clangLex
clangTidy
- clangTidyReadability
+ clangTidyReadabilityModule
)
Modified: clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp Sat Oct 25 20:41:14 2014
@@ -22,7 +22,9 @@
#include "UnnamedNamespaceInHeaderCheck.h"
#include "UsingNamespaceDirectiveCheck.h"
#include "../readability/BracesAroundStatementsCheck.h"
+#include "../readability/FunctionSize.h"
#include "../readability/NamespaceCommentCheck.h"
+#include "../readability/RedundantSmartptrGet.h"
using namespace clang::ast_matchers;
@@ -54,10 +56,14 @@ public:
"google-readability-function");
CheckFactories.registerCheck<readability::TodoCommentCheck>(
"google-readability-todo");
- CheckFactories.registerCheck<readability::NamespaceCommentCheck>(
- "google-readability-namespace-comments");
CheckFactories.registerCheck<readability::BracesAroundStatementsCheck>(
"google-readability-braces-around-statements");
+ CheckFactories.registerCheck<readability::FunctionSizeCheck>(
+ "google-readability-function-size");
+ CheckFactories.registerCheck<readability::NamespaceCommentCheck>(
+ "google-readability-namespace-comments");
+ CheckFactories.registerCheck<readability::RedundantSmartptrGet>(
+ "google-readability-redundant-smartptr-get");
}
ClangTidyOptions getModuleOptions() override {
@@ -65,6 +71,7 @@ public:
auto &Opts = Options.CheckOptions;
Opts["google-readability-braces-around-statements.ShortStatementLines"] =
"1";
+ Opts["google-readability-function-size.StatementThreshold"] = "800";
Opts["google-readability-namespace-comments.ShortNamespaceLines"] = "1";
Opts["google-readability-namespace-comments.SpacesBeforeComments"] = "2";
return Options;
Modified: clang-tools-extra/trunk/clang-tidy/llvm/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/CMakeLists.txt?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/CMakeLists.txt Sat Oct 25 20:41:14 2014
@@ -12,7 +12,7 @@ add_clang_library(clangTidyLLVMModule
clangBasic
clangLex
clangTidy
- clangTidyReadability
+ clangTidyReadabilityModule
clangTidyUtils
clangTooling
)
Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Sat Oct 25 20:41:14 2014
@@ -15,6 +15,4 @@ add_clang_library(clangTidyMiscModule
clangBasic
clangLex
clangTidy
- # Some readability checks are currently registered in the misc module.
- clangTidyReadability
)
Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Sat Oct 25 20:41:14 2014
@@ -10,11 +10,6 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
-// FIXME: Figure out if we want to create a separate module for readability
-// checks instead of registering them here.
-#include "../readability/BracesAroundStatementsCheck.h"
-#include "../readability/FunctionSize.h"
-#include "../readability/RedundantSmartptrGet.h"
#include "ArgumentCommentCheck.h"
#include "BoolPointerImplicitConversion.h"
#include "SwappedArgumentsCheck.h"
@@ -31,12 +26,6 @@ public:
CheckFactories.registerCheck<ArgumentCommentCheck>("misc-argument-comment");
CheckFactories.registerCheck<BoolPointerImplicitConversion>(
"misc-bool-pointer-implicit-conversion");
- CheckFactories.registerCheck<readability::BracesAroundStatementsCheck>(
- "misc-braces-around-statements");
- CheckFactories.registerCheck<readability::FunctionSizeCheck>(
- "misc-function-size");
- CheckFactories.registerCheck<readability::RedundantSmartptrGet>(
- "misc-redundant-smartptr-get");
CheckFactories.registerCheck<SwappedArgumentsCheck>(
"misc-swapped-arguments");
CheckFactories.registerCheck<UndelegatedConstructorCheck>(
Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Sat Oct 25 20:41:14 2014
@@ -1,9 +1,10 @@
set(LLVM_LINK_COMPONENTS support)
-add_clang_library(clangTidyReadability
+add_clang_library(clangTidyReadabilityModule
BracesAroundStatementsCheck.cpp
FunctionSize.cpp
NamespaceCommentCheck.cpp
+ ReadabilityTidyModule.cpp
RedundantSmartptrGet.cpp
LINK_LIBS
Added: clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=220631&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp Sat Oct 25 20:41:14 2014
@@ -0,0 +1,44 @@
+//===--- ReadabilityTidyModule.cpp - clang-tidy ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+#include "BracesAroundStatementsCheck.h"
+#include "FunctionSize.h"
+#include "RedundantSmartptrGet.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+class ReadabilityModule : public ClangTidyModule {
+public:
+ void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+ CheckFactories.registerCheck<BracesAroundStatementsCheck>(
+ "readability-braces-around-statements");
+ CheckFactories.registerCheck<FunctionSizeCheck>(
+ "readability-function-size");
+ CheckFactories.registerCheck<RedundantSmartptrGet>(
+ "readability-redundant-smartptr-get");
+ }
+};
+
+} // namespace readability
+
+// Register the MiscTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<readability::ReadabilityModule>
+X("readability-module", "Adds readability-related checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the MiscModule.
+volatile int ReadabilityModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Modified: clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt Sat Oct 25 20:41:14 2014
@@ -12,6 +12,7 @@ target_link_libraries(clang-tidy
clangTidyGoogleModule
clangTidyLLVMModule
clangTidyMiscModule
+ clangTidyReadabilityModule
clangTooling
)
Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Sat Oct 25 20:41:14 2014
@@ -302,6 +302,10 @@ static int GoogleModuleAnchorDestination
extern volatile int MiscModuleAnchorSource;
static int MiscModuleAnchorDestination = MiscModuleAnchorSource;
+// This anchor is used to force the linker to link the ReadabilityModule.
+extern volatile int ReadabilityModuleAnchorSource;
+static int ReadabilityModuleAnchorDestination = ReadabilityModuleAnchorSource;
+
} // namespace tidy
} // namespace clang
Removed: clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.c?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.c (removed)
@@ -1,9 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-casting %t -- -x c
-// REQUIRES: shell
-
-void f(const char *cpc) {
- const char *cpc2 = (const char*)cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: Redundant cast to the same type. [google-readability-casting]
- // CHECK-FIXES: const char *cpc2 = cpc;
- char *pc = (char*)cpc;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.cpp?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/avoid-c-style-casts.cpp (removed)
@@ -1,126 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-casting %t
-// REQUIRES: shell
-
-bool g() { return false; }
-
-enum Enum { Enum1 };
-struct X {};
-struct Y : public X {};
-
-void f(int a, double b, const char *cpc, const void *cpv, X *pX) {
- const char *cpc2 = (const char*)cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: Redundant cast to the same type. [google-readability-casting]
- // CHECK-FIXES: const char *cpc2 = cpc;
-
- char *pc = (char*)cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged. Use const_cast. {{.*}}
- // CHECK-FIXES: char *pc = const_cast<char*>(cpc);
-
- char *pc2 = (char*)(cpc + 33);
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: C-style casts are discouraged. Use const_cast. {{.*}}
- // CHECK-FIXES: char *pc2 = const_cast<char*>(cpc + 33);
-
- const char &crc = *cpc;
- char &rc = (char&)crc;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged. Use const_cast. {{.*}}
- // CHECK-FIXES: char &rc = const_cast<char&>(crc);
-
- char &rc2 = (char&)*cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: C-style casts are discouraged. Use const_cast. {{.*}}
- // CHECK-FIXES: char &rc2 = const_cast<char&>(*cpc);
-
- char ** const* const* ppcpcpc;
- char ****ppppc = (char****)ppcpcpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: C-style casts are discouraged. Use const_cast. {{.*}}
- // CHECK-FIXES: char ****ppppc = const_cast<char****>(ppcpcpc);
-
- char ***pppc = (char***)*(ppcpcpc);
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: C-style casts are discouraged. Use const_cast. {{.*}}
- // CHECK-FIXES: char ***pppc = const_cast<char***>(*(ppcpcpc));
-
- char ***pppc2 = (char***)(*ppcpcpc);
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged. Use const_cast. {{.*}}
- // CHECK-FIXES: char ***pppc2 = const_cast<char***>(*ppcpcpc);
-
- char *pc5 = (char*)(const char*)(cpv);
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: C-style casts are discouraged. Use const_cast. {{.*}}
- // CHECK-MESSAGES: :[[@LINE-2]]:22: warning: C-style casts are discouraged. Use reinterpret_cast. {{.*}}
- // CHECK-FIXES: char *pc5 = const_cast<char*>(reinterpret_cast<const char*>(cpv));
-
- int b1 = (int)b;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: C-style casts are discouraged. Use static_cast. [google-readability-casting]
- // CHECK-FIXES: int b1 = static_cast<int>(b);
-
- Y *pB = (Y*)pX;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: C-style casts are discouraged. Use static_cast/const_cast/reinterpret_cast. [google-readability-casting]
- Y &rB = (Y&)*pX;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: C-style casts are discouraged. Use static_cast/const_cast/reinterpret_cast. [google-readability-casting]
-
- const char *pc3 = (const char*)cpv;
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: C-style casts are discouraged. Use reinterpret_cast. [google-readability-casting]
- // CHECK-FIXES: const char *pc3 = reinterpret_cast<const char*>(cpv);
-
- char *pc4 = (char*)cpv;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: C-style casts are discouraged. Use static_cast/const_cast/reinterpret_cast. [google-readability-casting]
- // CHECK-FIXES: char *pc4 = (char*)cpv;
-
- b1 = (int)Enum1;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: C-style casts are discouraged. Use static_cast. [google-readability-casting]
- // CHECK-FIXES: b1 = static_cast<int>(Enum1);
-
- Enum e = (Enum)b1;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: C-style casts are discouraged. Use static_cast. [google-readability-casting]
- // CHECK-FIXES: Enum e = static_cast<Enum>(b1);
-
- // CHECK-MESSAGES-NOT: warning:
- int b2 = int(b);
- int b3 = static_cast<double>(b);
- int b4 = b;
- double aa = a;
- (void)b2;
- return (void)g();
-}
-
-template <typename T>
-void template_function(T t, int n) {
- int i = (int)t;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: C-style casts are discouraged. Use static_cast/const_cast/reinterpret_cast.
- // CHECK-FIXES: int i = (int)t;
- int j = (int)n;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Redundant cast to the same type.
- // CHECK-FIXES: int j = n;
-}
-
-template <typename T>
-struct TemplateStruct {
- void f(T t, int n) {
- int k = (int)t;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged. Use static_cast/const_cast/reinterpret_cast.
- // CHECK-FIXES: int k = (int)t;
- int l = (int)n;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Redundant cast to the same type.
- // CHECK-FIXES: int l = n;
- }
-};
-
-void test_templates() {
- template_function(1, 42);
- template_function(1.0, 42);
- TemplateStruct<int>().f(1, 42);
- TemplateStruct<double>().f(1.0, 42);
-}
-
-#define CAST(type, value) (type)(value)
-void macros(double d) {
- int i = CAST(int, d);
-}
-
-enum E { E1 = 1 };
-template <E e>
-struct A {
- // Usage of template argument e = E1 is represented as (E)1 in the AST for
- // some reason. We have a special treatment of this case to avoid warnings
- // here.
- static const E ee = e;
-};
-struct B : public A<E1> {};
Modified: clang-tools-extra/trunk/test/clang-tidy/google-module.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-module.cpp?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-module.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-module.cpp Sat Oct 25 20:41:14 2014
@@ -2,6 +2,8 @@
// CHECK: CheckOptions:
// CHECK: {{- key: *google-readability-braces-around-statements.ShortStatementLines}}
// CHECK-NEXT: {{value: *'1'}}
+// CHECK: {{- key: *google-readability-function-size.StatementThreshold}}
+// CHECK-NEXT: {{value: *'800'}}
// CHECK: {{- key: *google-readability-namespace-comments.ShortNamespaceLines}}
// CHECK-NEXT: {{value: *'1'}}
// CHECK: {{- key: *google-readability-namespace-comments.SpacesBeforeComments}}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-few-lines.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-few-lines.cpp?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-few-lines.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-few-lines.cpp (removed)
@@ -1,31 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t -config="{CheckOptions: [{key: misc-braces-around-statements.ShortStatementLines, value: 4}]}" --
-// REQUIRES: shell
-
-void do_something(const char *) {}
-
-bool cond(const char *) {
- return false;
-}
-
-void test() {
- if (cond("if1") /*comment*/) do_something("same-line");
-
- if (cond("if2"))
- do_something("single-line");
-
- if (cond("if3") /*comment*/)
- // some comment
- do_something("three"
- "lines");
-
- if (cond("if4") /*comment*/)
- // some comment
- do_something("many"
- "many"
- "many"
- "many"
- "lines");
- // CHECK-MESSAGES: :[[@LINE-7]]:31: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if4") /*comment*/) {
- // CHECK-FIXES: }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-same-line.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-same-line.cpp?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-same-line.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-same-line.cpp (removed)
@@ -1,37 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t -config="{CheckOptions: [{key: misc-braces-around-statements.ShortStatementLines, value: 1}]}" --
-// REQUIRES: shell
-
-void do_something(const char *) {}
-
-bool cond(const char *) {
- return false;
-}
-
-void test() {
- if (cond("if1") /*comment*/) do_something("same-line");
-
- if (cond("if2"))
- do_something("single-line");
- // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if2")) {
- // CHECK-FIXES: }
-
- if (cond("if3") /*comment*/)
- // some comment
- do_something("three"
- "lines");
- // CHECK-MESSAGES: :[[@LINE-4]]:31: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if3") /*comment*/) {
- // CHECK-FIXES: }
-
- if (cond("if4") /*comment*/)
- // some comment
- do_something("many"
- "many"
- "many"
- "many"
- "lines");
- // CHECK-MESSAGES: :[[@LINE-7]]:31: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if4") /*comment*/) {
- // CHECK-FIXES: }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-single-line.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-single-line.cpp?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-single-line.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-single-line.cpp (removed)
@@ -1,34 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t -config="{CheckOptions: [{key: misc-braces-around-statements.ShortStatementLines, value: 2}]}" --
-// REQUIRES: shell
-
-void do_something(const char *) {}
-
-bool cond(const char *) {
- return false;
-}
-
-void test() {
- if (cond("if1") /*comment*/) do_something("same-line");
-
- if (cond("if2"))
- do_something("single-line");
-
- if (cond("if3") /*comment*/)
- // some comment
- do_something("three"
- "lines");
- // CHECK-MESSAGES: :[[@LINE-4]]:31: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if3") /*comment*/) {
- // CHECK-FIXES: }
-
- if (cond("if4") /*comment*/)
- // some comment
- do_something("many"
- "many"
- "many"
- "many"
- "lines");
- // CHECK-MESSAGES: :[[@LINE-7]]:31: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if4") /*comment*/) {
- // CHECK-FIXES: }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements.cpp?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements.cpp (removed)
@@ -1,174 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t
-// REQUIRES: shell
-
-void do_something(const char *) {}
-
-bool cond(const char *) {
- return false;
-}
-
-#define EMPTY_MACRO
-#define EMPTY_MACRO_FUN()
-
-void test() {
- if (cond("if0") /*comment*/) do_something("same-line");
- // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if0") /*comment*/) { do_something("same-line");
- // CHECK-FIXES: }
-
- if (cond("if0.1"))
- do_something("single-line");
- // CHECK-MESSAGES: :[[@LINE-2]]:21: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if0.1")) {
- // CHECK-FIXES: }
-
- if (cond("if1") /*comment*/)
- // some comment
- do_something("if1");
- // CHECK-MESSAGES: :[[@LINE-3]]:31: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if1") /*comment*/) {
- // CHECK-FIXES: }
- if (cond("if2")) {
- do_something("if2");
- }
- if (cond("if3"))
- ;
- // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if3")) {
- // CHECK-FIXES: }
-
- if (cond("if-else1"))
- do_something("if-else1");
- // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("if-else1")) {
- // CHECK-FIXES: } else {
- else
- do_something("if-else1 else");
- // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: statement should be inside braces
- // CHECK-FIXES: }
- if (cond("if-else2")) {
- do_something("if-else2");
- } else {
- do_something("if-else2 else");
- }
-
- if (cond("if-else if-else1"))
- do_something("if");
- // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: statement should be inside braces
- // CHECK-FIXES: } else if (cond("else if1")) {
- else if (cond("else if1"))
- do_something("else if");
- // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: statement should be inside braces
- else
- do_something("else");
- // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: statement should be inside braces
- // CHECK-FIXES: }
- if (cond("if-else if-else2")) {
- do_something("if");
- } else if (cond("else if2")) {
- do_something("else if");
- } else {
- do_something("else");
- }
-
- for (;;)
- do_something("for");
- // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: statement should be inside braces
- // CHECK-FIXES: for (;;) {
- // CHECK-FIXES: }
- for (;;) {
- do_something("for");
- }
- for (;;)
- ;
- // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: statement should be inside braces
- // CHECK-FIXES: for (;;) {
- // CHECK-FIXES: }
-
- int arr[4] = {1, 2, 3, 4};
- for (int a : arr)
- do_something("for-range");
- // CHECK-MESSAGES: :[[@LINE-2]]:20: warning: statement should be inside braces
- // CHECK-FIXES: for (int a : arr) {
- // CHECK-FIXES: }
- for (int a : arr) {
- do_something("for-range");
- }
- for (int a : arr)
- ;
- // CHECK-MESSAGES: :[[@LINE-2]]:20: warning: statement should be inside braces
- // CHECK-FIXES: for (int a : arr) {
- // CHECK-FIXES: }
-
- while (cond("while1"))
- do_something("while");
- // CHECK-MESSAGES: :[[@LINE-2]]:25: warning: statement should be inside braces
- // CHECK-FIXES: while (cond("while1")) {
- // CHECK-FIXES: }
- while (cond("while2")) {
- do_something("while");
- }
- while (false)
- ;
- // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: statement should be inside braces
- // CHECK-FIXES: while (false) {
- // CHECK-FIXES: }
-
- do
- do_something("do1");
- while (cond("do1"));
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: statement should be inside braces
- // CHECK-FIXES: do {
- // CHECK-FIXES: } while (cond("do1"));
- do {
- do_something("do2");
- } while (cond("do2"));
-
- do
- ;
- while (false);
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: statement should be inside braces
- // CHECK-FIXES: do {
- // CHECK-FIXES: } while (false);
-
- if (cond("ifif1"))
- // comment
- if (cond("ifif2"))
- // comment
- /*comment*/ ; // comment
- // CHECK-MESSAGES: :[[@LINE-5]]:21: warning: statement should be inside braces
- // CHECK-MESSAGES: :[[@LINE-4]]:23: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("ifif1")) {
- // CHECK-FIXES: if (cond("ifif2")) {
- // CHECK-FIXES: }
- // CHECK-FIXES-NEXT: }
-
- if (cond("ifif3"))
- // comment
- if (cond("ifif4")) {
- // comment
- /*comment*/; // comment
- }
- // CHECK-MESSAGES: :[[@LINE-6]]:21: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("ifif3")) {
- // CHECK-FIXES: }
-
- if (cond("ifif5"))
- ; /* multi-line
- comment */
- // CHECK-MESSAGES: :[[@LINE-3]]:21: warning: statement should be inside braces
- // CHECK-FIXES: if (cond("ifif5")) {
- // CHECK-FIXES: }/* multi-line
-
- if (1) while (2) if (3) for (;;) do ; while(false) /**/;/**/
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should be inside braces
- // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: statement should be inside braces
- // CHECK-MESSAGES: :[[@LINE-3]]:26: warning: statement should be inside braces
- // CHECK-MESSAGES: :[[@LINE-4]]:35: warning: statement should be inside braces
- // CHECK-MESSAGES: :[[@LINE-5]]:38: warning: statement should be inside braces
- // CHECK-FIXES: if (1) { while (2) { if (3) { for (;;) { do { ; } while(false) /**/;/**/
- // CHECK-FIXES-NEXT: }
- // CHECK-FIXES-NEXT: }
- // CHECK-FIXES-NEXT: }
- // CHECK-FIXES-NEXT: }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-function-size.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-function-size.cpp?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-function-size.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-function-size.cpp (removed)
@@ -1,58 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir -p %t
-// RUN: sed 's#// *[A-Z-][A-Z-]*:.*#//#' %s > %t/t.cpp
-// RUN: echo '{ Checks: "-*,misc-function-size", CheckOptions: [{key: misc-function-size.LineThreshold, value: 0}, {key: misc-function-size.StatementThreshold, value: 0}, {key: misc-function-size.BranchThreshold, value: 0}]}' > %t/.clang-tidy
-// RUN: clang-tidy %t/t.cpp -- -std=c++11 2>&1 | FileCheck %s -implicit-check-not='{{warning:|error:|note:}}'
-
-void foo1() {
-}
-
-void foo2() {;}
-// CHECK: warning: function 'foo2' exceeds recommended size/complexity thresholds
-// CHECK: note: 1 statements (threshold 0)
-
-void foo3() {
-;
-
-}
-// CHECK: warning: function 'foo3' exceeds recommended size/complexity thresholds
-// CHECK: note: 3 lines including whitespace and comments (threshold 0)
-// CHECK: note: 1 statements (threshold 0)
-
-void foo4(int i) { if (i) {} else; {}
-}
-// CHECK: warning: function 'foo4' exceeds recommended size/complexity thresholds
-// CHECK: note: 1 lines including whitespace and comments (threshold 0)
-// CHECK: note: 3 statements (threshold 0)
-// CHECK: note: 1 branches (threshold 0)
-
-void foo5(int i) {for(;i;)while(i)
-do;while(i);
-}
-// CHECK: warning: function 'foo5' exceeds recommended size/complexity thresholds
-// CHECK: note: 2 lines including whitespace and comments (threshold 0)
-// CHECK: note: 7 statements (threshold 0)
-// CHECK: note: 3 branches (threshold 0)
-
-template <typename T> T foo6(T i) {return i;
-}
-int x = foo6(0);
-// CHECK: warning: function 'foo6' exceeds recommended size/complexity thresholds
-// CHECK: note: 1 lines including whitespace and comments (threshold 0)
-// CHECK: note: 1 statements (threshold 0)
-
-void bar1() { [](){;;;;;;;;;;;if(1){}}();
-
-
-}
-// CHECK: warning: function 'bar1' exceeds recommended size/complexity thresholds
-// CHECK: note: 3 lines including whitespace and comments (threshold 0)
-// CHECK: note: 14 statements (threshold 0)
-// CHECK: note: 1 branches (threshold 0)
-
-void bar2() { class A { void barx() {;;} }; }
-// CHECK: warning: function 'bar2' exceeds recommended size/complexity thresholds
-// CHECK: note: 3 statements (threshold 0)
-//
-// CHECK: warning: function 'barx' exceeds recommended size/complexity thresholds
-// CHECK: note: 2 statements (threshold 0)
Copied: clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-few-lines.cpp (from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-few-lines.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-few-lines.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-few-lines.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-few-lines.cpp&r1=220482&r2=220631&rev=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-few-lines.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-few-lines.cpp Sat Oct 25 20:41:14 2014
@@ -1,4 +1,4 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t -config="{CheckOptions: [{key: misc-braces-around-statements.ShortStatementLines, value: 4}]}" --
+// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 4}]}" --
// REQUIRES: shell
void do_something(const char *) {}
Copied: clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-same-line.cpp (from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-same-line.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-same-line.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-same-line.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-same-line.cpp&r1=220482&r2=220631&rev=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-same-line.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-same-line.cpp Sat Oct 25 20:41:14 2014
@@ -1,4 +1,4 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t -config="{CheckOptions: [{key: misc-braces-around-statements.ShortStatementLines, value: 1}]}" --
+// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 1}]}" --
// REQUIRES: shell
void do_something(const char *) {}
Copied: clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-single-line.cpp (from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-single-line.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-single-line.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-single-line.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-single-line.cpp&r1=220482&r2=220631&rev=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements-single-line.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-single-line.cpp Sat Oct 25 20:41:14 2014
@@ -1,4 +1,4 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t -config="{CheckOptions: [{key: misc-braces-around-statements.ShortStatementLines, value: 2}]}" --
+// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 2}]}" --
// REQUIRES: shell
void do_something(const char *) {}
Copied: clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp (from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements.cpp&r1=220482&r2=220631&rev=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-braces-around-statements.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp Sat Oct 25 20:41:14 2014
@@ -1,4 +1,4 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t
+// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-braces-around-statements %t
// REQUIRES: shell
void do_something(const char *) {}
Copied: clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp (from r220482, clang-tools-extra/trunk/test/clang-tidy/misc-function-size.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-function-size.cpp&r1=220482&r2=220631&rev=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-function-size.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp Sat Oct 25 20:41:14 2014
@@ -1,7 +1,7 @@
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: sed 's#// *[A-Z-][A-Z-]*:.*#//#' %s > %t/t.cpp
-// RUN: echo '{ Checks: "-*,misc-function-size", CheckOptions: [{key: misc-function-size.LineThreshold, value: 0}, {key: misc-function-size.StatementThreshold, value: 0}, {key: misc-function-size.BranchThreshold, value: 0}]}' > %t/.clang-tidy
+// RUN: echo '{ Checks: "-*,readability-function-size", CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}]}' > %t/.clang-tidy
// RUN: clang-tidy %t/t.cpp -- -std=c++11 2>&1 | FileCheck %s -implicit-check-not='{{warning:|error:|note:}}'
void foo1() {
Copied: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp (from r220482, clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp&r1=220482&r2=220631&rev=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp Sat Oct 25 20:41:14 2014
@@ -1,4 +1,4 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-redundant-smartptr-get %t
+// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-redundant-smartptr-get %t
// REQUIRES: shell
#define NULL __null
@@ -49,7 +49,7 @@ void Positive() {
BarPtr u;
// CHECK-FIXES: BarPtr u;
BarPtr().get()->Do();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer. [misc-redundant-smartptr-get]
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer. [readability-redundant-smartptr-get]
// CHECK-MESSAGES: BarPtr().get()->Do();
// CHECK-FIXES: BarPtr()->Do();
Removed: clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp (removed)
@@ -1,129 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-redundant-smartptr-get %t
-// REQUIRES: shell
-
-#define NULL __null
-
-namespace std {
-
-template <typename T>
-struct unique_ptr {
- T& operator*() const;
- T* operator->() const;
- T* get() const;
-};
-
-template <typename T>
-struct shared_ptr {
- T& operator*() const;
- T* operator->() const;
- T* get() const;
-};
-
-} // namespace std
-
-struct Bar {
- void Do();
- void ConstDo() const;
-};
-struct BarPtr {
- Bar* operator->();
- Bar& operator*();
- Bar* get();
-};
-struct int_ptr {
- int* get();
- int* operator->();
- int& operator*();
-};
-
-struct Fail1 {
- Bar* get();
-};
-struct Fail2 {
- Bar* get();
- int* operator->();
- int& operator*();
-};
-
-void Positive() {
- BarPtr u;
- // CHECK-FIXES: BarPtr u;
- BarPtr().get()->Do();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer. [misc-redundant-smartptr-get]
- // CHECK-MESSAGES: BarPtr().get()->Do();
- // CHECK-FIXES: BarPtr()->Do();
-
- u.get()->ConstDo();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer.
- // CHECK-MESSAGES: u.get()->ConstDo();
- // CHECK-FIXES: u->ConstDo();
-
- Bar& b = *BarPtr().get();
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Redundant get() call on smart pointer.
- // CHECK-MESSAGES: Bar& b = *BarPtr().get();
- // CHECK-FIXES: Bar& b = *BarPtr();
-
- Bar& b2 = *std::unique_ptr<Bar>().get();
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: Redundant get() call on smart pointer.
- // CHECK-MESSAGES: Bar& b2 = *std::unique_ptr<Bar>().get();
- // CHECK-FIXES: Bar& b2 = *std::unique_ptr<Bar>();
-
- (*BarPtr().get()).ConstDo();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
- // CHECK-MESSAGES: (*BarPtr().get()).ConstDo();
- // CHECK-FIXES: (*BarPtr()).ConstDo();
-
- (*std::unique_ptr<Bar>().get()).ConstDo();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
- // CHECK-MESSAGES: (*std::unique_ptr<Bar>().get()).ConstDo();
- // CHECK-FIXES: (*std::unique_ptr<Bar>()).ConstDo();
-
- std::unique_ptr<Bar>* up;
- (*up->get()).Do();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
- // CHECK-MESSAGES: (*up->get()).Do();
- // CHECK-FIXES: (**up).Do();
-
- int_ptr ip;
- int i = *ip.get();
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Redundant get() call on smart pointer.
- // CHECK-MESSAGES: int i = *ip.get();
- // CHECK-FIXES: int i = *ip;
-
- std::unique_ptr<int> uu;
- std::shared_ptr<double> *ss;
- bool bb = uu.get() == nullptr;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Redundant get() call on smart pointer.
- // CHECK-MESSAGES: uu.get() == nullptr;
- // CHECK-FIXES: bool bb = uu == nullptr;
-
- bb = nullptr != ss->get();
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: Redundant get() call on smart pointer.
- // CHECK-MESSAGES: nullptr != ss->get();
- // CHECK-FIXES: bb = nullptr != *ss;
-}
-
-void Negative() {
- struct NegPtr {
- int* get();
- int* operator->() {
- return &*this->get();
- }
- int& operator*() {
- return *get();
- }
- };
-
- std::unique_ptr<Bar>* u;
- u->get()->Do();
-
- Fail1().get()->Do();
- Fail2().get()->Do();
- const Bar& b = *Fail1().get();
- (*Fail2().get()).Do();
-
- int_ptr ip;
- bool bb = std::unique_ptr<int>().get() == NULL;
- bb = ip.get() == nullptr;
- bb = u->get() == NULL;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/use-override.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/use-override.cpp?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/use-override.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/use-override.cpp (removed)
@@ -1,226 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-use-override %t
-// REQUIRES: shell
-
-#define ABSTRACT = 0
-
-#define OVERRIDE override
-#define VIRTUAL virtual
-#define NOT_VIRTUAL
-#define NOT_OVERRIDE
-
-#define MUST_USE_RESULT __attribute__((warn_unused_result))
-
-struct MUST_USE_RESULT MustUseResultObject {};
-
-struct Base {
- virtual ~Base() {}
- virtual void a();
- virtual void b();
- virtual void c();
- virtual void d();
- virtual void e() = 0;
- virtual void f() = 0;
- virtual void g() = 0;
-
- virtual void j() const;
- virtual MustUseResultObject k();
- virtual bool l() MUST_USE_RESULT;
-
- virtual void m();
-};
-
-struct SimpleCases : public Base {
-public:
- virtual ~SimpleCases();
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Prefer using 'override' or (rarely) 'final' instead of 'virtual'
- // CHECK-FIXES: {{^ ~SimpleCases\(\) override;}}
-
- void a();
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Annotate this
- // CHECK-FIXES: {{^ void a\(\) override;}}
-
- void b() override;
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^ void b\(\) override;}}
-
- virtual void c();
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ void c\(\) override;}}
-
- virtual void d() override;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
- // CHECK-FIXES: {{^ void d\(\) override;}}
-
- virtual void e() = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ void e\(\) override = 0;}}
-
- virtual void f()=0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ void f\(\)override =0;}}
-
- virtual void g() ABSTRACT;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ void g\(\) override ABSTRACT;}}
-
- virtual void j() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ void j\(\) const override;}}
-
- virtual MustUseResultObject k(); // Has an implicit attribute.
- // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: Prefer using
- // CHECK-FIXES: {{^ MustUseResultObject k\(\) override;}}
-
- virtual bool l() MUST_USE_RESULT; // Has an explicit attribute
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ bool l\(\) override MUST_USE_RESULT;}}
-
- virtual void m() override final;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
- // CHECK-FIXES: {{^ void m\(\) final;}}
-};
-
-// CHECK-MESSAGES-NOT: warning:
-
-void SimpleCases::c() {}
-// CHECK-FIXES: {{^void SimpleCases::c\(\) {}}}
-
-SimpleCases::~SimpleCases() {}
-// CHECK-FIXES: {{^SimpleCases::~SimpleCases\(\) {}}}
-
-struct DefaultedDestructor : public Base {
- DefaultedDestructor() {}
- virtual ~DefaultedDestructor() = default;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Prefer using
- // CHECK-FIXES: {{^ ~DefaultedDestructor\(\) override = default;}}
-};
-
-struct FinalSpecified : public Base {
-public:
- virtual ~FinalSpecified() final;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Annotate this
- // CHECK-FIXES: {{^ ~FinalSpecified\(\) final;}}
-
- void b() final;
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^ void b\(\) final;}}
-
- virtual void d() final;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
- // CHECK-FIXES: {{^ void d\(\) final;}}
-
- virtual void e() final = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
- // CHECK-FIXES: {{^ void e\(\) final = 0;}}
-
- virtual void j() const final;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
- // CHECK-FIXES: {{^ void j\(\) const final;}}
-
- virtual bool l() final MUST_USE_RESULT;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
- // CHECK-FIXES: {{^ bool l\(\) final MUST_USE_RESULT;}}
-};
-
-struct InlineDefinitions : public Base {
-public:
- virtual ~InlineDefinitions() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Prefer using
- // CHECK-FIXES: {{^ ~InlineDefinitions\(\) override {}}}
-
- void a() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Annotate this
- // CHECK-FIXES: {{^ void a\(\) override {}}}
-
- void b() override {}
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^ void b\(\) override {}}}
-
- virtual void c() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ void c\(\) override {}}}
-
- virtual void d() override {}
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
- // CHECK-FIXES: {{^ void d\(\) override {}}}
-
- virtual void j() const {}
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ void j\(\) const override {}}}
-
- virtual MustUseResultObject k() {} // Has an implicit attribute.
- // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: Prefer using
- // CHECK-FIXES: {{^ MustUseResultObject k\(\) override {}}}
-
- virtual bool l() MUST_USE_RESULT {} // Has an explicit attribute
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ bool l\(\) override MUST_USE_RESULT {}}}
-};
-
-struct Macros : public Base {
- // Tests for 'virtual' and 'override' being defined through macros. Basically
- // give up for now.
- NOT_VIRTUAL void a() NOT_OVERRIDE;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: Annotate this
- // CHECK-FIXES: {{^ NOT_VIRTUAL void a\(\) override NOT_OVERRIDE;}}
-
- VIRTUAL void b() NOT_OVERRIDE;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ VIRTUAL void b\(\) override NOT_OVERRIDE;}}
-
- NOT_VIRTUAL void c() OVERRIDE;
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^ NOT_VIRTUAL void c\(\) OVERRIDE;}}
-
- VIRTUAL void d() OVERRIDE;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
- // CHECK-FIXES: {{^ VIRTUAL void d\(\) OVERRIDE;}}
-
-#define FUNC(return_type, name) return_type name()
- FUNC(void, e);
- // CHECK-FIXES: {{^ FUNC\(void, e\);}}
-
-#define F virtual void f();
- F
- // CHECK-FIXES: {{^ F}}
-
- VIRTUAL void g() OVERRIDE final;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
- // CHECK-FIXES: {{^ VIRTUAL void g\(\) final;}}
-};
-
-// Tests for templates.
-template <typename T> struct TemplateBase {
- virtual void f(T t);
-};
-
-template <typename T> struct DerivedFromTemplate : public TemplateBase<T> {
- virtual void f(T t);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
- // CHECK-FIXES: {{^ void f\(T t\) override;}}
-};
-void f() { DerivedFromTemplate<int>().f(2); }
-
-template <class C>
-struct UnusedMemberInstantiation : public C {
- virtual ~UnusedMemberInstantiation() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Prefer using
- // CHECK-FIXES: {{^ ~UnusedMemberInstantiation\(\) override {}}}
-};
-struct IntantiateWithoutUse : public UnusedMemberInstantiation<Base> {};
-
-struct Base2 {
- virtual ~Base2() {}
- virtual void a();
-};
-
-// The OverrideAttr isn't propagated to specializations in all cases. Make sure
-// we don't add "override" a second time.
-template <int I>
-struct MembersOfSpecializations : public Base2 {
- void a() override;
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^ void a\(\) override;}}
-};
-template <> void MembersOfSpecializations<3>::a() {}
-void ff() { MembersOfSpecializations<3>().a(); };
Modified: clang-tools-extra/trunk/unittests/clang-tidy/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/CMakeLists.txt?rev=220631&r1=220630&r2=220631&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/CMakeLists.txt Sat Oct 25 20:41:14 2014
@@ -9,10 +9,10 @@ include_directories(${CLANG_LINT_SOURCE_
add_extra_unittest(ClangTidyTests
ClangTidyDiagnosticConsumerTest.cpp
ClangTidyOptionsTest.cpp
- LLVMModuleTest.cpp
- ReadabilityChecksTest.cpp
GoogleModuleTest.cpp
- MiscModuleTest.cpp)
+ LLVMModuleTest.cpp
+ MiscModuleTest.cpp
+ ReadabilityModuleTest.cpp)
target_link_libraries(ClangTidyTests
clangAST
@@ -23,7 +23,7 @@ target_link_libraries(ClangTidyTests
clangTidyGoogleModule
clangTidyLLVMModule
clangTidyMiscModule
- clangTidyReadability
+ clangTidyReadabilityModule
clangTidyUtils
clangTooling
)
Removed: clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityChecksTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityChecksTest.cpp?rev=220630&view=auto
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityChecksTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityChecksTest.cpp (removed)
@@ -1,99 +0,0 @@
-#include "ClangTidyTest.h"
-#include "readability/NamespaceCommentCheck.h"
-#include "gtest/gtest.h"
-
-namespace clang {
-namespace tidy {
-namespace test {
-
-using readability::NamespaceCommentCheck;
-
-TEST(NamespaceCommentCheckTest, Basic) {
- EXPECT_EQ("namespace i {\n} // namespace i",
- runCheckOnCode<NamespaceCommentCheck>("namespace i {\n}"));
- EXPECT_EQ("namespace {\n} // namespace",
- runCheckOnCode<NamespaceCommentCheck>("namespace {\n}"));
- EXPECT_EQ(
- "namespace i { namespace j {\n} // namespace j\n } // namespace i",
- runCheckOnCode<NamespaceCommentCheck>("namespace i { namespace j {\n} }"));
-}
-
-TEST(NamespaceCommentCheckTest, SingleLineNamespaces) {
- EXPECT_EQ(
- "namespace i { namespace j { } }",
- runCheckOnCode<NamespaceCommentCheck>("namespace i { namespace j { } }"));
-}
-
-TEST(NamespaceCommentCheckTest, CheckExistingComments) {
- EXPECT_EQ("namespace i { namespace j {\n"
- "} /* namespace j */ } // namespace i\n"
- " /* random comment */",
- runCheckOnCode<NamespaceCommentCheck>(
- "namespace i { namespace j {\n"
- "} /* namespace j */ } /* random comment */"));
- EXPECT_EQ("namespace {\n"
- "} // namespace",
- runCheckOnCode<NamespaceCommentCheck>("namespace {\n"
- "} // namespace"));
- EXPECT_EQ("namespace {\n"
- "} //namespace",
- runCheckOnCode<NamespaceCommentCheck>("namespace {\n"
- "} //namespace"));
- EXPECT_EQ("namespace {\n"
- "} // anonymous namespace",
- runCheckOnCode<NamespaceCommentCheck>("namespace {\n"
- "} // anonymous namespace"));
- EXPECT_EQ("namespace {\n"
- "} // Anonymous namespace.",
- runCheckOnCode<NamespaceCommentCheck>("namespace {\n"
- "} // Anonymous namespace."));
- EXPECT_EQ("namespace q {\n"
- "} // namespace q",
- runCheckOnCode<NamespaceCommentCheck>("namespace q {\n"
- "} // anonymous namespace q"));
- EXPECT_EQ(
- "namespace My_NameSpace123 {\n"
- "} // namespace My_NameSpace123",
- runCheckOnCode<NamespaceCommentCheck>("namespace My_NameSpace123 {\n"
- "} // namespace My_NameSpace123"));
- EXPECT_EQ(
- "namespace My_NameSpace123 {\n"
- "} //namespace My_NameSpace123",
- runCheckOnCode<NamespaceCommentCheck>("namespace My_NameSpace123 {\n"
- "} //namespace My_NameSpace123"));
- EXPECT_EQ("namespace My_NameSpace123 {\n"
- "} // end namespace My_NameSpace123",
- runCheckOnCode<NamespaceCommentCheck>(
- "namespace My_NameSpace123 {\n"
- "} // end namespace My_NameSpace123"));
- // Understand comments only on the same line.
- EXPECT_EQ("namespace {\n"
- "} // namespace\n"
- "// namespace",
- runCheckOnCode<NamespaceCommentCheck>("namespace {\n"
- "}\n"
- "// namespace"));
- // Leave unknown comments.
- EXPECT_EQ("namespace {\n"
- "} // namespace // random text",
- runCheckOnCode<NamespaceCommentCheck>("namespace {\n"
- "} // random text"));
-}
-
-TEST(NamespaceCommentCheckTest, FixWrongComments) {
- EXPECT_EQ("namespace i { namespace jJ0_ {\n"
- "} // namespace jJ0_\n"
- " } // namespace i\n"
- " /* random comment */",
- runCheckOnCode<NamespaceCommentCheck>(
- "namespace i { namespace jJ0_ {\n"
- "} /* namespace qqq */ } /* random comment */"));
- EXPECT_EQ("namespace {\n"
- "} // namespace",
- runCheckOnCode<NamespaceCommentCheck>("namespace {\n"
- "} // namespace asdf"));
-}
-
-} // namespace test
-} // namespace tidy
-} // namespace clang
More information about the cfe-commits
mailing list