[llvm-bugs] [Bug 44420] New: Fatal error in clang/lib/AST/DeclPrinter.cpp

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 31 15:56:44 PST 2019


            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: unassignedclangbugs at nondot.org
          Reporter: hav467614 at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 22974
  --> https://bugs.llvm.org/attachment.cgi?id=22974&action=edit

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

//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();
      // This must be a syntax error.
  return BaseType;

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/20191231/0ddc08cf/attachment.html>

More information about the llvm-bugs mailing list