[llvm] 34b8a0d - [Verifier] Silence static analyzer null dereference warning (PR45118)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 17 09:10:00 PDT 2020
Author: Simon Pilgrim
Date: 2020-03-17T16:01:23Z
New Revision: 34b8a0d5998ce9131d50e79b54ddd3e6d7d212fa
URL: https://github.com/llvm/llvm-project/commit/34b8a0d5998ce9131d50e79b54ddd3e6d7d212fa
DIFF: https://github.com/llvm/llvm-project/commit/34b8a0d5998ce9131d50e79b54ddd3e6d7d212fa.diff
LOG: [Verifier] Silence static analyzer null dereference warning (PR45118)
As discussed on PR45118, getInlinedAtScope() shouldn't ever return null. So we can simplify the logic to an assertion and remove all other null tests.
Added:
Modified:
llvm/lib/IR/Verifier.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 37dc3a8fbd9b..68c920d4e54f 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2385,11 +2385,14 @@ void Verifier::visitFunction(const Function &F) {
AssertDI(Parent && isa<DILocalScope>(Parent),
"DILocation's scope must be a DILocalScope", N, &F, &I, DL,
Parent);
+
DILocalScope *Scope = DL->getInlinedAtScope();
- if (Scope && !Seen.insert(Scope).second)
+ Assert(Scope, "Failed to find DILocalScope", DL);
+
+ if (!Seen.insert(Scope).second)
return;
- DISubprogram *SP = Scope ? Scope->getSubprogram() : nullptr;
+ DISubprogram *SP = Scope->getSubprogram();
// Scope and SP could be the same MDNode and we don't want to skip
// validation in that case
More information about the llvm-commits
mailing list