[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
Mon Oct 7 22:27:01 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL374013: [ItaniumMangle] Fix mangling of GNU __null in an expression to match GCC (authored by jrtc27, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68368?vs=222949&id=223783#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68368

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


Index: cfe/trunk/lib/AST/ItaniumMangle.cpp
===================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp
+++ cfe/trunk/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";
Index: cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp
+++ cfe/trunk/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 *);
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68368.223783.patch
Type: text/x-patch
Size: 1369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191008/a81f7a29/attachment-0001.bin>


More information about the cfe-commits mailing list