CPlusPlus: Inline more simple Type related functions

Change-Id: I2103e8047b385b438e58072e8a2689f1889d2724
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2022-06-24 16:45:12 +02:00
parent 27d51e9804
commit e2bb204d4d
26 changed files with 180 additions and 469 deletions

View File

@@ -650,7 +650,7 @@ void tst_FindUsages::objc_args()
Declaration *methodIface = iface->memberAt(0)->asDeclaration();
QVERIFY(methodIface);
QCOMPARE(methodIface->identifier()->chars(), "method");
QVERIFY(methodIface->type()->isObjCMethodType());
QVERIFY(methodIface->type()->asObjCMethodType());
ObjCClass *impl = doc->globalSymbolAt(1)->asObjCClass();
QVERIFY(impl);

View File

@@ -451,7 +451,7 @@ void tst_Lookup::iface_impl_scoping()
Argument *method1Arg = method1Impl->memberAt(0)->asArgument();
QVERIFY(method1Arg);
QCOMPARE(method1Arg->identifier()->chars(), "arg");
QVERIFY(method1Arg->type()->isIntegerType());
QVERIFY(method1Arg->type()->asIntegerType());
Block *method1Body = method1Impl->memberAt(1)->asBlock();
QVERIFY(method1Body);
@@ -465,7 +465,7 @@ void tst_Lookup::iface_impl_scoping()
QVERIFY(arg->name());
QVERIFY(arg->name()->identifier());
QCOMPARE(arg->name()->identifier()->chars(), "arg");
QVERIFY(arg->type()->isIntegerType());
QVERIFY(arg->type()->asIntegerType());
const QList<LookupItem> candidates = context.lookup(arg->name(), method1Body->enclosingScope());
QCOMPARE(candidates.size(), 1);

View File

@@ -206,7 +206,7 @@ void tst_Semantic::function_declaration_1()
FullySpecifiedType declTy = decl->type();
Function *funTy = declTy->asFunctionType();
QVERIFY(funTy);
QVERIFY(funTy->returnType()->isVoidType());
QVERIFY(funTy->returnType()->asVoidType());
QCOMPARE(funTy->argumentCount(), 0);
QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier);
@@ -230,7 +230,7 @@ void tst_Semantic::function_declaration_2()
FullySpecifiedType declTy = decl->type();
Function *funTy = declTy->asFunctionType();
QVERIFY(funTy);
QVERIFY(funTy->returnType()->isVoidType());
QVERIFY(funTy->returnType()->asVoidType());
QCOMPARE(funTy->argumentCount(), 1);
QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier);
@@ -251,7 +251,7 @@ void tst_Semantic::function_declaration_2()
// check the type of the formal argument
FullySpecifiedType argTy = arg->type();
QVERIFY(argTy->isReferenceType());
QVERIFY(argTy->asReferenceType());
QVERIFY(argTy->asReferenceType()->elementType().isConst());
NamedType *namedTy = argTy->asReferenceType()->elementType()->asNamedType();
QVERIFY(namedTy);
@@ -359,7 +359,7 @@ void tst_Semantic::function_declaration_ref_qualifier()
FullySpecifiedType declTy = decl->type();
Function *funTy = declTy->asFunctionType();
QVERIFY(funTy);
QVERIFY(funTy->returnType()->isVoidType());
QVERIFY(funTy->returnType()->asVoidType());
QCOMPARE(funTy->argumentCount(), 0);
// check the ref-qualifier
@@ -374,7 +374,7 @@ void tst_Semantic::function_definition_1()
Function *funTy = doc->globals->memberAt(0)->asFunction();
QVERIFY(funTy);
QVERIFY(funTy->returnType()->isVoidType());
QVERIFY(funTy->returnType()->asVoidType());
QCOMPARE(funTy->argumentCount(), 0);
QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier);
@@ -448,7 +448,7 @@ void tst_Semantic::alias_declaration_1()
QVERIFY(decl->isTypedef());
QVERIFY(decl->type().isTypedef());
QVERIFY(decl->type()->isIntegerType());
QVERIFY(decl->type()->asIntegerType());
}
void tst_Semantic::typedef_1()
@@ -502,7 +502,7 @@ void tst_Semantic::typedef_2()
Declaration *typedefPointDecl = doc->globals->memberAt(1)->asDeclaration();
QVERIFY(typedefPointDecl);
QVERIFY(typedefPointDecl->isTypedef());
QVERIFY(typedefPointDecl->type()->isNamedType());
QVERIFY(typedefPointDecl->type()->asNamedType());
QCOMPARE(typedefPointDecl->type()->asNamedType()->name(), _pointStruct->name());
Function *mainFun = doc->globals->memberAt(2)->asFunction();
@@ -527,7 +527,7 @@ void tst_Semantic::typedef_3()
Declaration *typedefPointDecl = doc->globals->memberAt(1)->asDeclaration();
QVERIFY(typedefPointDecl);
QVERIFY(typedefPointDecl->isTypedef());
QVERIFY(typedefPointDecl->type()->isPointerType());
QVERIFY(typedefPointDecl->type()->asPointerType());
QCOMPARE(typedefPointDecl->type()->asPointerType()->elementType()->asClassType(),
_pointStruct);
}
@@ -543,16 +543,16 @@ void tst_Semantic::const_1()
Declaration *decl = doc->globals->memberAt(0)->asDeclaration();
QVERIFY(decl);
QVERIFY(decl->type()->isFunctionType());
QVERIFY(decl->type()->asFunctionType());
Function *funTy = decl->type()->asFunctionType();
QVERIFY(funTy->returnType()->isIntegerType());
QVERIFY(funTy->returnType()->asIntegerType());
QCOMPARE(funTy->argumentCount(), 1);
Argument *arg = funTy->argumentAt(0)->asArgument();
QVERIFY(arg);
QVERIFY(! arg->type().isConst());
QVERIFY(arg->type()->isPointerType());
QVERIFY(arg->type()->asPointerType());
QVERIFY(arg->type()->asPointerType()->elementType().isConst());
QVERIFY(arg->type()->asPointerType()->elementType()->isIntegerType());
QVERIFY(arg->type()->asPointerType()->elementType()->asIntegerType());
}
void tst_Semantic::const_2()
@@ -566,16 +566,16 @@ void tst_Semantic::const_2()
Declaration *decl = doc->globals->memberAt(0)->asDeclaration();
QVERIFY(decl);
QVERIFY(decl->type()->isFunctionType());
QVERIFY(decl->type()->asFunctionType());
Function *funTy = decl->type()->asFunctionType();
QVERIFY(funTy->returnType()->isIntegerType());
QVERIFY(funTy->returnType()->asIntegerType());
QCOMPARE(funTy->argumentCount(), 1);
Argument *arg = funTy->argumentAt(0)->asArgument();
QVERIFY(arg);
QVERIFY(arg->type().isConst());
QVERIFY(arg->type()->isPointerType());
QVERIFY(arg->type()->asPointerType());
QVERIFY(! arg->type()->asPointerType()->elementType().isConst());
QVERIFY(arg->type()->asPointerType()->elementType()->isIntegerType());
QVERIFY(arg->type()->asPointerType()->elementType()->asIntegerType());
}
void tst_Semantic::pointer_to_function_1()