[PATCH] D41781: [DeclPrinter] Handle built-in C++ types in -ast-print.

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 5 11:23:36 PST 2018


tra created this revision.
tra added a reviewer: arphaman.
Herald added subscribers: jlebar, sanjoy.

Fixes a crash in clang when it crashed with -ast-print on code that contained decltype(nullptr).


https://reviews.llvm.org/D41781

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/test/Sema/ast-print-cxx.cpp


Index: clang/test/Sema/ast-print-cxx.cpp
===================================================================
--- /dev/null
+++ clang/test/Sema/ast-print-cxx.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c++11 %s -ast-print | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 %s -ast-print \
+// RUN:      | %clang_cc1 -std=c++11 -x c++ -fsyntax-only -
+
+// CHECK: typedef decltype(nullptr) nullptr_t;
+typedef decltype(nullptr) nullptr_t;
Index: clang/lib/AST/DeclPrinter.cpp
===================================================================
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -144,6 +144,8 @@
       BaseType = RTy->getPointeeType();
     else if (const AutoType *ATy = BaseType->getAs<AutoType>())
       BaseType = ATy->getDeducedType();
+    else if (isa<BuiltinType>(BaseType))
+      break;
     else
       llvm_unreachable("Unknown declarator!");
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41781.128777.patch
Type: text/x-patch
Size: 892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180105/9b13acba/attachment.bin>


More information about the cfe-commits mailing list