diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 23f323d0286a..321a139665f6 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -81,10 +81,10 @@ break; \ break; // Don't desugar through the primary typedef of an anonymous type. - if (isa(Underlying) && isa(QT)) - if (cast(Underlying)->getDecl()->getTypedefForAnonDecl() == - cast(QT)->getDecl()) - break; + if (const TagType *UTT = Underlying->getAs()) + if (const TypedefType *QTT = dyn_cast(QT)) + if (UTT->getDecl()->getTypedefForAnonDecl() == QTT->getDecl()) + break; // Record that we actually looked through an opaque type here. ShouldAKA = true; @@ -94,11 +94,11 @@ break; \ // If we have a pointer-like type, desugar the pointee as well. // FIXME: Handle other pointer-like types. if (const PointerType *Ty = QT->getAs()) { - QT = Context.getPointerType(Desugar(Context, Ty->getPointeeType(), - ShouldAKA)); + QT = Context.getPointerType(Desugar(Context, Ty->getPointeeType(), + ShouldAKA)); } else if (const LValueReferenceType *Ty = QT->getAs()) { - QT = Context.getLValueReferenceType(Desugar(Context, Ty->getPointeeType(), - ShouldAKA)); + QT = Context.getLValueReferenceType(Desugar(Context, Ty->getPointeeType(), + ShouldAKA)); } return QC.apply(QT); @@ -151,13 +151,10 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty, bool ShouldAKA = false; QualType DesugaredTy = Desugar(Context, Ty, ShouldAKA); if (ShouldAKA) { - std::string D = DesugaredTy.getAsString(Context.PrintingPolicy); - if (D != S) { - S = "'" + S + "' (aka '"; - S += D; - S += "')"; - return S; - } + S = "'" + S + "' (aka '"; + S += DesugaredTy.getAsString(Context.PrintingPolicy); + S += "')"; + return S; } }