]> granicus.if.org Git - clang/commitdiff
Avoid crash when dumping LocInfoType.
authorSerge Pavlov <sepavloff@gmail.com>
Mon, 28 Dec 2015 17:19:12 +0000 (17:19 +0000)
committerSerge Pavlov <sepavloff@gmail.com>
Mon, 28 Dec 2015 17:19:12 +0000 (17:19 +0000)
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

lib/AST/ASTDumper.cpp

index f94bd49fd857260fe448a3944f20d21cb0bb27a7..e7fee0316b69d537aeed9e0dae05055e633a0c9d 100644 (file)
@@ -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 << "<<<NULL>>>";
       return;
     }
+    if (const LocInfoType *LIT = llvm::dyn_cast<LocInfoType>(T)) {
+      {
+        ColorScope Color(*this, TypeColor);
+        OS << "LocInfo Type";
+      }
+      dumpPointer(T);
+      dumpTypeAsChild(LIT->getTypeSourceInfo()->getType());
+      return;
+    }
 
     {
       ColorScope Color(*this, TypeColor);