forked from qt-creator/qt-creator
CPlusPlus: Inline more simple Type related functions
Change-Id: I2103e8047b385b438e58072e8a2689f1889d2724 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -285,7 +285,7 @@ public:
|
||||
}
|
||||
|
||||
const FullySpecifiedType ty = rewrite->env->apply(name->identifier(), rewrite);
|
||||
const Name * const minName = ty->isNamedType() ? ty->asNamedType()->name() : name;
|
||||
const Name * const minName = ty->asNamedType() ? ty->asNamedType()->name() : name;
|
||||
const TemplateNameId * const newTemplateNameId = control()->templateNameId(
|
||||
identifier(minName->identifier()), name->isSpecialization(), args.data(),
|
||||
args.size());
|
||||
|
||||
@@ -315,7 +315,7 @@ private:
|
||||
return Usage::Type::Other;
|
||||
if (const auto refType = type->asReferenceType())
|
||||
return refType->elementType().isConst() ? Usage::Type::Read : Usage::Type::WritableRef;
|
||||
while (type->isPointerType()) {
|
||||
while (type->asPointerType()) {
|
||||
type = type->asPointerType()->elementType();
|
||||
if (!type.isConst())
|
||||
return Usage::Type::WritableRef;
|
||||
@@ -434,7 +434,7 @@ private:
|
||||
if (items.isEmpty())
|
||||
return Usage::Type::Other;
|
||||
for (const LookupItem &item : qAsConst(items)) {
|
||||
if (item.type()->isFunctionType()) {
|
||||
if (item.type()->asFunctionType()) {
|
||||
if (item.type().isConst())
|
||||
return Usage::Type::Read;
|
||||
if (item.type().isStatic())
|
||||
|
||||
@@ -58,7 +58,7 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
|
||||
|
||||
FullySpecifiedType symbolType = symbol->type();
|
||||
if (symbol->asFunction() || (symbol->asDeclaration() && symbolType &&
|
||||
symbolType->isFunctionType()))
|
||||
symbolType->asFunctionType()))
|
||||
{
|
||||
const Function *function = symbol->asFunction();
|
||||
if (!function)
|
||||
|
||||
@@ -1089,14 +1089,14 @@ ClassOrNamespace *ClassOrNamespace::findSpecialization(const TemplateNameId *tem
|
||||
= specializationTemplateArgument.type().type()->asPointerType();
|
||||
// specialization and initialization argument have to be a pointer
|
||||
// additionally type of pointer argument of specialization has to be namedType
|
||||
if (specPointer && initializationTemplateArgument.type().type()->isPointerType()
|
||||
&& specPointer->elementType().type()->isNamedType()) {
|
||||
if (specPointer && initializationTemplateArgument.type().type()->asPointerType()
|
||||
&& specPointer->elementType().type()->asNamedType()) {
|
||||
return cit->second;
|
||||
}
|
||||
|
||||
ArrayType *specArray
|
||||
= specializationTemplateArgument.type().type()->asArrayType();
|
||||
if (specArray && initializationTemplateArgument.type().type()->isArrayType()) {
|
||||
if (specArray && initializationTemplateArgument.type().type()->asArrayType()) {
|
||||
if (const NamedType *argumentNamedType
|
||||
= specArray->elementType().type()->asNamedType()) {
|
||||
if (const Name *argumentName = argumentNamedType->name()) {
|
||||
@@ -1340,7 +1340,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
|
||||
cloner.type(tParam->type(), &subst);
|
||||
|
||||
if (i < templSpecArgumentCount
|
||||
&& templSpecId->templateArgumentAt(i).type()->isPointerType()) {
|
||||
&& templSpecId->templateArgumentAt(i).type()->asPointerType()) {
|
||||
if (PointerType *pointerType = ty->asPointerType())
|
||||
ty = pointerType->elementType();
|
||||
}
|
||||
|
||||
@@ -168,10 +168,10 @@ private:
|
||||
visited.insert(declaration);
|
||||
|
||||
// continue working with the typedefed type and scope
|
||||
if (type->type()->isPointerType()) {
|
||||
if (type->type()->asPointerType()) {
|
||||
*type = FullySpecifiedType(
|
||||
_context.bindings()->control()->pointerType(declaration->type()));
|
||||
} else if (type->type()->isReferenceType()) {
|
||||
} else if (type->type()->asReferenceType()) {
|
||||
*type = FullySpecifiedType(
|
||||
_context.bindings()->control()->referenceType(
|
||||
declaration->type(),
|
||||
@@ -1129,11 +1129,11 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
|
||||
|
||||
Function *instantiatedFunction = nullptr;
|
||||
|
||||
if (overloadType->isFunctionType()) {
|
||||
if (overloadType->asFunctionType()) {
|
||||
FullySpecifiedType overloadTy
|
||||
= instantiate(binding->templateId(), overload);
|
||||
instantiatedFunction = overloadTy->asFunctionType();
|
||||
} else if (overloadType->isTemplateType()
|
||||
} else if (overloadType->asTemplateType()
|
||||
&& overloadType->asTemplateType()->declaration()
|
||||
&& overloadType->asTemplateType()->declaration()->asFunction()) {
|
||||
instantiatedFunction = overloadType->asTemplateType()->declaration()->asFunction();
|
||||
@@ -1146,7 +1146,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
|
||||
|
||||
typedefsResolver.resolve(&retTy, &functionScope, r.binding());
|
||||
|
||||
if (! retTy->isPointerType() && ! retTy->isNamedType())
|
||||
if (! retTy->asPointerType() && ! retTy->asNamedType())
|
||||
continue;
|
||||
|
||||
if (PointerType *ptrTy = retTy->asPointerType())
|
||||
@@ -1178,7 +1178,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
|
||||
}
|
||||
} else if (accessOp == T_DOT) {
|
||||
if (replacedDotOperator) {
|
||||
*replacedDotOperator = originalType->isPointerType() || ty->isPointerType();
|
||||
*replacedDotOperator = originalType->asPointerType() || ty->asPointerType();
|
||||
if (PointerType *ptrTy = ty->asPointerType())
|
||||
ty = ptrTy->elementType();
|
||||
}
|
||||
|
||||
@@ -312,8 +312,8 @@ void TypePrettyPrinter::visit(PointerToMemberType *type)
|
||||
|
||||
void TypePrettyPrinter::prependSpaceBeforeIndirection(const FullySpecifiedType &type)
|
||||
{
|
||||
const bool elementTypeIsPointerOrReference = type.type()->isPointerType()
|
||||
|| type.type()->isReferenceType();
|
||||
const bool elementTypeIsPointerOrReference = type.type()->asPointerType()
|
||||
|| type.type()->asReferenceType();
|
||||
const bool elementIsConstPointerOrReference = elementTypeIsPointerOrReference && type.isConst();
|
||||
const bool shouldBindToLeftSpecifier = _overview->starBindFlags & Overview::BindToLeftSpecifier;
|
||||
if (elementIsConstPointerOrReference && ! shouldBindToLeftSpecifier)
|
||||
@@ -342,8 +342,8 @@ void TypePrettyPrinter::prependSpaceAfterIndirection(bool hasName)
|
||||
|
||||
void TypePrettyPrinter::visit(PointerType *type)
|
||||
{
|
||||
const bool isIndirectionToFunction = type->elementType().type()->isFunctionType();
|
||||
const bool isIndirectionToArray = type->elementType().type()->isArrayType();
|
||||
const bool isIndirectionToFunction = type->elementType().type()->asFunctionType();
|
||||
const bool isIndirectionToArray = type->elementType().type()->asArrayType();
|
||||
|
||||
visitIndirectionType(aPointerType, type->elementType(),
|
||||
isIndirectionToFunction || isIndirectionToArray);
|
||||
@@ -351,8 +351,8 @@ void TypePrettyPrinter::visit(PointerType *type)
|
||||
|
||||
void TypePrettyPrinter::visit(ReferenceType *type)
|
||||
{
|
||||
const bool isIndirectionToFunction = type->elementType().type()->isFunctionType();
|
||||
const bool isIndirectionToArray = type->elementType().type()->isArrayType();
|
||||
const bool isIndirectionToFunction = type->elementType().type()->asFunctionType();
|
||||
const bool isIndirectionToArray = type->elementType().type()->asArrayType();
|
||||
const IndirectionType indirectionType = type->isRvalueReference()
|
||||
? aRvalueReferenceType : aReferenceType;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user