[llvm-bugs] [Bug 43366] New: If dyn_cast<TYPE>(X) is non-null, assume X is non-null as well?

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 19 14:51:55 PDT 2019


            Bug ID: 43366
           Summary: If dyn_cast<TYPE>(X) is non-null, assume X is non-null
                    as well?
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: llvm-dev at redking.me.uk
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org,
                    noqnoqneo at gmail.com

Noticed here:


if (auto *VTy = dyn_cast<VectorType>(Ty)) {
  Type *EltTy = VTy->getElementType();
  // Lower vectors of pointers to native pointer types.
  if (auto *PTy = dyn_cast<PointerType>(EltTy)) {
    EVT PointerTy(getPointerTy(DL, PTy->getAddressSpace()));
    EltTy = PointerTy.getTypeForEVT(Ty->getContext());
  return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(EltTy, false),

The warning says that Ty->getContext() can be a null pointer, but if we know
that VTy is non-null and is a dyn_cast from Ty, then shouldn't Ty be known to
be non-null?

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190919/f8aa1bac/attachment.html>

More information about the llvm-bugs mailing list