r374013 - [ItaniumMangle] Fix mangling of GNU __null in an expression to match GCC
James Clarke via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 7 19:28:57 PDT 2019
Author: jrtc27
Date: Mon Oct 7 19:28:57 2019
New Revision: 374013
URL: http://llvm.org/viewvc/llvm-project?rev=374013&view=rev
Log:
[ItaniumMangle] Fix mangling of GNU __null in an expression to match GCC
Reviewers: rsmith
Reviewed By: rsmith
Subscribers: erik.pilkington, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D68368
Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=374013&r1=374012&r2=374013&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Mon Oct 7 19:28:57 2019
@@ -4273,8 +4273,11 @@ recurse:
}
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";
Modified: cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp?rev=374013&r1=374012&r2=374013&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-exprs.cpp Mon Oct 7 19:28:57 2019
@@ -373,3 +373,19 @@ namespace designated_init {
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 *);
+}
More information about the cfe-commits
mailing list