[llvm] Add assertions for the smart pointers with the possibility to be null in DWARF...
authorElla Ma <alansnape3058@gmail.com>
Fri, 26 Feb 2021 18:42:23 +0000 (21:42 +0300)
committerAlexey Lapshin <a.v.lapshin@mail.ru>
Sat, 27 Feb 2021 07:14:39 +0000 (10:14 +0300)
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

llvm/lib/DWARFLinker/DWARFLinker.cpp

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