Skip to content

Commit 5560270

Browse files
committed
Fix pretty printer test with GCC
llvm-svn: 371884
1 parent 52a89cc commit 5560270

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

libcxx/test/pretty_printers/gdb_pretty_printer_test.sh.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <unordered_map>
2828
#include <unordered_set>
2929

30+
#include "test_macros.h"
31+
3032
// To write a pretty-printer test:
3133
//
3234
// 1. Declare a variable of the type you want to test
@@ -54,11 +56,20 @@
5456
// ComparePrettyPrintTo*. Also, make sure neither it, nor the
5557
// variables we need present in the Compare functions are optimized
5658
// away.
57-
void StopForDebugger(void *value, void *check) __attribute__((optnone)) { }
59+
#ifdef TEST_COMPILER_GCC
60+
#define OPT_NONE __attribute__((noinline))
61+
#else
62+
#define OPT_NONE __attribute__((optnone))
63+
#endif
64+
void StopForDebugger(void *value, void *check) OPT_NONE;
65+
void StopForDebugger(void *value, void *check) {}
66+
5867

5968
// Prevents the compiler optimizing away the parameter in the caller function.
6069
template <typename Type>
61-
void MarkAsLive(Type &&t) __attribute__((optnone)) { }
70+
void MarkAsLive(Type &&t) OPT_NONE;
71+
template <typename Type>
72+
void MarkAsLive(Type &&t) {}
6273

6374
// In all of the Compare(Expression)PrettyPrintTo(Regex/Chars) functions below,
6475
// the python script sets a breakpoint just before the call to StopForDebugger,
@@ -425,7 +436,7 @@ void set_iterator_test() {
425436
MarkAsLive(not_found);
426437
// Because the end_node is not easily detected, just be sure it doesn't crash.
427438
CompareExpressionPrettyPrintToRegex("not_found",
428-
R"(std::__tree_const_iterator = {\[0x[a-f0-9]+\] = .*})");
439+
R"(std::__tree_const_iterator ( = {\[0x[a-f0-9]+\] = .*}|<error reading variable:.*>))");
429440
}
430441

431442
void map_iterator_test() {

0 commit comments

Comments
 (0)