From 8c2bb5ef5654ac216fc30d035588ab4669baa5c1 Mon Sep 17 00:00:00 2001 From: Alexander Kuechler Date: Wed, 6 Nov 2024 11:40:49 +0100 Subject: [PATCH] LLVM update testUndefInsertvalue --- .../llvm/LLVMIRLanguageFrontendTest.kt | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cpg-language-llvm/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/llvm/LLVMIRLanguageFrontendTest.kt b/cpg-language-llvm/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/llvm/LLVMIRLanguageFrontendTest.kt index fcad78bec7..90e3785243 100644 --- a/cpg-language-llvm/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/llvm/LLVMIRLanguageFrontendTest.kt +++ b/cpg-language-llvm/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/llvm/LLVMIRLanguageFrontendTest.kt @@ -665,17 +665,22 @@ class LLVMIRLanguageFrontendTest { assertNotNull(foo) assertEquals("literal_i32_i8", foo.type.typeName) - val record = (foo.type as? ObjectType)?.recordDeclaration + val fooType = foo.type + assertIs(fooType) + val record = fooType.recordDeclaration assertNotNull(record) assertEquals(2, record.fields.size) - val declStatement = foo.bodyOrNull() - assertNotNull(declStatement) + val declarationStatement = foo.bodyOrNull() + assertNotNull(declarationStatement) - val varDecl = declStatement.singleDeclaration as VariableDeclaration - assertLocalName("a", varDecl) - assertEquals("literal_i32_i8", varDecl.type.typeName) - val args = (varDecl.initializer as ConstructExpression).arguments + val varDeclaration = declarationStatement.singleDeclaration + assertIs(varDeclaration) + assertLocalName("a", varDeclaration) + assertEquals("literal_i32_i8", varDeclaration.type.typeName) + val initializer = varDeclaration.initializer + assertIs(initializer) + val args = initializer.arguments assertEquals(2, args.size) assertLiteralValue(100L, args[0]) assertLiteralValue(null, args[1]) @@ -696,10 +701,12 @@ class LLVMIRLanguageFrontendTest { assertEquals("=", assign.operatorCode) assertEquals(1, assign.lhs.size) assertEquals(1, assign.rhs.size) - assertLocalName("b", (assign.lhs.first() as MemberExpression).base) - assertEquals(".", (assign.lhs.first() as MemberExpression).operatorCode) - assertLocalName("field_1", assign.lhs.first() as MemberExpression) - assertEquals(7L, (assign.rhs.first() as Literal<*>).value as Long) + val assignLhs = assign.lhs.first() + assertIs(assignLhs) + assertLocalName("b", assignLhs.base) + assertEquals(".", assignLhs.operatorCode) + assertLocalName("field_1", assignLhs) + assertLiteralValue(7L, assign.rhs.first()) } @Test