[cfe-commits] r124315 - in /cfe/trunk: lib/AST/ItaniumMangle.cpp test/CodeGenCXX/mangle.cpp
John McCall
rjmccall at apple.com
Wed Jan 26 12:05:40 PST 2011
Author: rjmccall
Date: Wed Jan 26 14:05:40 2011
New Revision: 124315
URL: http://llvm.org/viewvc/llvm-project?rev=124315&view=rev
Log:
When mangling a qualified array type, push the qualifiers down to the
element type. Fixes rdar://problem/8913416.
Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=124315&r1=124314&r2=124315&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Jan 26 14:05:40 2011
@@ -1191,21 +1191,35 @@
Out << Buffer;
}
-void CXXNameMangler::mangleType(QualType T) {
+void CXXNameMangler::mangleType(QualType nonCanon) {
// Only operate on the canonical type!
- T = Context.getASTContext().getCanonicalType(T);
+ QualType canon = nonCanon.getCanonicalType();
- bool IsSubstitutable = T.hasLocalQualifiers() || !isa<BuiltinType>(T);
- if (IsSubstitutable && mangleSubstitution(T))
+ SplitQualType split = canon.split();
+ Qualifiers quals = split.second;
+ const Type *ty = split.first;
+
+ bool isSubstitutable = quals || !isa<BuiltinType>(ty);
+ if (isSubstitutable && mangleSubstitution(canon))
return;
- if (Qualifiers Quals = T.getLocalQualifiers()) {
- mangleQualifiers(Quals);
+ // If we're mangling a qualified array type, push the qualifiers to
+ // the element type.
+ if (quals && isa<ArrayType>(ty)) {
+ ty = Context.getASTContext().getAsArrayType(canon);
+ quals = Qualifiers();
+
+ // Note that we don't update canon: we want to add the
+ // substitution at the canonical type.
+ }
+
+ if (quals) {
+ mangleQualifiers(quals);
// Recurse: even if the qualified type isn't yet substitutable,
// the unqualified type might be.
- mangleType(T.getLocalUnqualifiedType());
+ mangleType(QualType(ty, 0));
} else {
- switch (T->getTypeClass()) {
+ switch (ty->getTypeClass()) {
#define ABSTRACT_TYPE(CLASS, PARENT)
#define NON_CANONICAL_TYPE(CLASS, PARENT) \
case Type::CLASS: \
@@ -1213,15 +1227,15 @@
return;
#define TYPE(CLASS, PARENT) \
case Type::CLASS: \
- mangleType(static_cast<const CLASS##Type*>(T.getTypePtr())); \
+ mangleType(static_cast<const CLASS##Type*>(ty)); \
break;
#include "clang/AST/TypeNodes.def"
}
}
// Add the substitution.
- if (IsSubstitutable)
- addSubstitution(T);
+ if (isSubstitutable)
+ addSubstitution(canon);
}
void CXXNameMangler::mangleNameOrStandardSubstitution(const NamedDecl *ND) {
Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=124315&r1=124314&r2=124315&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Wed Jan 26 14:05:40 2011
@@ -635,3 +635,15 @@
// CHECK: define void @_ZN6test221fEDn(
void f(decltype(nullptr)) { }
}
+
+// rdar://problem/8913416
+namespace test23 {
+ typedef void * const vpc;
+
+ // CHECK: define void @_ZN6test231fERA10_KPv(
+ void f(vpc (&)[10]) {}
+
+ typedef vpc vpca5[5];
+ void f(vpca5 volatile (&)[10]) {}
+ // CHECK: define void @_ZN6test231fERA10_A5_VKPv(
+}
More information about the cfe-commits
mailing list