Regularize support for naming conversion functions in using decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99979 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index dfaa855..3c3786d 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -3327,6 +3327,11 @@
CurContext->addDecl(Shadow);
Shadow->setAccess(UD->getAccess());
+ // Register it as a conversion if appropriate.
+ if (Shadow->getDeclName().getNameKind()
+ == DeclarationName::CXXConversionFunctionName)
+ cast<CXXRecordDecl>(CurContext)->addConversionFunction(Shadow);
+
if (Orig->isInvalidDecl() || UD->isInvalidDecl())
Shadow->setInvalidDecl();
@@ -3361,6 +3366,10 @@
/// decl structures are (very reasonably) not designed for removal.
/// (2) avoids this but is very fiddly and phase-dependent.
void Sema::HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow) {
+ if (Shadow->getDeclName().getNameKind() ==
+ DeclarationName::CXXConversionFunctionName)
+ cast<CXXRecordDecl>(Shadow->getDeclContext())->removeConversion(Shadow);
+
// Remove it from the DeclContext...
Shadow->getDeclContext()->removeDecl(Shadow);
@@ -3374,7 +3383,7 @@
Shadow->getUsingDecl()->removeShadowDecl(Shadow);
// TODO: complain somehow if Shadow was used. It shouldn't
- // be possible for this to happen, because
+ // be possible for this to happen, because...?
}
/// Builds a using declaration.