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

Alexey Lapshin via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 27 03:32:27 PST 2021


Author: Ella Ma
Date: 2021-02-27T10:14:39+03:00
New Revision: df6fb4d392e530fbf9d4e331711c500d47980dcc

URL: https://github.com/llvm/llvm-project/commit/df6fb4d392e530fbf9d4e331711c500d47980dcc
DIFF: https://github.com/llvm/llvm-project/commit/df6fb4d392e530fbf9d4e331711c500d47980dcc.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/DWARFLinker/DWARFLinker.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 184c9c801792..4846b5c10084 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -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) {


        


More information about the llvm-commits mailing list