Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 8910a54

Browse files
committed
[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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374013 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d798a1e commit 8910a54

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/AST/ItaniumMangle.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -4273,8 +4273,11 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) {
42734273
}
42744274

42754275
case Expr::GNUNullExprClass:
4276-
// FIXME: should this really be mangled the same as nullptr?
4277-
// fallthrough
4276+
// Mangle as if an integer literal 0.
4277+
Out << 'L';
4278+
mangleType(E->getType());
4279+
Out << "0E";
4280+
break;
42784281

42794282
case Expr::CXXNullPtrLiteralExprClass: {
42804283
Out << "LDnE";

test/CodeGenCXX/mangle-exprs.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,19 @@ namespace designated_init {
373373
template<typename T> void f(decltype(T{.a.b[3][1 ... 4] = 9}) x) {}
374374
void use_f(A a) { f<A>(a); }
375375
}
376+
377+
namespace null {
378+
template <decltype(nullptr) P>
379+
void cpp_nullptr(typename enable_if<P == nullptr>::type* = 0) {
380+
}
381+
382+
template <void *P>
383+
void gnu_null(typename enable_if<P == __null>::type* = 0) {
384+
}
385+
386+
// CHECK-LABEL: define {{.*}} @_ZN4null11cpp_nullptrILDn0EEEvPN9enable_ifIXeqT_LDnEEvE4typeE
387+
template void cpp_nullptr<nullptr>(void *);
388+
389+
// CHECK-LABEL: define {{.*}} @_ZN4null8gnu_nullILPv0EEEvPN9enable_ifIXeqT_Ll0EEvE4typeE
390+
template void gnu_null<nullptr>(void *);
391+
}

0 commit comments

Comments
 (0)