Skip to content

Commit

Permalink
Add FOLLY_ASSUME_UNREACHABLE
Browse files Browse the repository at this point in the history
Summary: Add a macro that informs the compiler that a statement is unreachable, and at the same time suppresses `-Wunreachable-code` warnings that Clang throws up when.

Reviewed By: ohcnivek

Differential Revision: D62024037

fbshipit-source-id: 7c180952e6846a9881940fdb618a5388c467727c
  • Loading branch information
Gabriel Agamennoni authored and facebook-github-bot committed Sep 4, 2024
1 parent 5990e34 commit 03e2a94
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions folly/lang/Assume.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,13 @@ FOLLY_ALWAYS_INLINE void assume(bool cond) {
}

} // namespace folly

/**
* Inform the compiler that the statement is not reachable at runtime, and
* disable compiler warnings.
*/
#define FOLLY_ASSUME_UNREACHABLE() \
FOLLY_PUSH_WARNING \
FOLLY_CLANG_DISABLE_WARNING("-Wunreachable-code") \
::folly::assume_unreachable(); \
FOLLY_POP_WARNING

0 comments on commit 03e2a94

Please sign in to comment.