[PATCH] D82880: Fix PR35677: UB on __int128_t or __uint128_t template parameters.

David Stone via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 24 14:45:43 PDT 2021


davidstone updated this revision to Diff 333135.
davidstone added a comment.

[clang] 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".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82880/new/

https://reviews.llvm.org/D82880

Files:
  clang/lib/AST/StmtPrinter.cpp
  clang/test/AST/ast-print-int128.cpp


Index: clang/test/AST/ast-print-int128.cpp
===================================================================
--- /dev/null
+++ 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>());
Index: clang/lib/AST/StmtPrinter.cpp
===================================================================
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -1170,6 +1170,8 @@
   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.
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82880.333135.patch
Type: text/x-patch
Size: 947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210324/b9daed78/attachment-0001.bin>


More information about the cfe-commits mailing list