Skip to content

Commit

Permalink
Merge pull request #274 from amerry/appleclang-warning-fix
Browse files Browse the repository at this point in the history
Properly guard the usage of [[likely]] (especially for AppleClang 12)
  • Loading branch information
BurningEnlightenment authored Jan 26, 2023
2 parents 9331fb0 + a506b9e commit 093f364
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions include/outcome/try.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,13 @@ OUTCOME_V2_NAMESPACE_END
#define _OUTCOME_TRY_CALL_OVERLOAD(name, ...) \
_OUTCOME_TRY_OVERLOAD_GLUE(_OUTCOME_TRY_OVERLOAD_MACRO(name, _OUTCOME_TRY_COUNT_ARGS_MAX8(__VA_ARGS__)), (__VA_ARGS__))

#ifndef OUTCOME_TRY_LIKELY_IF
#if(__cplusplus >= 202000L || _HAS_CXX20) && (!defined(__clang__) || __clang_major__ >= 12) && (!defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9)
#if !defined(OUTCOME_TRY_LIKELY_IF) && defined(__has_cpp_attribute)
#if __has_cpp_attribute(likely)
#define OUTCOME_TRY_LIKELY_IF(...) if(__VA_ARGS__) [[likely]]
#elif defined(__clang__) || defined(__GNUC__)
#endif
#endif
#ifndef OUTCOME_TRY_LIKELY_IF
#if defined(__clang__) || defined(__GNUC__)
#define OUTCOME_TRY_LIKELY_IF(...) if(__builtin_expect(!!(__VA_ARGS__), true))
#else
#define OUTCOME_TRY_LIKELY_IF(...) if(__VA_ARGS__)
Expand Down

0 comments on commit 093f364

Please sign in to comment.