@@ -21,22 +21,11 @@ import cpptrace;
2121#endif
2222
2323
24- #if defined(_MSC_VER) && !defined(__clang__)
25- #define NOINLINE_LAMBDA [[msvc::noinline]]
26- #else
27- #define NOINLINE_LAMBDA __attribute__ ((noinline))
28- #endif
29-
30- static volatile int truthy = 2 ;
31-
3224namespace {
3325 template <typename E, typename ... Args>
3426 CPPTRACE_FORCE_NO_INLINE
35- int do_throw (Args&&... args) {
36- if (truthy) {
37- throw E (std::forward<Args>(args)...);
38- }
39- return 2 ;
27+ void do_throw (Args&&... args) {
28+ throw E (std::forward<Args>(args)...);
4029 }
4130
4231 void check_trace (const cpptrace::stacktrace& trace, std::string file, int line) {
@@ -83,15 +72,16 @@ TEST(TryCatch, Basic) {
8372 int line = 0 ;
8473 bool did_catch = false ;
8574 cpptrace::try_catch (
86- [&] () NOINLINE_LAMBDA {
75+ [&] {
8776 line = __LINE__ + 1 ;
88- volatile int x = do_throw<std::runtime_error>(" foobar" );
89- (void )x;
77+ do_throw<std::runtime_error>(" foobar" );
9078 },
9179 [&] (const std::runtime_error& e) {
9280 did_catch = true ;
9381 EXPECT_EQ (e.what (), std::string (" foobar" ));
94- check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
82+ #if !defined(_WIN32) || (!defined(_M_ARM64) && !defined(_M_ARM))
83+ check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
84+ #endif
9585 check_trace (cpptrace::from_current_exception (), test_name);
9686 }
9787 );
@@ -116,15 +106,16 @@ TEST(TryCatch, Upcast) {
116106 int line = 0 ;
117107 bool did_catch = false ;
118108 cpptrace::try_catch (
119- [&] () NOINLINE_LAMBDA {
109+ [&] {
120110 line = __LINE__ + 1 ;
121- volatile int x = do_throw<std::runtime_error>(" foobar" );
122- (void )x;
111+ do_throw<std::runtime_error>(" foobar" );
123112 },
124113 [&] (const std::exception& e) {
125114 did_catch = true ;
126115 EXPECT_EQ (e.what (), std::string (" foobar" ));
127- check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
116+ #if !defined(_WIN32) || (!defined(_M_ARM64) && !defined(_M_ARM))
117+ check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
118+ #endif
128119 check_trace (cpptrace::from_current_exception (), test_name);
129120 }
130121 );
@@ -136,10 +127,9 @@ TEST(TryCatch, NoHandler) {
136127 bool did_catch = false ;
137128 try {
138129 cpptrace::try_catch (
139- [&] () NOINLINE_LAMBDA {
130+ [&] {
140131 line = __LINE__ + 1 ;
141- volatile int x = do_throw<std::exception>();
142- (void )x;
132+ do_throw<std::exception>();
143133 },
144134 [&] (const std::runtime_error&) {
145135 FAIL ();
@@ -157,10 +147,9 @@ TEST(TryCatch, NoMatchingHandler) {
157147 bool did_catch = false ;
158148 try {
159149 cpptrace::try_catch (
160- [&] () NOINLINE_LAMBDA {
150+ [&] {
161151 line = __LINE__ + 1 ;
162- volatile int x = do_throw<std::exception>();
163- (void )x;
152+ do_throw<std::exception>();
164153 }
165154 );
166155 FAIL ();
@@ -175,10 +164,9 @@ TEST(TryCatch, CorrectHandler) {
175164 int line = 0 ;
176165 bool did_catch = false ;
177166 cpptrace::try_catch (
178- [&] () NOINLINE_LAMBDA {
167+ [&] {
179168 line = __LINE__ + 1 ;
180- volatile int x = do_throw<std::runtime_error>(" foobar" );
181- (void )x;
169+ do_throw<std::runtime_error>(" foobar" );
182170 },
183171 [&] (int ) {
184172 FAIL ();
@@ -189,7 +177,9 @@ TEST(TryCatch, CorrectHandler) {
189177 [&] (const std::runtime_error& e) {
190178 did_catch = true ;
191179 EXPECT_EQ (e.what (), std::string (" foobar" ));
192- check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
180+ #if !defined(_WIN32) || (!defined(_M_ARM64) && !defined(_M_ARM))
181+ check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
182+ #endif
193183 check_trace (cpptrace::from_current_exception (), test_name);
194184 },
195185 [&] (const std::exception&) {
@@ -204,10 +194,9 @@ TEST(TryCatch, BlanketHandler) {
204194 int line = 0 ;
205195 bool did_catch = false ;
206196 cpptrace::try_catch (
207- [&] () NOINLINE_LAMBDA {
197+ [&] {
208198 line = __LINE__ + 1 ;
209- volatile int x = do_throw<std::exception>();
210- (void )x;
199+ do_throw<std::exception>();
211200 },
212201 [&] (int ) {
213202 FAIL ();
@@ -220,7 +209,9 @@ TEST(TryCatch, BlanketHandler) {
220209 },
221210 [&] () {
222211 did_catch = true ;
223- check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
212+ #if !defined(_WIN32) || (!defined(_M_ARM64) && !defined(_M_ARM))
213+ check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
214+ #endif
224215 check_trace (cpptrace::from_current_exception (), test_name);
225216 }
226217 );
@@ -232,10 +223,9 @@ TEST(TryCatch, CatchOrdering) {
232223 int line = 0 ;
233224 bool did_catch = false ;
234225 cpptrace::try_catch (
235- [&] () NOINLINE_LAMBDA {
226+ [&] {
236227 line = __LINE__ + 1 ;
237- volatile int x = do_throw<std::runtime_error>(" foobar" );
238- (void )x;
228+ do_throw<std::runtime_error>(" foobar" );
239229 },
240230 [&] (int ) {
241231 FAIL ();
@@ -245,7 +235,9 @@ TEST(TryCatch, CatchOrdering) {
245235 },
246236 [&] () {
247237 did_catch = true ;
248- check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
238+ #if !defined(_WIN32) || (!defined(_M_ARM64) && !defined(_M_ARM))
239+ check_trace (cpptrace::from_current_exception (), " try_catch.cpp" , line);
240+ #endif
249241 check_trace (cpptrace::from_current_exception (), test_name);
250242 },
251243 [&] (const std::runtime_error&) {
@@ -288,8 +280,7 @@ TEST(TryCatch, Value) {
288280 copy_move_tracker::reset ();
289281 cpptrace::try_catch (
290282 [&] {
291- volatile int x = do_throw<copy_move_tracker>();
292- (void )x;
283+ do_throw<copy_move_tracker>();
293284 },
294285 [&] (copy_move_tracker) {
295286 did_catch = true ;
@@ -305,8 +296,7 @@ TEST(TryCatch, Ref) {
305296 copy_move_tracker::reset ();
306297 cpptrace::try_catch (
307298 [&] {
308- volatile int x = do_throw<copy_move_tracker>();
309- (void )x;
299+ do_throw<copy_move_tracker>();
310300 },
311301 [&] (copy_move_tracker&) {
312302 did_catch = true ;
@@ -322,8 +312,7 @@ TEST(TryCatch, ConstRef) {
322312 copy_move_tracker::reset ();
323313 cpptrace::try_catch (
324314 [&] {
325- volatile int x = do_throw<copy_move_tracker>();
326- (void )x;
315+ do_throw<copy_move_tracker>();
327316 },
328317 [&] (const copy_move_tracker&) {
329318 did_catch = true ;
0 commit comments