From: Douglas Gregor Date: Sat, 3 Dec 2011 18:24:43 +0000 (+0000) Subject: Fix mangling substitutions for address-space-qualified class X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14795c86f1c37874afa332a7b9bc18e6a02bf420;p=clang Fix mangling substitutions for address-space-qualified class types. Patch from Dmitri Rubinstein! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145776 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index b2e1d20ca0..1e71a627ce 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -2984,8 +2984,15 @@ bool CXXNameMangler::mangleSubstitution(const NamedDecl *ND) { return mangleSubstitution(reinterpret_cast(ND)); } +/// \brief Determine whether the given type has any qualifiers that are +/// relevant for substitutions. +static bool hasMangledSubstitutionQualifiers(QualType T) { + Qualifiers Qs = T.getQualifiers(); + return Qs.getCVRQualifiers() || Qs.hasAddressSpace(); +} + bool CXXNameMangler::mangleSubstitution(QualType T) { - if (!T.getCVRQualifiers()) { + if (!hasMangledSubstitutionQualifiers(T)) { if (const RecordType *RT = T->getAs()) return mangleSubstitution(RT->getDecl()); } @@ -3171,7 +3178,7 @@ bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { } void CXXNameMangler::addSubstitution(QualType T) { - if (!T.getCVRQualifiers()) { + if (!hasMangledSubstitutionQualifiers(T)) { if (const RecordType *RT = T->getAs()) { addSubstitution(RT->getDecl()); return; diff --git a/test/CodeGenCXX/mangle-address-space.cpp b/test/CodeGenCXX/mangle-address-space.cpp index fbbcbfa35b..ff23c20691 100644 --- a/test/CodeGenCXX/mangle-address-space.cpp +++ b/test/CodeGenCXX/mangle-address-space.cpp @@ -4,3 +4,9 @@ void f0(char *p) { } // CHECK: define void @_Z2f0PU3AS1c void f0(char __attribute__((address_space(1))) *p) { } + +struct OpaqueType; +typedef OpaqueType __attribute__((address_space(100))) * OpaqueTypePtr; + +// CHECK: define void @_Z2f0PU5AS10010OpaqueType +void f0(OpaqueTypePtr) { }