summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Frontend/backend-diagnostic.c9
-rw-r--r--clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp18
-rw-r--r--clang/test/Misc/backend-stack-frame-diagnostics.cpp51
3 files changed, 72 insertions, 6 deletions
diff --git a/clang/test/Frontend/backend-diagnostic.c b/clang/test/Frontend/backend-diagnostic.c
index 8b61c0350ec..d6fe48bc9c5 100644
--- a/clang/test/Frontend/backend-diagnostic.c
+++ b/clang/test/Frontend/backend-diagnostic.c
@@ -11,16 +11,13 @@
// RUN: not %clang_cc1 %s -mllvm -warn-stack-size=0 -no-integrated-as -S -o - -triple=i386-apple-darwin -Wno-frame-larger-than 2> %t.err
// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --check-prefix=ASM
//
-// Currently the stack size reporting cannot be checked with -verify because
-// no source location is attached to the diagnostic. Therefore do not emit
-// them for the -verify test for now.
// RUN: %clang_cc1 %s -S -o - -triple=i386-apple-darwin -verify -no-integrated-as
extern void doIt(char *);
-// REGULAR: warning: stack size exceeded ({{[0-9]+}}) in stackSizeWarning
-// PROMOTE: error: stack size exceeded ({{[0-9]+}}) in stackSizeWarning
-// IGNORE-NOT: stack size exceeded ({{[0-9]+}}) in stackSizeWarning
+// REGULAR: warning: stack frame size of {{[0-9]+}} bytes in function 'stackSizeWarning'
+// PROMOTE: error: stack frame size of {{[0-9]+}} bytes in function 'stackSizeWarning'
+// IGNORE-NOT: stack frame size of {{[0-9]+}} bytes in function 'stackSizeWarning'
void stackSizeWarning() {
char buffer[80];
doIt(buffer);
diff --git a/clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp b/clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp
new file mode 100644
index 00000000000..8ae8c55396d
--- /dev/null
+++ b/clang/test/Misc/backend-stack-frame-diagnostics-fallback.cpp
@@ -0,0 +1,18 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -mllvm -warn-stack-size=0 -emit-codegen-only -triple=i386-apple-darwin 2>&1 | FileCheck %s
+
+// TODO: Emit rich diagnostics for thunks and move this into the appropriate test file.
+// Until then, test that we fall back and display the LLVM backend diagnostic.
+namespace frameSizeThunkWarning {
+ struct A {
+ virtual void f();
+ };
+
+ struct B : virtual A {
+ virtual void f();
+ };
+
+ // CHECK: warning: stack frame size of {{[0-9]+}} bytes in function 'frameSizeThunkWarning::B::f'
+ // CHECK: warning: stack size limit exceeded ({{[0-9]+}}) in {{[^ ]+}}
+ void B::f() { }
+}
diff --git a/clang/test/Misc/backend-stack-frame-diagnostics.cpp b/clang/test/Misc/backend-stack-frame-diagnostics.cpp
new file mode 100644
index 00000000000..19303594b2b
--- /dev/null
+++ b/clang/test/Misc/backend-stack-frame-diagnostics.cpp
@@ -0,0 +1,51 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks -Wframe-larger-than=70 -Xclang -verify -o /dev/null -c %s
+
+// Test that:
+// * The driver passes the option through to the backend.
+// * The frontend diagnostic handler 'demangles' and resolves the correct function definition.
+
+// TODO: Support rich backend diagnostics for Objective-C methods.
+
+extern void doIt(char *);
+
+void frameSizeWarning(int, int) {}
+
+void frameSizeWarning();
+
+void frameSizeWarning() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in function 'frameSizeWarning'}}
+ char buffer[80];
+ doIt(buffer);
+}
+
+void frameSizeWarning();
+
+void frameSizeWarning(int) {}
+
+void frameSizeLocalClassWarning() {
+ struct S {
+ S() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in function 'frameSizeLocalClassWarning()::S::S'}}
+ char buffer[80];
+ doIt(buffer);
+ }
+ };
+ S();
+}
+
+void frameSizeLambdaWarning() {
+ auto fn =
+ []() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in lambda expression}}
+ char buffer[80];
+ doIt(buffer);
+ };
+ fn();
+}
+
+void frameSizeBlocksWarning() {
+ auto fn =
+ ^() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in block literal}}
+ char buffer[80];
+ doIt(buffer);
+ };
+ fn();
+}
OpenPOWER on IntegriCloud