[llvm] Instruction: avoid crash in getStableDebugLoc when `this` isn't a DbgInfoIntrinsic (PR #66266)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 14:04:12 PDT 2023
================
@@ -886,8 +886,11 @@ Instruction::getPrevNonDebugInstruction(bool SkipPseudoOp) const {
}
const DebugLoc &Instruction::getStableDebugLoc() const {
- if (isa<DbgInfoIntrinsic>(this))
- return getNextNonDebugInstruction()->getDebugLoc();
+ if (isa<DbgInfoIntrinsic>(this)) {
+ const Instruction* next = getNextNonDebugInstruction();
----------------
MaskRay wrote:
LLVM coding standard prefers `Instruction *next`. With C++17, prefer:
```
if (const Instruction *Next = getNextNonDebugInstruction())
return Next->getDebugLoc();
```
https://github.com/llvm/llvm-project/pull/66266
More information about the llvm-commits
mailing list