From 76742aedda1189059fbc0a4c6af6d0285dbec9da Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 28 Nov 2014 22:22:46 +0000 Subject: [PATCH] AST: Consider pseudo-struct builtin types as substitutable We didn't consider types like ObjCSel as a substitution candidate. This fixes PR21688. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222941 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ItaniumMangle.cpp | 15 ++++++++++++++- test/CodeGenObjCXX/subst-sel.mm | 4 ++++ test/CodeGenOpenCL/opencl_types.cl | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/CodeGenObjCXX/subst-sel.mm diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index 9e9c1718d1..31250aaa20 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -1840,6 +1840,19 @@ void CXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) { Context.mangleObjCMethodName(MD, Out); } +static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty) { + if (Quals) + return true; + if (Ty->isSpecificBuiltinType(BuiltinType::ObjCSel)) + return true; + if (Ty->isOpenCLSpecificType()) + return true; + if (Ty->isBuiltinType()) + return false; + + return true; +} + void CXXNameMangler::mangleType(QualType T) { // If our type is instantiation-dependent but not dependent, we mangle // it as it was written in the source, removing any top-level sugar. @@ -1881,7 +1894,7 @@ void CXXNameMangler::mangleType(QualType T) { Qualifiers quals = split.Quals; const Type *ty = split.Ty; - bool isSubstitutable = quals || !isa(T); + bool isSubstitutable = isTypeSubstitutable(quals, ty); if (isSubstitutable && mangleSubstitution(T)) return; diff --git a/test/CodeGenObjCXX/subst-sel.mm b/test/CodeGenObjCXX/subst-sel.mm new file mode 100644 index 0000000000..f4a2b840fe --- /dev/null +++ b/test/CodeGenObjCXX/subst-sel.mm @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s + +// CHECK: @_Z4bad1P8NSObjectP13objc_selectorP11objc_objectS4_ +void bad1(struct NSObject *, SEL, id, id) {} diff --git a/test/CodeGenOpenCL/opencl_types.cl b/test/CodeGenOpenCL/opencl_types.cl index ed2bf6dd11..4ef94e660e 100644 --- a/test/CodeGenOpenCL/opencl_types.cl +++ b/test/CodeGenOpenCL/opencl_types.cl @@ -35,3 +35,6 @@ kernel void foo(image1d_t img) { fnc4smp(glb_smp); // CHECK: call void @fnc4smp(i32 } + +void __attribute__((overloadable)) bad1(image1d_t *b, image2d_t *c, image2d_t *d) {} +// CHECK-LABEL: @_Z4bad1P11ocl_image1dP11ocl_image2dS2_ -- 2.40.0