diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-04-23 05:21:20 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-04-23 05:21:20 +0000 |
commit | 96183f6b0659c036100ce4718d219ceb43a82edd (patch) | |
tree | a836fd972feb9e558e6aa9719543439ab052075e /clang/lib/AST/MicrosoftMangle.cpp | |
parent | 8210fdf26ef0ac40486dd34253dda178fff78dd1 (diff) | |
download | bcm5719-llvm-96183f6b0659c036100ce4718d219ceb43a82edd.tar.gz bcm5719-llvm-96183f6b0659c036100ce4718d219ceb43a82edd.zip |
[MS ABI] Treat ConstantArrayType like IncompleteArrayType in args
Type backreferences for arguments use the DecayedType's original type.
Because of this, arguments with the same canonical type with the same
mangling would not backreference each other if one was a
ConstantArrayType while the other was an IncompleteArrayType. Solve
this by canonicalizing the ConstantArrayType to a suitable
IncompleteArrayType.
This fixes PR23325.
llvm-svn: 235572
Diffstat (limited to 'clang/lib/AST/MicrosoftMangle.cpp')
-rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 36891021142..6c953421dbe 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -1377,17 +1377,27 @@ void MicrosoftCXXNameMangler::mangleArgumentType(QualType T, // e.g. // void (*x)(void) will not form a backreference with void x(void) void *TypePtr; - if (const DecayedType *DT = T->getAs<DecayedType>()) { - TypePtr = DT->getOriginalType().getCanonicalType().getAsOpaquePtr(); + if (const auto *DT = T->getAs<DecayedType>()) { + QualType OriginalType = DT->getOriginalType(); + // Decayed ConstantArrayType should be treated identically to decayed + // IncompleteArrayType. + if (const auto *CAT = + getASTContext().getAsConstantArrayType(OriginalType)) + OriginalType = getASTContext().getIncompleteArrayType( + CAT->getElementType(), CAT->getSizeModifier(), + CAT->getIndexTypeCVRQualifiers()); + + TypePtr = OriginalType.getCanonicalType().getAsOpaquePtr(); // If the original parameter was textually written as an array, // instead treat the decayed parameter like it's const. // // e.g. // int [] -> int * const - if (DT->getOriginalType()->isArrayType()) + if (OriginalType->isArrayType()) T = T.withConst(); - } else + } else { TypePtr = T.getCanonicalType().getAsOpaquePtr(); + } ArgBackRefMap::iterator Found = TypeBackReferences.find(TypePtr); |