1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

[llvm] Add assertions for the smart pointers with the possibility to be null in DWARFLinker::loadClangModule

Split from D91844.

The local variable `Unit` in function `DWARFLinker::loadClangModule`
in file `llvm/lib/DWARFLinker/DWARFLinker.cpp`. If the variable is not set
in the loop below its definition, it will trigger a null pointer dereference
after the loop.

Patch By: OikawaKirie

Reviewed By: avl

Differential Revision: https://reviews.llvm.org/D97185
This commit is contained in:
Ella Ma 2021-02-26 21:42:23 +03:00 committed by Alexey Lapshin
parent ca656eb6e9
commit 1f7cac962d

View File

@ -2131,6 +2131,7 @@ Error DWARFLinker::loadClangModule(
Unit->markEverythingAsKept(); Unit->markEverythingAsKept();
} }
} }
assert(Unit && "CompileUnit is not set!");
if (!Unit->getOrigUnit().getUnitDIE().hasChildren()) if (!Unit->getOrigUnit().getUnitDIE().hasChildren())
return Error::success(); return Error::success();
if (!Quiet && Options.Verbose) { if (!Quiet && Options.Verbose) {