]> granicus.if.org Git - llvm/commitdiff
[IR] IntrinsicInst - silence static analyzer dyn_cast<> null dereference warnings...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 24 Sep 2019 11:40:45 +0000 (11:40 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 24 Sep 2019 11:40:45 +0000 (11:40 +0000)
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.

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

lib/IR/IntrinsicInst.cpp

index a426c9b4df1e1a5756040351d69af467e12235d7..2996cfb533262d290ddf818d9fa60ec8e8175e3e 100644 (file)
@@ -107,7 +107,7 @@ Optional<ConstrainedFPIntrinsic::RoundingMode>
 ConstrainedFPIntrinsic::getRoundingMode() const {
   unsigned NumOperands = getNumArgOperands();
   Metadata *MD =
-      dyn_cast<MetadataAsValue>(getArgOperand(NumOperands - 2))->getMetadata();
+      cast<MetadataAsValue>(getArgOperand(NumOperands - 2))->getMetadata();
   if (!MD || !isa<MDString>(MD))
     return None;
   return StrToRoundingMode(cast<MDString>(MD)->getString());
@@ -153,7 +153,7 @@ Optional<ConstrainedFPIntrinsic::ExceptionBehavior>
 ConstrainedFPIntrinsic::getExceptionBehavior() const {
   unsigned NumOperands = getNumArgOperands();
   Metadata *MD =
-      dyn_cast<MetadataAsValue>(getArgOperand(NumOperands - 1))->getMetadata();
+      cast<MetadataAsValue>(getArgOperand(NumOperands - 1))->getMetadata();
   if (!MD || !isa<MDString>(MD))
     return None;
   return StrToExceptionBehavior(cast<MDString>(MD)->getString());