diff options
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/APValue.cpp | 7 | ||||
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 4 | ||||
-rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 6 | ||||
-rw-r--r-- | clang/lib/AST/TypePrinter.cpp | 9 |
4 files changed, 16 insertions, 10 deletions
diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp index e7b5a6be34b..0fa0216d9da 100644 --- a/clang/lib/AST/APValue.cpp +++ b/clang/lib/AST/APValue.cpp @@ -403,9 +403,13 @@ void APValue::printPretty(raw_ostream &Out, ASTContext &Ctx, QualType Ty) const{ if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>()) Out << *VD; - else + else { + assert(Base.get<const Expr *>() != nullptr && + "Expecting non-null Expr"); Base.get<const Expr*>()->printPretty(Out, nullptr, Ctx.getPrintingPolicy()); + } + if (!O.isZero()) { Out << " + " << (O / S); if (IsReference) @@ -426,6 +430,7 @@ void APValue::printPretty(raw_ostream &Out, ASTContext &Ctx, QualType Ty) const{ ElemTy = VD->getType(); } else { const Expr *E = Base.get<const Expr*>(); + assert(E != nullptr && "Expecting non-null Expr"); E->printPretty(Out, nullptr, Ctx.getPrintingPolicy()); ElemTy = E->getType(); } diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 558654d8875..e5e5130f695 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -536,6 +536,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { SimpleInit->printPretty(Out, nullptr, Policy, Indentation); else { for (unsigned I = 0; I != NumArgs; ++I) { + assert(Args[I] != nullptr && "Expected non-null Expr"); if (isa<CXXDefaultArgExpr>(Args[I])) break; @@ -586,7 +587,8 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } else Out << ' '; - D->getBody()->printPretty(Out, nullptr, SubPolicy, Indentation); + if (D->getBody()) + D->getBody()->printPretty(Out, nullptr, SubPolicy, Indentation); Out << '\n'; } } diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 1daab32e5b7..06514056185 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -645,6 +645,7 @@ void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { for (typename T::varlist_iterator I = Node->varlist_begin(), E = Node->varlist_end(); I != E; ++I) { + assert(*I && "Expected non-null Stmt"); if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(*I)) { OS << (I == Node->varlist_begin() ? StartSym : ','); cast<NamedDecl>(DRE->getDecl())->printQualifiedName(OS); @@ -2025,11 +2026,6 @@ void Stmt::printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation) const { - if (this == nullptr) { - OS << "<NULL>"; - return; - } - StmtPrinter P(OS, Helper, Policy, Indentation); P.Visit(const_cast<Stmt*>(this)); } diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index dfb43a0a84e..8e2cea3f880 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -593,7 +593,8 @@ FunctionProtoType::printExceptionSpecification(raw_ostream &OS, OS << " noexcept"; if (getExceptionSpecType() == EST_ComputedNoexcept) { OS << '('; - getNoexceptExpr()->printPretty(OS, nullptr, Policy); + if (getNoexceptExpr()) + getNoexceptExpr()->printPretty(OS, nullptr, Policy); OS << ')'; } } @@ -761,7 +762,8 @@ void TypePrinter::printTypedefAfter(const TypedefType *T, raw_ostream &OS) { } void TypePrinter::printTypeOfExprBefore(const TypeOfExprType *T, raw_ostream &OS) { OS << "typeof "; - T->getUnderlyingExpr()->printPretty(OS, nullptr, Policy); + if (T->getUnderlyingExpr()) + T->getUnderlyingExpr()->printPretty(OS, nullptr, Policy); spaceBeforePlaceHolder(OS); } void TypePrinter::printTypeOfExprAfter(const TypeOfExprType *T, @@ -777,7 +779,8 @@ void TypePrinter::printTypeOfAfter(const TypeOfType *T, raw_ostream &OS) { } void TypePrinter::printDecltypeBefore(const DecltypeType *T, raw_ostream &OS) { OS << "decltype("; - T->getUnderlyingExpr()->printPretty(OS, nullptr, Policy); + if (T->getUnderlyingExpr()) + T->getUnderlyingExpr()->printPretty(OS, nullptr, Policy); OS << ')'; spaceBeforePlaceHolder(OS); } |