[PATCH] Add a check to flag the usage of C-style casts (Google Style).

Daniel Jasper djasper at google.com
Wed Jun 18 03:10:26 PDT 2014


================
Comment at: clang-tidy/google/CMakeLists.txt:4
@@ -3,2 +3,3 @@
 add_clang_library(clangTidyGoogleModule
+  CStyleCastsCheck.cpp
   ExplicitConstructorCheck.cpp
----------------
I think the naming is not ideal. First, the "..Check" is mostly redundant information, maybe remove that, at least for new checks. Second, it would be good to verify what is being checked with c-style casts. So, maybe DontUseCStyleCasts.cpp or AvoidCStyleCasts.cpp.

================
Comment at: clang-tidy/google/CStyleCastsCheck.h:21
@@ +20,3 @@
+///
+/// 'readability/casting'
+/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting
----------------
What is this?

================
Comment at: clang-tidy/google/GoogleTidyModule.cpp:25
@@ -23,1 +24,3 @@
     CheckFactories.addCheckFactory(
+        "google-readability-casting",
+        new ClangTidyCheckFactory<readability::CStyleCastsCheck>());
----------------
Maybe order alphabetically by check name?

================
Comment at: test/clang-tidy/c-style-casts.cpp:1
@@ +1,2 @@
+// RUN: clang-tidy -checks=-*,google-readability-casting %s -- | FileCheck %s
+
----------------
Maybe use check_clang_tidy_output.sh to decouple the check configuration.

================
Comment at: test/clang-tidy/c-style-casts.cpp:3
@@ +2,3 @@
+
+// CHECK-NOT: warning:
+bool g() { return false; }
----------------
Out of curiosity, why would there be a c-style cast here?

http://reviews.llvm.org/D4189






More information about the cfe-commits mailing list