From: Serge Pavlov Date: Mon, 28 Dec 2015 17:19:12 +0000 (+0000) Subject: Avoid crash when dumping LocInfoType. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d187518c85f9d7ed612c61acc3d969ca2d0ce59;p=clang Avoid crash when dumping LocInfoType. LocInfoType is a helper type used internally inside Sema and Parser, it does not exist in valid AST. LocInfoType uses code value outside the range of valid Type codes, as a result, dumping such type causes error. The fix allows correct dumping LocInfoType. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256503 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index f94bd49fd8..e7fee0316b 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -24,6 +24,7 @@ #include "clang/Basic/Builtins.h" #include "clang/Basic/Module.h" #include "clang/Basic/SourceManager.h" +#include "clang/Sema/LocInfoType.h" #include "llvm/Support/raw_ostream.h" using namespace clang; using namespace clang::comments; @@ -655,6 +656,15 @@ void ASTDumper::dumpTypeAsChild(const Type *T) { OS << "<<>>"; return; } + if (const LocInfoType *LIT = llvm::dyn_cast(T)) { + { + ColorScope Color(*this, TypeColor); + OS << "LocInfo Type"; + } + dumpPointer(T); + dumpTypeAsChild(LIT->getTypeSourceInfo()->getType()); + return; + } { ColorScope Color(*this, TypeColor);