https://bugs.llvm.org/show_bug.cgi?id=44420

            Bug ID: 44420
           Summary: Fatal error in clang/lib/AST/DeclPrinter.cpp
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: hav467...@gmail.com
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@metafoo.co.uk

Created attachment 22974
  --> https://bugs.llvm.org/attachment.cgi?id=22974&action=edit
clang/lib/AST/DeclPrinter.cpp

A fatal error causes the program to crash, because the program tries to access
a NULL BaseType.
The following is where the bug happens, and I add comments about the bug in the
code.

//In clang/lib/AST/DeclPrinter.cpp at line 143:
static QualType GetBaseType(QualType T) {
  // FIXME: This should be on the Type class!
  QualType BaseType = T;
  while (!BaseType->isSpecifierType()) {                                       
                                       //3. crash here because BaseType is
NULL, Description: Assertion failed: !isNull() && "Cannot retrieve a NULL type
pointer", file clang/AST/Type.h, line 659
    if (const PointerType *PTy = BaseType->getAs<PointerType>())
      BaseType = PTy->getPointeeType();
    else if (const BlockPointerType *BPy = BaseType->getAs<BlockPointerType>())
      BaseType = BPy->getPointeeType();
    else if (const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
      BaseType = ATy->getElementType();
    else if (const FunctionType* FTy = BaseType->getAs<FunctionType>())
      BaseType = FTy->getReturnType();                                         
                                     //1. go here Firstly
    else if (const VectorType *VTy = BaseType->getAs<VectorType>())
      BaseType = VTy->getElementType();
    else if (const ReferenceType *RTy = BaseType->getAs<ReferenceType>())
      BaseType = RTy->getPointeeType();
    else if (const AutoType *ATy = BaseType->getAs<AutoType>())
      BaseType = ATy->getDeducedType();                                        
                                   //2. go here and return NULL!!!
    else if (const ParenType *PTy = BaseType->getAs<ParenType>())
      BaseType = PTy->desugar();
    else
      // This must be a syntax error.
      break;
  }
  return BaseType;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to