[llvm-bugs] [Bug 45118] New: Verifier - nullptr dereference warning
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 5 04:58:56 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=45118
Bug ID: 45118
Summary: Verifier - nullptr dereference warning
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Core LLVM classes
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: anemet at apple.com, aprantl at apple.com,
llvm-bugs at lists.llvm.org, orlando.hyams at sony.com
http://lab.llvm.org:8080/coverage/coverage-reports/llvm/coverage/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/IR/Verifier.cpp.html
Static analysis warns that the SP variable is dereferenced as null:
DILocalScope *Scope = DL->getInlinedAtScope();
if (Scope && !Seen.insert(Scope).second)
return;
DISubprogram *SP = Scope ? Scope->getSubprogram() : nullptr;
// Scope and SP could be the same MDNode and we don't want to skip
// validation in that case
if (SP && ((Scope != SP) && !Seen.insert(SP).second))
return;
AssertDI(SP->describes(&F),
"!dbg attachment points at wrong subprogram for function", N, &F,
&I, DL, Scope, SP);
AFAICT the Scope variable will always be non-null (and we should just assert
that it is), allowing us to simplify the code to something like the below (my
main concern is I'm not sure on how the verifier assertions are supposed to be
implemented):
DILocalScope *Scope = DL->getInlinedAtScope();
assert(Scope && "Unknown inlined scope"); <-- NOT FAMILIAR WITH THE
VERIFIER ASSERTION MECHANISM
if (!Seen.insert(Scope).second)
return;
DISubprogram *SP = Scope->getSubprogram();
assert(SP && "Unknown scope subprogram"); <-- NOT FAMILIAR WITH THE
VERIFIER ASSERTION MECHANISM
// Scope and SP could be the same MDNode and we don't want to skip
// validation in that case
if (((Scope != SP) && !Seen.insert(SP).second))
return;
AssertDI(SP->describes(&F),
"!dbg attachment points at wrong subprogram for function", N, &F,
&I, DL, Scope, SP);
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200305/cef26f97/attachment.html>
More information about the llvm-bugs
mailing list