[libcxx-commits] [libcxx] r371884 - Fix pretty printer test with GCC

Eric Fiselier via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 13 12:04:34 PDT 2019


Author: ericwf
Date: Fri Sep 13 12:04:33 2019
New Revision: 371884

URL: http://llvm.org/viewvc/llvm-project?rev=371884&view=rev
Log:
Fix pretty printer test with GCC

Modified:
    libcxx/trunk/test/pretty_printers/gdb_pretty_printer_test.sh.cpp

Modified: libcxx/trunk/test/pretty_printers/gdb_pretty_printer_test.sh.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/pretty_printers/gdb_pretty_printer_test.sh.cpp?rev=371884&r1=371883&r2=371884&view=diff
==============================================================================
--- libcxx/trunk/test/pretty_printers/gdb_pretty_printer_test.sh.cpp (original)
+++ libcxx/trunk/test/pretty_printers/gdb_pretty_printer_test.sh.cpp Fri Sep 13 12:04:33 2019
@@ -27,6 +27,8 @@
 #include <unordered_map>
 #include <unordered_set>
 
+#include "test_macros.h"
+
 // To write a pretty-printer test:
 //
 // 1. Declare a variable of the type you want to test
@@ -54,11 +56,20 @@
 // ComparePrettyPrintTo*.  Also, make sure neither it, nor the
 // variables we need present in the Compare functions are optimized
 // away.
-void StopForDebugger(void *value, void *check) __attribute__((optnone)) { }
+#ifdef TEST_COMPILER_GCC
+#define OPT_NONE __attribute__((noinline))
+#else
+#define OPT_NONE __attribute__((optnone))
+#endif
+void StopForDebugger(void *value, void *check) OPT_NONE;
+void StopForDebugger(void *value, void *check)  {}
+
 
 // Prevents the compiler optimizing away the parameter in the caller function.
 template <typename Type>
-void MarkAsLive(Type &&t) __attribute__((optnone)) { }
+void MarkAsLive(Type &&t) OPT_NONE;
+template <typename Type>
+void MarkAsLive(Type &&t) {}
 
 // In all of the Compare(Expression)PrettyPrintTo(Regex/Chars) functions below,
 // the python script sets a breakpoint just before the call to StopForDebugger,
@@ -425,7 +436,7 @@ void set_iterator_test() {
   MarkAsLive(not_found);
   // Because the end_node is not easily detected, just be sure it doesn't crash.
   CompareExpressionPrettyPrintToRegex("not_found",
-      R"(std::__tree_const_iterator  = {\[0x[a-f0-9]+\] = .*})");
+      R"(std::__tree_const_iterator ( = {\[0x[a-f0-9]+\] = .*}|<error reading variable:.*>))");
 }
 
 void map_iterator_test() {




More information about the libcxx-commits mailing list