summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/fix-errors.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2014-11-03 14:06:31 +0000
committerAlexander Kornienko <alexfh@google.com>2014-11-03 14:06:31 +0000
commit5eac3c6a44405e86639901e802fa86a4f02792f3 (patch)
treebf38b5eb90d02b1ed65483155be5554280268693 /clang-tools-extra/test/clang-tidy/fix-errors.cpp
parentcf6bfb1dd0a87fb93795b4ddedc663addab59293 (diff)
downloadbcm5719-llvm-5eac3c6a44405e86639901e802fa86a4f02792f3.tar.gz
bcm5719-llvm-5eac3c6a44405e86639901e802fa86a4f02792f3.zip
[clang-tidy] Added -fix-errors option
Summary: Added -fix-errors option to allow applying fixes when compiler errors are present. Without this flag -fix would bail out if there are compiler errors. This is needed to avoid applying wrong fixes if Clang fails to recover from compilation errors correctly. Reviewers: djasper, klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D6059 llvm-svn: 221152
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/fix-errors.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/fix-errors.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/fix-errors.cpp b/clang-tools-extra/test/clang-tidy/fix-errors.cpp
new file mode 100644
index 00000000000..639873e2524
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/fix-errors.cpp
@@ -0,0 +1,15 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp -checks='-*,google-explicit-constructor' -fix -- > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.cpp -check-prefix=CHECK-FIX %s
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp -checks='-*,google-explicit-constructor' -fix-errors -- > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.cpp -check-prefix=CHECK-FIX2 %s
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES2 %s
+
+class A { A(int i); }
+// CHECK-FIX: class A { A(int i); }{{$}}
+// CHECK-MESSAGES: Fixes have NOT been applied.
+// CHECK-FIX2: class A { explicit A(int i); };
+// CHECK-MESSAGES2: note: FIX-IT applied suggested code changes
+// CHECK-MESSAGES2: clang-tidy applied 2 of 2 suggested fixes.
OpenPOWER on IntegriCloud