diff options
Diffstat (limited to 'lib/AST/APValue.cpp')
-rw-r--r-- | lib/AST/APValue.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/AST/APValue.cpp b/lib/AST/APValue.cpp index c45b52a65a4db..c05b160b8e3d9 100644 --- a/lib/AST/APValue.cpp +++ b/lib/AST/APValue.cpp @@ -416,18 +416,26 @@ void APValue::printPretty(raw_ostream &Out, ASTContext &Ctx, QualType Ty) const{ << GetApproxValue(getComplexFloatImag()) << "i"; return; case APValue::LValue: { - LValueBase Base = getLValueBase(); - if (!Base) { - Out << "0"; - return; - } - bool IsReference = Ty->isReferenceType(); QualType InnerTy = IsReference ? Ty.getNonReferenceType() : Ty->getPointeeType(); if (InnerTy.isNull()) InnerTy = Ty; + LValueBase Base = getLValueBase(); + if (!Base) { + if (isNullPointer()) { + Out << (Ctx.getLangOpts().CPlusPlus11 ? "nullptr" : "0"); + } else if (IsReference) { + Out << "*(" << InnerTy.stream(Ctx.getPrintingPolicy()) << "*)" + << getLValueOffset().getQuantity(); + } else { + Out << "(" << Ty.stream(Ctx.getPrintingPolicy()) << ")" + << getLValueOffset().getQuantity(); + } + return; + } + if (!hasLValuePath()) { // No lvalue path: just print the offset. CharUnits O = getLValueOffset(); |