================
@@ -0,0 +1,1013 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -Wstack-exhausted -verify
+
+class AClass {
+public:
+  AClass() {}
+  AClass &foo() { return *this; }
+};
+
+void test_bar() {
+  AClass a;
+  // expected-warning@* {{stack nearly exhausted; compilation time may suffer, 
and crashes due to stack overflow are likely}}
+  a.foo().foo().foo().foo().foo().foo().foo().foo().foo().foo().foo().foo()
----------------
ilya-biryukov wrote:

Having a check that the compiler does not crash seems better than nothing, so 
the test in its current state seems useful.

However, @bricknerb please check it runs quickly. Another failure mode we've 
had before is that we would add slow tests and everyone running tests would 
wait on them, even when they're testing a relatively small thing.

We've had ideas about making the stack size we warn at configurable (either 
through flags or in only in C++ APIs to allow unit-testing). It might be a way 
to test this long-term, but it's probably an even bigger thing than unifying 
the warning with Sema, so I don't necessarily feel like going there unless 
people have spare time (I've wanted to do this myself, but never found the time)

https://github.com/llvm/llvm-project/pull/111701
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to