Author: David Stone
Date: 2021-03-25T17:27:13-04:00
New Revision: 4b5baa5b8244778b0e7253cdb98924c3dab611b7

URL: 
https://github.com/llvm/llvm-project/commit/4b5baa5b8244778b0e7253cdb98924c3dab611b7
DIFF: 
https://github.com/llvm/llvm-project/commit/4b5baa5b8244778b0e7253cdb98924c3dab611b7.diff

LOG: Handle 128-bits IntegerLiterals in StmtPrinter

This fixes PR35677: "int128_t or uint128_t as non-type template
parameter causes crash when considering invalid constructor".

Added: 
    clang/test/AST/ast-print-int128.cpp

Modified: 
    clang/lib/AST/StmtPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 9acfeda4e76c..ca35c6dccbf8 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1170,6 +1170,10 @@ void StmtPrinter::VisitIntegerLiteral(IntegerLiteral 
*Node) {
   case BuiltinType::ULong:     OS << "UL"; break;
   case BuiltinType::LongLong:  OS << "LL"; break;
   case BuiltinType::ULongLong: OS << "ULL"; break;
+  case BuiltinType::Int128:
+    break; // no suffix.
+  case BuiltinType::UInt128:
+    break; // no suffix.
   }
 }
 

diff  --git a/clang/test/AST/ast-print-int128.cpp 
b/clang/test/AST/ast-print-int128.cpp
new file mode 100644
index 000000000000..01a130ceaa32
--- /dev/null
+++ b/clang/test/AST/ast-print-int128.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -ast-print -std=c++20 %s -o - | FileCheck %s
+
+template <bool>
+struct enable_if {
+};
+
+template <__uint128_t x, typename = typename enable_if<x != 0>::type>
+void f();
+
+template <__int128_t>
+void f();
+
+using T = decltype(f<0>());
+
+// CHECK: using T = decltype(f<0>());


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to