[clang] [NFC][clang][test][asan] Make `instantiation-depth-default.cpp` a valid test case under `asan` and `ubsan` configs (PR #75254)

Duo Wang via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 09:46:48 PST 2024


https://github.com/wdunicornpro updated https://github.com/llvm/llvm-project/pull/75254

>From 410aaea22e1824c7f8ba27a8f538d0c039a5ab62 Mon Sep 17 00:00:00 2001
From: Duo Wang <Duo.Wang at sony.com>
Date: Fri, 8 Dec 2023 15:38:08 -0800
Subject: [PATCH 1/2] add `-Wno-stack-exhausted` flag to support asan and ubsan

---
 .../SemaTemplate/instantiation-depth-default.cpp | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/clang/test/SemaTemplate/instantiation-depth-default.cpp b/clang/test/SemaTemplate/instantiation-depth-default.cpp
index f5835b86b3a385..362cf2b34aef51 100644
--- a/clang/test/SemaTemplate/instantiation-depth-default.cpp
+++ b/clang/test/SemaTemplate/instantiation-depth-default.cpp
@@ -1,18 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-backtrace-limit=2 %s
-//
-// FIXME: Disable this test when Clang was built with ASan, because ASan
-// increases our per-frame stack usage enough that this test no longer fits
-// within our normal stack space allocation.
-// UNSUPPORTED: asan
-//
+// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-backtrace-limit=2 -Wno-stack-exhausted %s
 // The default stack size on NetBSD is too small for this test.
 // UNSUPPORTED: system-netbsd
 
 template<int N, typename T> struct X : X<N+1, T*> {};
-// expected-error-re at 11 {{recursive template instantiation exceeded maximum depth of 1024{{$}}}}
-// expected-note at 11 {{instantiation of template class}}
-// expected-note at 11 {{skipping 1023 contexts in backtrace}}
-// expected-note at 11 {{use -ftemplate-depth=N to increase recursive template instantiation depth}}
+// expected-error-re at 5 {{recursive template instantiation exceeded maximum depth of 1024{{$}}}}
+// expected-note at 5 {{instantiation of template class}}
+// expected-note at 5 {{skipping 1023 contexts in backtrace}}
+// expected-note at 5 {{use -ftemplate-depth=N to increase recursive template instantiation depth}}
 
 X<0, int> x; // expected-note {{in instantiation of}}
 

>From 277939cd269d0d16fcf2f62debc7df0c2f1504f5 Mon Sep 17 00:00:00 2001
From: Duo Wang <Duo.Wang at sony.com>
Date: Thu, 4 Jan 2024 09:46:34 -0800
Subject: [PATCH 2/2] -Wno-stack-exhausted under asan and ubsan only

---
 clang/test/SemaTemplate/instantiation-depth-default.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/SemaTemplate/instantiation-depth-default.cpp b/clang/test/SemaTemplate/instantiation-depth-default.cpp
index 362cf2b34aef51..430d042d7e0f49 100644
--- a/clang/test/SemaTemplate/instantiation-depth-default.cpp
+++ b/clang/test/SemaTemplate/instantiation-depth-default.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-backtrace-limit=2 -Wno-stack-exhausted %s
+// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-backtrace-limit=2 %if {{asan|ubsan}} %{ -Wno-stack-exhausted %} %s
 // The default stack size on NetBSD is too small for this test.
 // UNSUPPORTED: system-netbsd
 



More information about the cfe-commits mailing list