]> granicus.if.org Git - llvm/commitdiff
MemorySanitizer - silence static analyzer dyn_cast<> null dereference warnings. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 26 Sep 2019 10:56:14 +0000 (10:56 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 26 Sep 2019 10:56:14 +0000 (10:56 +0000)
The static analyzer is warning about a potential null dereferences, but we should be able to use cast<> directly and if not assert will fire for us.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372960 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/MemorySanitizer.cpp

index dd7b4fcbd0fba91947efa08e5509b96f00183f9b..81bd2f3c18ac965b56a9c3c9eb4bce37c71bc76d 100644 (file)
@@ -3627,10 +3627,10 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
   int getNumOutputArgs(InlineAsm *IA, CallBase *CB) {
     int NumRetOutputs = 0;
     int NumOutputs = 0;
-    Type *RetTy = dyn_cast<Value>(CB)->getType();
+    Type *RetTy = cast<Value>(CB)->getType();
     if (!RetTy->isVoidTy()) {
       // Register outputs are returned via the CallInst return value.
-      StructType *ST = dyn_cast_or_null<StructType>(RetTy);
+      auto *ST = dyn_cast<StructType>(RetTy);
       if (ST)
         NumRetOutputs = ST->getNumElements();
       else
@@ -3667,7 +3667,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
     // corresponding CallInst has nO+nI+1 operands (the last operand is the
     // function to be called).
     const DataLayout &DL = F.getParent()->getDataLayout();
-    CallBase *CB = dyn_cast<CallBase>(&I);
+    CallBase *CB = cast<CallBase>(&I);
     IRBuilder<> IRB(&I);
     InlineAsm *IA = cast<InlineAsm>(CB->getCalledValue());
     int OutputArgs = getNumOutputArgs(IA, CB);