summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2018-11-21 01:11:18 +0000
committerAlexander Kornienko <alexfh@google.com>2018-11-21 01:11:18 +0000
commitf4f78ff25c7c6835de39ab1ce655fff223f2fbbc (patch)
treebc4864f27b763422801cd43975136eb52196e22f
parentb2ac7eec4270bc84d0caa86375cbff5cf116408f (diff)
downloadbcm5719-llvm-f4f78ff25c7c6835de39ab1ce655fff223f2fbbc.tar.gz
bcm5719-llvm-f4f78ff25c7c6835de39ab1ce655fff223f2fbbc.zip
[clang-tidy] Add a test for proper handling of locations in scratch space.
This test examines the behavior change of clang::tooling::Diagnostic in r347372. llvm-svn: 347373
-rw-r--r--clang-tools-extra/test/clang-tidy/export-diagnostics.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/export-diagnostics.cpp b/clang-tools-extra/test/clang-tidy/export-diagnostics.cpp
new file mode 100644
index 00000000000..5eda2042ad2
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/export-diagnostics.cpp
@@ -0,0 +1,28 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t-input.cpp
+// RUN: clang-tidy %t-input.cpp -checks='-*,google-explicit-constructor,clang-diagnostic-missing-prototypes' -export-fixes=%t.yaml -- -Wmissing-prototypes > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s -implicit-check-not='{{warning|error|note}}:'
+// RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
+#define X(n) void n ## n() {}
+X(f)
+
+// CHECK-MESSAGES: -input.cpp:2:1: warning: no previous prototype for function 'ff' [clang-diagnostic-missing-prototypes]
+// CHECK-MESSAGES: -input.cpp:1:19: note: expanded from macro 'X'
+// CHECK-MESSAGES: {{^}}note: expanded from here{{$}}
+
+// CHECK-YAML: ---
+// CHECK-YAML-NEXT: MainSourceFile: '{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: Diagnostics:
+// CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-missing-prototypes
+// CHECK-YAML-NEXT: Message: 'no previous prototype for function ''ff'''
+// CHECK-YAML-NEXT: FileOffset: 30
+// CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: Notes:
+// CHECK-YAML-NEXT: - Message: 'expanded from macro ''X'''
+// CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: FileOffset: 18
+// CHECK-YAML-NEXT: - Message: expanded from here
+// CHECK-YAML-NEXT: FilePath: ''
+// CHECK-YAML-NEXT: FileOffset: 0
+// CHECK-YAML-NEXT: Replacements: []
+// CHECK-YAML-NEXT: ...
+
OpenPOWER on IntegriCloud