[PATCH] D23480: Add a test for clang-tidy using the clang cl driver

Zachary Turner via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 12 17:58:31 PDT 2016


zturner created this revision.
zturner added a reviewer: alexfh.
zturner added a subscriber: cfe-commits.

In order to get this to work, the positional arguments must use `--driver-mode=cl <args>`, and NOT `clang-cl <args>`.  In the latter case, clang-tidy has to try really hard to "guess" whether the first argument is argv[0] or argv[1].  This still tests effectively the same thing, but without the convoluted magic of having to care about the name of the tool being run.

This is the test for D23455

https://reviews.llvm.org/D23480

Files:
  test/clang-tidy/clang-cl-driver.cpp

Index: test/clang-tidy/clang-cl-driver.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/clang-cl-driver.cpp
@@ -0,0 +1,17 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr %s -- --driver-mode=cl /DTEST1 /DFOO=foo /DBAR=bar | FileCheck -implicit-check-not="{{warning|error}}:" %s
+int *a = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#ifdef TEST1
+int *b = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
+#define foo 1
+#define bar 1
+#if FOO
+int *c = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
+#if BAR
+int *d = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
\ No newline at end of file


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23480.67948.patch
Type: text/x-patch
Size: 704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160813/131c15f3/attachment.bin>


More information about the cfe-commits mailing list