[compiler-rt] r303392 - [compiler-rt] Replace ifs with switch statement in IsHandledDeadlySignal
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 16:13:23 PDT 2017
Author: vitalybuka
Date: Thu May 18 18:13:22 2017
New Revision: 303392
URL: http://llvm.org/viewvc/llvm-project?rev=303392&view=rev
Log:
[compiler-rt] Replace ifs with switch statement in IsHandledDeadlySignal
Reviewers: eugenis
Subscribers: kubamracek, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D33158
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=303392&r1=303391&r2=303392&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Thu May 18 18:13:22 2017
@@ -1395,15 +1395,19 @@ AndroidApiLevel AndroidGetApiLevel() {
#endif
bool IsHandledDeadlySignal(int signum) {
- if (common_flags()->handle_abort && signum == SIGABRT)
- return true;
- if (common_flags()->handle_sigill && signum == SIGILL)
- return true;
- if (common_flags()->handle_sigfpe && signum == SIGFPE)
- return true;
- if (common_flags()->handle_segv && signum == SIGSEGV)
- return true;
- return common_flags()->handle_sigbus && signum == SIGBUS;
+ switch (signum) {
+ case SIGABRT:
+ return common_flags()->handle_abort;
+ case SIGILL:
+ return common_flags()->handle_sigill;
+ case SIGFPE:
+ return common_flags()->handle_sigfpe;
+ case SIGSEGV:
+ return common_flags()->handle_segv;
+ case SIGBUS:
+ return common_flags()->handle_sigbus;
+ }
+ return false;
}
#if !SANITIZER_GO
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=303392&r1=303391&r2=303392&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Thu May 18 18:13:22 2017
@@ -394,18 +394,22 @@ void ListOfModules::init() {
}
bool IsHandledDeadlySignal(int signum) {
+ // Handling fatal signals on watchOS and tvOS devices is disallowed.
if ((SANITIZER_WATCHOS || SANITIZER_TVOS) && !(SANITIZER_IOSSIM))
- // Handling fatal signals on watchOS and tvOS devices is disallowed.
return false;
- if (common_flags()->handle_abort && signum == SIGABRT)
- return true;
- if (common_flags()->handle_sigill && signum == SIGILL)
- return true;
- if (common_flags()->handle_sigfpe && signum == SIGFPE)
- return true;
- if (common_flags()->handle_segv && signum == SIGSEGV)
- return true;
- return common_flags()->handle_sigbus && signum == SIGBUS;
+ switch (signum) {
+ case SIGABRT:
+ return common_flags()->handle_abort;
+ case SIGILL:
+ return common_flags()->handle_sigill;
+ case SIGFPE:
+ return common_flags()->handle_sigfpe;
+ case SIGSEGV:
+ return common_flags()->handle_segv;
+ case SIGBUS:
+ return common_flags()->handle_sigbus;
+ }
+ return false;
}
MacosVersion cached_macos_version = MACOS_VERSION_UNINITIALIZED;
More information about the llvm-commits
mailing list