[llvm] r373099 - ModuleUtils - silence static analyzer dyn_cast<> null dereference warning. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 09:55:49 PDT 2019


Author: rksimon
Date: Fri Sep 27 09:55:49 2019
New Revision: 373099

URL: http://llvm.org/viewvc/llvm-project?rev=373099&view=rev
Log:
ModuleUtils - silence static analyzer dyn_cast<> null dereference warning. NFCI.

The static analyzer is warning about a potential null dereference, but we should be able to use cast<> directly and if not assert will fire for us.

Modified:
    llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp

Modified: llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp?rev=373099&r1=373098&r2=373099&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp Fri Sep 27 09:55:49 2019
@@ -73,7 +73,7 @@ static void appendToUsedList(Module &M,
   SmallPtrSet<Constant *, 16> InitAsSet;
   SmallVector<Constant *, 16> Init;
   if (GV) {
-    ConstantArray *CA = dyn_cast<ConstantArray>(GV->getInitializer());
+    auto *CA = cast<ConstantArray>(GV->getInitializer());
     for (auto &Op : CA->operands()) {
       Constant *C = cast_or_null<Constant>(Op);
       if (InitAsSet.insert(C).second)




More information about the llvm-commits mailing list