forked from OSchip/llvm-project
Don't return a pointer to an UnresolvedSetImpl in the CXXRecordDecl interface,
expose only the iterators instead. llvm-svn: 168770
This commit is contained in:
parent
58c3cc12da
commit
a6567c4102
|
@ -1018,21 +1018,12 @@ public:
|
|||
return isLambda() ? captures_begin() + getLambdaData().NumCaptures : NULL;
|
||||
}
|
||||
|
||||
/// getConversions - Retrieve the overload set containing all of the
|
||||
/// conversion functions in this class.
|
||||
UnresolvedSetImpl *getConversionFunctions() {
|
||||
return &data().Conversions;
|
||||
}
|
||||
const UnresolvedSetImpl *getConversionFunctions() const {
|
||||
return &data().Conversions;
|
||||
}
|
||||
|
||||
typedef UnresolvedSetImpl::iterator conversion_iterator;
|
||||
typedef UnresolvedSetIterator conversion_iterator;
|
||||
conversion_iterator conversion_begin() const {
|
||||
return getConversionFunctions()->begin();
|
||||
return data().Conversions.begin();
|
||||
}
|
||||
conversion_iterator conversion_end() const {
|
||||
return getConversionFunctions()->end();
|
||||
return data().Conversions.end();
|
||||
}
|
||||
|
||||
/// Removes a conversion function from this class. The conversion
|
||||
|
@ -1042,7 +1033,8 @@ public:
|
|||
|
||||
/// getVisibleConversionFunctions - get all conversion functions visible
|
||||
/// in current class; including conversion function templates.
|
||||
const UnresolvedSetImpl *getVisibleConversionFunctions();
|
||||
std::pair<conversion_iterator, conversion_iterator>
|
||||
getVisibleConversionFunctions();
|
||||
|
||||
/// isAggregate - Whether this class is an aggregate (C++
|
||||
/// [dcl.init.aggr]), which is a class with no user-declared
|
||||
|
|
|
@ -1007,12 +1007,13 @@ static void CollectVisibleConversions(ASTContext &Context,
|
|||
|
||||
// Collect the direct conversions and figure out which conversions
|
||||
// will be hidden in the subclasses.
|
||||
UnresolvedSetImpl &Cs = *Record->getConversionFunctions();
|
||||
if (!Cs.empty()) {
|
||||
CXXRecordDecl::conversion_iterator ConvI = Record->conversion_begin();
|
||||
CXXRecordDecl::conversion_iterator ConvE = Record->conversion_end();
|
||||
if (ConvI != ConvE) {
|
||||
HiddenTypesBuffer = ParentHiddenTypes;
|
||||
HiddenTypes = &HiddenTypesBuffer;
|
||||
|
||||
for (UnresolvedSetIterator I = Cs.begin(), E = Cs.end(); I != E; ++I) {
|
||||
for (CXXRecordDecl::conversion_iterator I = ConvI; I != ConvE; ++I) {
|
||||
CanQualType ConvType(GetConversionType(Context, I.getDecl()));
|
||||
bool Hidden = ParentHiddenTypes.count(ConvType);
|
||||
if (!Hidden)
|
||||
|
@ -1073,10 +1074,11 @@ static void CollectVisibleConversions(ASTContext &Context,
|
|||
|
||||
// Go ahead and collect the direct conversions and add them to the
|
||||
// hidden-types set.
|
||||
UnresolvedSetImpl &Cs = *Record->getConversionFunctions();
|
||||
Output.append(Cs.begin(), Cs.end());
|
||||
for (UnresolvedSetIterator I = Cs.begin(), E = Cs.end(); I != E; ++I)
|
||||
HiddenTypes.insert(GetConversionType(Context, I.getDecl()));
|
||||
CXXRecordDecl::conversion_iterator ConvI = Record->conversion_begin();
|
||||
CXXRecordDecl::conversion_iterator ConvE = Record->conversion_end();
|
||||
Output.append(ConvI, ConvE);
|
||||
for (; ConvI != ConvE; ++ConvI)
|
||||
HiddenTypes.insert(GetConversionType(Context, ConvI.getDecl()));
|
||||
|
||||
// Recursively collect conversions from base classes.
|
||||
for (CXXRecordDecl::base_class_iterator
|
||||
|
@ -1099,16 +1101,18 @@ static void CollectVisibleConversions(ASTContext &Context,
|
|||
|
||||
/// getVisibleConversionFunctions - get all conversion functions visible
|
||||
/// in current class; including conversion function templates.
|
||||
const UnresolvedSetImpl *CXXRecordDecl::getVisibleConversionFunctions() {
|
||||
std::pair<CXXRecordDecl::conversion_iterator,CXXRecordDecl::conversion_iterator>
|
||||
CXXRecordDecl::getVisibleConversionFunctions() {
|
||||
// If root class, all conversions are visible.
|
||||
if (bases_begin() == bases_end())
|
||||
return &data().Conversions;
|
||||
return std::make_pair(data().Conversions.begin(), data().Conversions.end());
|
||||
// If visible conversion list is already evaluated, return it.
|
||||
if (data().ComputedVisibleConversions)
|
||||
return &data().VisibleConversions;
|
||||
CollectVisibleConversions(getASTContext(), this, data().VisibleConversions);
|
||||
data().ComputedVisibleConversions = true;
|
||||
return &data().VisibleConversions;
|
||||
if (!data().ComputedVisibleConversions) {
|
||||
CollectVisibleConversions(getASTContext(), this, data().VisibleConversions);
|
||||
data().ComputedVisibleConversions = true;
|
||||
}
|
||||
return std::make_pair(data().VisibleConversions.begin(),
|
||||
data().VisibleConversions.end());
|
||||
}
|
||||
|
||||
void CXXRecordDecl::removeConversion(const NamedDecl *ConvDecl) {
|
||||
|
@ -1123,7 +1127,7 @@ void CXXRecordDecl::removeConversion(const NamedDecl *ConvDecl) {
|
|||
// with sufficiently large numbers of directly-declared conversions
|
||||
// that asymptotic behavior matters.
|
||||
|
||||
UnresolvedSetImpl &Convs = *getConversionFunctions();
|
||||
UnresolvedSetImpl &Convs = data().Conversions;
|
||||
for (unsigned I = 0, E = Convs.size(); I != E; ++I) {
|
||||
if (Convs[I].getDecl() == ConvDecl) {
|
||||
Convs.erase(I);
|
||||
|
|
|
@ -10369,10 +10369,10 @@ void Sema::ActOnFields(Scope* S,
|
|||
if (CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
|
||||
if (!CXXRecord->isInvalidDecl()) {
|
||||
// Set access bits correctly on the directly-declared conversions.
|
||||
UnresolvedSetImpl *Convs = CXXRecord->getConversionFunctions();
|
||||
for (UnresolvedSetIterator I = Convs->begin(), E = Convs->end();
|
||||
I != E; ++I)
|
||||
Convs->setAccess(I, (*I)->getAccess());
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = CXXRecord->conversion_begin(),
|
||||
E = CXXRecord->conversion_end(); I != E; ++I)
|
||||
I.setAccess((*I)->getAccess());
|
||||
|
||||
if (!CXXRecord->isDependentType()) {
|
||||
// Adjust user-defined destructor exception spec.
|
||||
|
|
|
@ -2037,9 +2037,11 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
|
|||
SmallVector<CXXConversionDecl*, 4> ObjectPtrConversions;
|
||||
|
||||
CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
|
||||
const UnresolvedSetImpl *Conversions = RD->getVisibleConversionFunctions();
|
||||
for (UnresolvedSetImpl::iterator I = Conversions->begin(),
|
||||
E = Conversions->end(); I != E; ++I) {
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator>
|
||||
Conversions = RD->getVisibleConversionFunctions();
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
NamedDecl *D = I.getDecl();
|
||||
if (isa<UsingShadowDecl>(D))
|
||||
D = cast<UsingShadowDecl>(D)->getTargetDecl();
|
||||
|
|
|
@ -3200,10 +3200,11 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S,
|
|||
// functions.
|
||||
CXXRecordDecl *T2RecordDecl = cast<CXXRecordDecl>(T2RecordType->getDecl());
|
||||
|
||||
const UnresolvedSetImpl *Conversions
|
||||
= T2RecordDecl->getVisibleConversionFunctions();
|
||||
for (UnresolvedSetImpl::const_iterator I = Conversions->begin(),
|
||||
E = Conversions->end(); I != E; ++I) {
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator>
|
||||
Conversions = T2RecordDecl->getVisibleConversionFunctions();
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
NamedDecl *D = *I;
|
||||
CXXRecordDecl *ActingDC = cast<CXXRecordDecl>(D->getDeclContext());
|
||||
if (isa<UsingShadowDecl>(D))
|
||||
|
@ -3759,11 +3760,11 @@ static void TryUserDefinedConversion(Sema &S,
|
|||
CXXRecordDecl *SourceRecordDecl
|
||||
= cast<CXXRecordDecl>(SourceRecordType->getDecl());
|
||||
|
||||
const UnresolvedSetImpl *Conversions
|
||||
= SourceRecordDecl->getVisibleConversionFunctions();
|
||||
for (UnresolvedSetImpl::const_iterator I = Conversions->begin(),
|
||||
E = Conversions->end();
|
||||
I != E; ++I) {
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator>
|
||||
Conversions = SourceRecordDecl->getVisibleConversionFunctions();
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
NamedDecl *D = *I;
|
||||
CXXRecordDecl *ActingDC = cast<CXXRecordDecl>(D->getDeclContext());
|
||||
if (isa<UsingShadowDecl>(D))
|
||||
|
|
|
@ -673,9 +673,8 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) {
|
|||
if (!Record->isCompleteDefinition())
|
||||
return Found;
|
||||
|
||||
const UnresolvedSetImpl *Unresolved = Record->getConversionFunctions();
|
||||
for (UnresolvedSetImpl::iterator U = Unresolved->begin(),
|
||||
UEnd = Unresolved->end(); U != UEnd; ++U) {
|
||||
for (CXXRecordDecl::conversion_iterator U = Record->conversion_begin(),
|
||||
UEnd = Record->conversion_end(); U != UEnd; ++U) {
|
||||
FunctionTemplateDecl *ConvTemplate = dyn_cast<FunctionTemplateDecl>(*U);
|
||||
if (!ConvTemplate)
|
||||
continue;
|
||||
|
|
|
@ -3065,10 +3065,11 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
|
|||
if (CXXRecordDecl *FromRecordDecl
|
||||
= dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
|
||||
// Add all of the conversion functions as candidates.
|
||||
const UnresolvedSetImpl *Conversions
|
||||
= FromRecordDecl->getVisibleConversionFunctions();
|
||||
for (UnresolvedSetImpl::iterator I = Conversions->begin(),
|
||||
E = Conversions->end(); I != E; ++I) {
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator>
|
||||
Conversions = FromRecordDecl->getVisibleConversionFunctions();
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
DeclAccessPair FoundDecl = I.getPair();
|
||||
NamedDecl *D = FoundDecl.getDecl();
|
||||
CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(D->getDeclContext());
|
||||
|
@ -3959,10 +3960,11 @@ FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
|
|||
= dyn_cast<CXXRecordDecl>(T2->getAs<RecordType>()->getDecl());
|
||||
|
||||
OverloadCandidateSet CandidateSet(DeclLoc);
|
||||
const UnresolvedSetImpl *Conversions
|
||||
= T2RecordDecl->getVisibleConversionFunctions();
|
||||
for (UnresolvedSetImpl::iterator I = Conversions->begin(),
|
||||
E = Conversions->end(); I != E; ++I) {
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator>
|
||||
Conversions = T2RecordDecl->getVisibleConversionFunctions();
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
NamedDecl *D = *I;
|
||||
CXXRecordDecl *ActingDC = cast<CXXRecordDecl>(D->getDeclContext());
|
||||
if (isa<UsingShadowDecl>(D))
|
||||
|
@ -5104,15 +5106,15 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From,
|
|||
// Look for a conversion to an integral or enumeration type.
|
||||
UnresolvedSet<4> ViableConversions;
|
||||
UnresolvedSet<4> ExplicitConversions;
|
||||
const UnresolvedSetImpl *Conversions
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator> Conversions
|
||||
= cast<CXXRecordDecl>(RecordTy->getDecl())->getVisibleConversionFunctions();
|
||||
|
||||
bool HadMultipleCandidates = (Conversions->size() > 1);
|
||||
bool HadMultipleCandidates
|
||||
= (std::distance(Conversions.first, Conversions.second) > 1);
|
||||
|
||||
for (UnresolvedSetImpl::iterator I = Conversions->begin(),
|
||||
E = Conversions->end();
|
||||
I != E;
|
||||
++I) {
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
if (CXXConversionDecl *Conversion
|
||||
= dyn_cast<CXXConversionDecl>((*I)->getUnderlyingDecl())) {
|
||||
if (isIntegralOrEnumerationType(
|
||||
|
@ -6286,10 +6288,11 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
|
|||
return;
|
||||
|
||||
CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(TyRec->getDecl());
|
||||
const UnresolvedSetImpl *Conversions
|
||||
= ClassDecl->getVisibleConversionFunctions();
|
||||
for (UnresolvedSetImpl::iterator I = Conversions->begin(),
|
||||
E = Conversions->end(); I != E; ++I) {
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator>
|
||||
Conversions = ClassDecl->getVisibleConversionFunctions();
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
NamedDecl *D = I.getDecl();
|
||||
if (isa<UsingShadowDecl>(D))
|
||||
D = cast<UsingShadowDecl>(D)->getTargetDecl();
|
||||
|
@ -6355,11 +6358,12 @@ static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr* ArgExpr) {
|
|||
if (!ClassDecl->hasDefinition())
|
||||
return VRQuals;
|
||||
|
||||
const UnresolvedSetImpl *Conversions =
|
||||
ClassDecl->getVisibleConversionFunctions();
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator>
|
||||
Conversions = ClassDecl->getVisibleConversionFunctions();
|
||||
|
||||
for (UnresolvedSetImpl::iterator I = Conversions->begin(),
|
||||
E = Conversions->end(); I != E; ++I) {
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
NamedDecl *D = I.getDecl();
|
||||
if (isa<UsingShadowDecl>(D))
|
||||
D = cast<UsingShadowDecl>(D)->getTargetDecl();
|
||||
|
@ -10878,10 +10882,11 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
|
|||
// functions for each conversion function declared in an
|
||||
// accessible base class provided the function is not hidden
|
||||
// within T by another intervening declaration.
|
||||
const UnresolvedSetImpl *Conversions
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator> Conversions
|
||||
= cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
|
||||
for (UnresolvedSetImpl::iterator I = Conversions->begin(),
|
||||
E = Conversions->end(); I != E; ++I) {
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
NamedDecl *D = *I;
|
||||
CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(D->getDeclContext());
|
||||
if (isa<UsingShadowDecl>(D))
|
||||
|
|
|
@ -954,16 +954,15 @@ Sema::ObjCSubscriptKind
|
|||
// objective-C pointer type.
|
||||
UnresolvedSet<4> ViableConversions;
|
||||
UnresolvedSet<4> ExplicitConversions;
|
||||
const UnresolvedSetImpl *Conversions
|
||||
std::pair<CXXRecordDecl::conversion_iterator,
|
||||
CXXRecordDecl::conversion_iterator> Conversions
|
||||
= cast<CXXRecordDecl>(RecordTy->getDecl())->getVisibleConversionFunctions();
|
||||
|
||||
int NoIntegrals=0, NoObjCIdPointers=0;
|
||||
SmallVector<CXXConversionDecl *, 4> ConversionDecls;
|
||||
|
||||
for (UnresolvedSetImpl::iterator I = Conversions->begin(),
|
||||
E = Conversions->end();
|
||||
I != E;
|
||||
++I) {
|
||||
for (CXXRecordDecl::conversion_iterator
|
||||
I = Conversions.first, E = Conversions.second; I != E; ++I) {
|
||||
if (CXXConversionDecl *Conversion
|
||||
= dyn_cast<CXXConversionDecl>((*I)->getUnderlyingDecl())) {
|
||||
QualType CT = Conversion->getConversionType().getNonReferenceType();
|
||||
|
|
Loading…
Reference in New Issue