-
-
Notifications
You must be signed in to change notification settings - Fork 134
adds experimental support for C++20 modules #248
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
13 commits
Select commit
Hold shift + click to select a range
967964c
adds experimental support for C++20 modules
cjdb ded6ca9
Try to fix integration test
jeremy-rifkin 1a0454c
Try to fix CI
jeremy-rifkin c73cceb
Detect module support with compiler versions
jeremy-rifkin 6c27579
Remove register_jit_objects_from_gdb_jit_interface from the module in…
jeremy-rifkin d3d6bdc
Misc
jeremy-rifkin 25a75dc
Remove gdb_jit include
jeremy-rifkin 2375e9f
Fix for bazel
jeremy-rifkin af8b2db
Fix for bazel
jeremy-rifkin 190a07e
Fix install rules
jeremy-rifkin a6f5018
Set a destination for the modules file set
jeremy-rifkin 0a8c500
Update modules install destination
jeremy-rifkin ec9f31c
Cleanup and rename module to .cppm
jeremy-rifkin 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
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
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
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
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
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,21 @@ | ||
#ifndef CPPTRACE_EXCEPTIONS_MACROS_HPP | ||
#define CPPTRACE_EXCEPTIONS_MACROS_HPP | ||
|
||
// Exception wrapper utilities | ||
#define CPPTRACE_WRAP_BLOCK(statements) do { \ | ||
try { \ | ||
statements \ | ||
} catch(...) { \ | ||
::cpptrace::rethrow_and_wrap_if_needed(); \ | ||
} \ | ||
} while(0) | ||
|
||
#define CPPTRACE_WRAP(expression) [&] () -> decltype((expression)) { \ | ||
try { \ | ||
return expression; \ | ||
} catch(...) { \ | ||
::cpptrace::rethrow_and_wrap_if_needed(1); \ | ||
} \ | ||
} () | ||
|
||
#endif // CPPTRACE_EXCEPTIONS_MACROS_HPP |
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
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,54 @@ | ||
#ifndef CPPTRACE_FROM_CURRENT_MACROS_HPP | ||
#define CPPTRACE_FROM_CURRENT_MACROS_HPP | ||
|
||
// https://godbolt.org/z/4MsT6KqP1 | ||
#ifdef _MSC_VER | ||
#define CPPTRACE_UNREACHABLE() __assume(false) | ||
#else | ||
#define CPPTRACE_UNREACHABLE() __builtin_unreachable() | ||
#endif | ||
|
||
// https://godbolt.org/z/7neGPEche | ||
// gcc added support in 4.8 but I'm too lazy to check the minor version | ||
#if defined(__GNUC__) && (__GNUC__ < 5) | ||
#define CPPTRACE_NORETURN __attribute__((noreturn)) | ||
#else | ||
#define CPPTRACE_NORETURN [[noreturn]] | ||
#endif | ||
|
||
#ifdef _MSC_VER | ||
#define CPPTRACE_TYPE_FOR(param) \ | ||
::cpptrace::detail::argument<void(param)>::type | ||
// this awful double-IILE is due to C2713 "You can't use structured exception handling (__try/__except) and C++ | ||
// exception handling (try/catch) in the same function." | ||
#define CPPTRACE_TRY \ | ||
try { \ | ||
[&]() { \ | ||
__try { \ | ||
[&]() { | ||
#define CPPTRACE_CATCH(param) \ | ||
}(); \ | ||
} __except(::cpptrace::detail::exception_filter<CPPTRACE_TYPE_FOR(param)>(GetExceptionInformation())) {} \ | ||
}(); \ | ||
} catch(param) | ||
#else | ||
#define CPPTRACE_UNWIND_INTERCEPTOR_FOR(param) \ | ||
::cpptrace::detail::unwind_interceptor_for<void(param)> | ||
#define CPPTRACE_TRY \ | ||
try { \ | ||
try { | ||
#define CPPTRACE_CATCH(param) \ | ||
} catch(const CPPTRACE_UNWIND_INTERCEPTOR_FOR(param)&) { \ | ||
CPPTRACE_UNREACHABLE(); \ | ||
/* force instantiation of the init-er */ \ | ||
::cpptrace::detail::nop(CPPTRACE_UNWIND_INTERCEPTOR_FOR(param)::init); \ | ||
} \ | ||
} catch(param) | ||
#endif | ||
|
||
#ifdef CPPTRACE_UNPREFIXED_TRY_CATCH | ||
#define TRY CPPTRACE_TRY | ||
#define CATCH(param) CPPTRACE_CATCH(param) | ||
#endif | ||
|
||
#endif // CPPTRACE_FROM_CURRENT_MACROS_HPP |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, is there a sensible way to make either of the following work instead of a new macros header?
If a macros header is the best way to do this I think it's good with me - and I'm guessing if so other libraries might follow the same pattern. But I'd love to be able to keep
#include <cpptrace/from_current.hpp>
under modules if possible as that is currently in a sense part of the library interface.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do the former, but not the latter (yet). Having said that, including
cpptrace/from_current.hpp
will undo some or all of the hard work that modules is accomplishing. I'm not aware of a better way to import macros from a module library than to doOnce support for modules stabilises, I'd recommend the docs encourage header users not include the
_macros.hpp
headers, and instead just stick with the original headers (which export the macros).