forked from qt-creator/qt-creator
C++: Unindent findSpecialization
Change-Id: I5759c4e5b061865d53b00c7eeb0b1cee54f8398e Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
b365387f0d
commit
63433e7b98
@@ -1168,7 +1168,9 @@ static LookupScopePrivate *findSpecializationWithMatchingTemplateArgument(
|
|||||||
}
|
}
|
||||||
|
|
||||||
LookupScopePrivate *LookupScopePrivate::findSpecialization(
|
LookupScopePrivate *LookupScopePrivate::findSpecialization(
|
||||||
const TemplateNameId *templId, const TemplateNameIdTable &specializations, LookupScopePrivate *origin)
|
const TemplateNameId *templId,
|
||||||
|
const TemplateNameIdTable &specializations,
|
||||||
|
LookupScopePrivate *origin)
|
||||||
{
|
{
|
||||||
// we go through all specialization and try to find that one with template argument as pointer
|
// we go through all specialization and try to find that one with template argument as pointer
|
||||||
for (TemplateNameIdTable::const_iterator cit = specializations.begin();
|
for (TemplateNameIdTable::const_iterator cit = specializations.begin();
|
||||||
@@ -1176,51 +1178,47 @@ LookupScopePrivate *LookupScopePrivate::findSpecialization(
|
|||||||
const TemplateNameId *specializationNameId = cit->first;
|
const TemplateNameId *specializationNameId = cit->first;
|
||||||
const unsigned specializationTemplateArgumentCount
|
const unsigned specializationTemplateArgumentCount
|
||||||
= specializationNameId->templateArgumentCount();
|
= specializationNameId->templateArgumentCount();
|
||||||
const unsigned initializationTemplateArgumentCount
|
const unsigned initializationTemplateArgumentCount = templId->templateArgumentCount();
|
||||||
= templId->templateArgumentCount();
|
|
||||||
// for now it works only when we have the same number of arguments in specialization
|
// for now it works only when we have the same number of arguments in specialization
|
||||||
// and initialization(in future it should be more clever)
|
// and initialization(in future it should be more clever)
|
||||||
if (specializationTemplateArgumentCount == initializationTemplateArgumentCount) {
|
if (specializationTemplateArgumentCount != initializationTemplateArgumentCount)
|
||||||
for (unsigned i = 0; i < initializationTemplateArgumentCount; ++i) {
|
continue;
|
||||||
const FullySpecifiedType &specializationTemplateArgument
|
for (unsigned i = 0; i < initializationTemplateArgumentCount; ++i) {
|
||||||
= specializationNameId->templateArgumentAt(i);
|
const FullySpecifiedType &specializationTemplateArgument
|
||||||
FullySpecifiedType initializationTemplateArgument
|
= specializationNameId->templateArgumentAt(i);
|
||||||
= templId->templateArgumentAt(i);
|
FullySpecifiedType initializationTemplateArgument = templId->templateArgumentAt(i);
|
||||||
TypeResolver typeResolver(*_factory);
|
TypeResolver typeResolver(*_factory);
|
||||||
Scope *scope = 0;
|
Scope *scope = 0;
|
||||||
typeResolver.resolve(&initializationTemplateArgument, &scope, origin ? origin->q : 0);
|
typeResolver.resolve(&initializationTemplateArgument, &scope, origin ? origin->q : 0);
|
||||||
PointerType *specPointer
|
PointerType *specPointer = specializationTemplateArgument.type()->asPointerType();
|
||||||
= specializationTemplateArgument.type()->asPointerType();
|
// specialization and initialization argument have to be a pointer
|
||||||
// specialization and initialization argument have to be a pointer
|
// additionally type of pointer argument of specialization has to be namedType
|
||||||
// additionally type of pointer argument of specialization has to be namedType
|
if (specPointer && initializationTemplateArgument.type()->isPointerType()
|
||||||
if (specPointer && initializationTemplateArgument.type()->isPointerType()
|
&& specPointer->elementType().type()->isNamedType()) {
|
||||||
&& specPointer->elementType().type()->isNamedType()) {
|
return cit->second;
|
||||||
return cit->second;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ArrayType *specArray
|
ArrayType *specArray = specializationTemplateArgument.type()->asArrayType();
|
||||||
= specializationTemplateArgument.type()->asArrayType();
|
if (specArray && initializationTemplateArgument.type()->isArrayType()) {
|
||||||
if (specArray && initializationTemplateArgument.type()->isArrayType()) {
|
if (const NamedType *argumentNamedType
|
||||||
if (const NamedType *argumentNamedType
|
= specArray->elementType().type()->asNamedType()) {
|
||||||
= specArray->elementType().type()->asNamedType()) {
|
if (const Name *argumentName = argumentNamedType->name()) {
|
||||||
if (const Name *argumentName = argumentNamedType->name()) {
|
if (LookupScopePrivate *reference
|
||||||
if (LookupScopePrivate *reference
|
= findSpecializationWithMatchingTemplateArgument(
|
||||||
= findSpecializationWithMatchingTemplateArgument(
|
argumentName, cit->second)) {
|
||||||
argumentName, cit->second)) {
|
return reference;
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (specializationTemplateArgument == initializationTemplateArgument)
|
if (specializationTemplateArgument == initializationTemplateArgument)
|
||||||
return cit->second;
|
return cit->second;
|
||||||
|
|
||||||
if (const NamedType *specName = specializationTemplateArgument->asNamedType()) {
|
if (const NamedType *specName = specializationTemplateArgument->asNamedType()) {
|
||||||
if (const NamedType *initName = initializationTemplateArgument->asNamedType()) {
|
if (const NamedType *initName = initializationTemplateArgument->asNamedType()) {
|
||||||
if (specName->name()->identifier() == initName->name()->identifier())
|
if (specName->name()->identifier() == initName->name()->identifier())
|
||||||
return cit->second;
|
return cit->second;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user