Recommit: Handle diagnostic warnings in Frontend diagnostic handler.
Clang uses a diagnostic handler to grab diagnostic messages so it can print them
with the line of source code they refer to. This patch extends this to handle
optimization failures that were added to llvm to produce a warning when
loop vectorization is explicitly specified (using a pragma clang loop directive)
but fails.
Update renames warning flag name to avoid indicating the flag's severity and
adds a test.
Reviewed by Alp Toker
llvm-svn: 213400
diff --git a/clang/test/Misc/backend-optimization-failure.cpp b/clang/test/Misc/backend-optimization-failure.cpp
new file mode 100644
index 0000000..79b7a3a
--- /dev/null
+++ b/clang/test/Misc/backend-optimization-failure.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -O3 -emit-llvm -gline-tables-only -S -verify -o /dev/null
+
+// Test verifies optimization failures generated by the backend are handled
+// correctly by clang. LLVM tests verify all of the failure conditions.
+
+void test_switch(int *A, int *B, int Length) {
+#pragma clang loop vectorize(enable) unroll(disable)
+ for (int i = 0; i < Length; i++) {
+ /* expected-warning {{loop not vectorized: failed explicitly specified loop vectorization}} */ switch (A[i]) {
+ case 0:
+ B[i] = 1;
+ break;
+ case 1:
+ B[i] = 2;
+ break;
+ default:
+ B[i] = 3;
+ }
+ }
+}