2 //===----------------------------------------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
10 #ifndef SUPPORT_DEMANGLE_H
11 #define SUPPORT_DEMANGLE_H
13 #include "test_macros.h"
17 #if !defined(TEST_HAS_NO_DEMANGLE)
18 # if defined(__GNUC__) || defined(__clang__)
19 # if __has_include("cxxabi.h")
22 # define TEST_HAS_NO_DEMANGLE
25 # define TEST_HAS_NO_DEMANGLE
29 #if defined(TEST_HAS_NO_DEMANGLE)
30 inline std::string demangle(const char* mangled_name) {
34 template <size_t N> struct Printer;
35 inline std::string demangle(const char* mangled_name) {
37 std::string input(mangled_name);
38 input.insert(0, "_Z");
39 char* out = __cxxabiv1::__cxa_demangle(input.c_str(), nullptr, nullptr, &status);
49 #endif // SUPPORT_DEMANGLE_H