[PATCH] D68368: [ItaniumMangle] Fix mangling of GNU __null in an expression to match GCC

James Clarke via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 2 18:35:10 PDT 2019


jrtc27 created this revision.
jrtc27 added a reviewer: rsmith.
Herald added subscribers: cfe-commits, erik.pilkington.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68368

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/mangle-exprs.cpp


Index: clang/test/CodeGenCXX/mangle-exprs.cpp
===================================================================
--- clang/test/CodeGenCXX/mangle-exprs.cpp
+++ clang/test/CodeGenCXX/mangle-exprs.cpp
@@ -373,3 +373,19 @@
   template<typename T> void f(decltype(T{.a.b[3][1 ... 4] = 9}) x) {}
   void use_f(A a) { f<A>(a); }
 }
+
+namespace null {
+  template <decltype(nullptr) P>
+  void cpp_nullptr(typename enable_if<P == nullptr>::type* = 0) {
+  }
+
+  template <void *P>
+  void gnu_null(typename enable_if<P == __null>::type* = 0) {
+  }
+
+  // CHECK-LABEL: define {{.*}} @_ZN4null11cpp_nullptrILDn0EEEvPN9enable_ifIXeqT_LDnEEvE4typeE
+  template void cpp_nullptr<nullptr>(void *);
+
+  // CHECK-LABEL: define {{.*}} @_ZN4null8gnu_nullILPv0EEEvPN9enable_ifIXeqT_Ll0EEvE4typeE
+  template void gnu_null<nullptr>(void *);
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===================================================================
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -4273,8 +4273,11 @@
   }
 
   case Expr::GNUNullExprClass:
-    // FIXME: should this really be mangled the same as nullptr?
-    // fallthrough
+    // Mangle as if an integer literal 0.
+    Out << 'L';
+    mangleType(E->getType());
+    Out << "0E";
+    break;
 
   case Expr::CXXNullPtrLiteralExprClass: {
     Out << "LDnE";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68368.222949.patch
Type: text/x-patch
Size: 1345 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191003/5fbd8f67/attachment.bin>


More information about the cfe-commits mailing list