[llvm] 01b5c60 - [IR] Use switch in Instruction::mayThrow() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 12 00:59:46 PDT 2023
Author: Nikita Popov
Date: 2023-04-12T09:59:36+02:00
New Revision: 01b5c60d9ae09b666459330b62b78decdaae5d94
URL: https://github.com/llvm/llvm-project/commit/01b5c60d9ae09b666459330b62b78decdaae5d94
DIFF: https://github.com/llvm/llvm-project/commit/01b5c60d9ae09b666459330b62b78decdaae5d94.diff
LOG: [IR] Use switch in Instruction::mayThrow() (NFC)
Added:
Modified:
llvm/lib/IR/Instruction.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 0d8e637109066..ed4890eb7c994 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -734,13 +734,18 @@ bool Instruction::isVolatile() const {
}
bool Instruction::mayThrow() const {
- if (const CallInst *CI = dyn_cast<CallInst>(this))
- return !CI->doesNotThrow();
- if (const auto *CRI = dyn_cast<CleanupReturnInst>(this))
- return CRI->unwindsToCaller();
- if (const auto *CatchSwitch = dyn_cast<CatchSwitchInst>(this))
- return CatchSwitch->unwindsToCaller();
- return isa<ResumeInst>(this);
+ switch (getOpcode()) {
+ case Instruction::Call:
+ return !cast<CallInst>(this)->doesNotThrow();
+ case Instruction::CleanupRet:
+ return cast<CleanupReturnInst>(this)->unwindsToCaller();
+ case Instruction::CatchSwitch:
+ return cast<CatchSwitchInst>(this)->unwindsToCaller();
+ case Instruction::Resume:
+ return true;
+ default:
+ return false;
+ }
}
bool Instruction::mayHaveSideEffects() const {
More information about the llvm-commits
mailing list