-
Notifications
You must be signed in to change notification settings - Fork 24
Vendor demangle.hpp header from Boost
#1816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f237129
Vendor demangle.hpp header from Boost
msimberg f6ce48c
Clean up ifdefs in demangle.hpp
msimberg e4c8fed
Format demangle.hpp
msimberg 430f71d
Move demangle helper to gridtools::common namespace
msimberg d2e2099
Merge branch 'master' into boost-demangle-vendor
havogt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // Vendored and slightly simplified version of boost::core::demangle | ||
| // | ||
| // Copyright 2014 Peter Dimov | ||
| // Copyright 2014 Andrey Semashev | ||
| // | ||
| // Distributed under the Boost Software License, Version 1.0. | ||
| // See accompanying file LICENSE_1_0.txt or copy at | ||
| // http://www.boost.org/LICENSE_1_0.txt | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
|
|
||
| #if __has_include(<cxxabi.h>) | ||
| #define GT_HAS_CXXABI_H | ||
| #endif | ||
|
|
||
| #if defined(GT_HAS_CXXABI_H) | ||
| #include <cxxabi.h> | ||
| #endif | ||
|
|
||
| namespace gridtools { | ||
|
|
||
| namespace common { | ||
|
|
||
| inline char const *demangle_alloc(char const *name) noexcept; | ||
| inline void demangle_free(char const *name) noexcept; | ||
|
|
||
| class scoped_demangled_name { | ||
| private: | ||
| char const *m_p; | ||
|
|
||
| public: | ||
| explicit scoped_demangled_name(char const *name) noexcept : m_p(demangle_alloc(name)) {} | ||
|
|
||
| ~scoped_demangled_name() noexcept { demangle_free(m_p); } | ||
|
|
||
| char const *get() const noexcept { return m_p; } | ||
|
|
||
| scoped_demangled_name(scoped_demangled_name const &) = delete; | ||
| scoped_demangled_name &operator=(scoped_demangled_name const &) = delete; | ||
| }; | ||
|
|
||
| #if defined(GT_HAS_CXXABI_H) | ||
|
|
||
| inline char const *demangle_alloc(char const *name) noexcept { | ||
| int status = 0; | ||
| std::size_t size = 0; | ||
| return abi::__cxa_demangle(name, NULL, &size, &status); | ||
| } | ||
|
|
||
| inline void demangle_free(char const *name) noexcept { std::free(const_cast<char *>(name)); } | ||
|
|
||
| inline std::string demangle(char const *name) { | ||
| scoped_demangled_name demangled_name(name); | ||
| char const *p = demangled_name.get(); | ||
| if (!p) | ||
| p = name; | ||
| return p; | ||
| } | ||
|
|
||
| #else | ||
|
|
||
| inline char const *demangle_alloc(char const *name) noexcept { return name; } | ||
|
|
||
| inline void demangle_free(char const *) noexcept {} | ||
|
|
||
| inline std::string demangle(char const *name) { return name; } | ||
|
|
||
| #endif | ||
|
|
||
| } // namespace common | ||
|
|
||
| } // namespace gridtools | ||
|
|
||
| #undef GT_HAS_CXXABI_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.