From 63cfc9dda9e0b792388bcb19b0f4c1214c64e457 Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Wed, 22 Nov 2023 19:44:03 +0100 Subject: [PATCH] Avoid using `rawSignature` directly when creating nodes (#1362) Previously, in the CXX frontend, we were supplying the `rawSignature` as code(override) to almost all functions that created nodes. The issue with that is, that this does not respect the `codeInNodes` config option, which might be turned on to save memory. This PR consequently uses the `rawNode` parameter, which forwards setting code and location to the language frontend, which DOES respect the `codeInNodes` option. --- .../cpg/frontends/cxx/DeclarationHandler.kt | 8 +- .../cpg/frontends/cxx/DeclaratorHandler.kt | 33 ++++---- .../cpg/frontends/cxx/ExpressionHandler.kt | 76 ++++++++----------- .../cpg/frontends/cxx/InitializerHandler.kt | 4 +- .../cxx/ParameterDeclarationHandler.kt | 2 +- .../cpg/frontends/cxx/StatementHandler.kt | 36 ++++----- 6 files changed, 75 insertions(+), 84 deletions(-) diff --git a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/DeclarationHandler.kt b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/DeclarationHandler.kt index a371816613..6e54810e29 100644 --- a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/DeclarationHandler.kt +++ b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/DeclarationHandler.kt @@ -81,7 +81,7 @@ class DeclarationHandler(lang: CXXLanguageFrontend) : * done yet. */ private fun handleUsingDirective(using: CPPASTUsingDirective): Declaration { - return newUsingDeclaration(using.rawSignature, using.qualifiedName.toString()) + return newUsingDeclaration(qualifiedName = using.qualifiedName.toString(), rawNode = using) } /** @@ -704,11 +704,7 @@ class DeclarationHandler(lang: CXXLanguageFrontend) : fun handleTranslationUnit(translationUnit: IASTTranslationUnit): TranslationUnitDeclaration { val node = - newTranslationUnitDeclaration( - translationUnit.filePath, - translationUnit.rawSignature, - translationUnit - ) + newTranslationUnitDeclaration(translationUnit.filePath, rawNode = translationUnit) // There might have been errors in the previous translation unit and in any case // we need to reset the scope manager scope to global, to avoid spilling scope errors into diff --git a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/DeclaratorHandler.kt b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/DeclaratorHandler.kt index e66c277079..9d1335c176 100644 --- a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/DeclaratorHandler.kt +++ b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/DeclaratorHandler.kt @@ -117,8 +117,8 @@ class DeclaratorHandler(lang: CXXLanguageFrontend) : ctx.name.toString(), unknownType(), // Type will be filled out later by // handleSimpleDeclaration - ctx.rawSignature, - implicitInitializerAllowed, + implicitInitializerAllowed = implicitInitializerAllowed, + rawNode = ctx ) // Add this declaration to the current scope @@ -142,10 +142,10 @@ class DeclaratorHandler(lang: CXXLanguageFrontend) : name.localName, unknownType(), emptyList(), - ctx.rawSignature, - frontend.locationOf(ctx), - initializer, - true + location = frontend.locationOf(ctx), + initializer = initializer, + implicitInitializerAllowed = true, + rawNode = ctx ) frontend.scopeManager.addDeclaration(declaration) @@ -401,19 +401,24 @@ class DeclaratorHandler(lang: CXXLanguageFrontend) : val recordDeclaration = frontend.scopeManager.currentRecord if (recordDeclaration == null) { // variable - result = newVariableDeclaration(name, unknownType(), ctx.rawSignature, true) + result = + newVariableDeclaration( + name, + unknownType(), + implicitInitializerAllowed = true, + rawNode = ctx + ) } else { // field - val code = ctx.rawSignature result = newFieldDeclaration( name, unknownType(), emptyList(), - code, - frontend.locationOf(ctx), - null, - false, + location = frontend.locationOf(ctx), + initializer = null, + implicitInitializerAllowed = false, + rawNode = ctx ) } @@ -435,7 +440,7 @@ class DeclaratorHandler(lang: CXXLanguageFrontend) : newRecordDeclaration( ctx.name.toString(), kind, - ctx.rawSignature, + rawNode = ctx, ) // Handle C++ classes @@ -483,7 +488,7 @@ class DeclaratorHandler(lang: CXXLanguageFrontend) : private fun handleTemplateTypeParameter( ctx: CPPASTSimpleTypeTemplateParameter ): TypeParameterDeclaration { - return newTypeParameterDeclaration(ctx.rawSignature, ctx.rawSignature, ctx) + return newTypeParameterDeclaration(ctx.rawSignature, rawNode = ctx) } private fun processMembers(ctx: IASTCompositeTypeSpecifier) { diff --git a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/ExpressionHandler.kt b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/ExpressionHandler.kt index 06f5b1ae2f..2af62aaa41 100644 --- a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/ExpressionHandler.kt +++ b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/ExpressionHandler.kt @@ -161,18 +161,17 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : } val referencedType = frontend.typeOf(ctx.typeId) - return newTypeIdExpression(operatorCode, type, referencedType, ctx.rawSignature) + return newTypeIdExpression(operatorCode, type, referencedType, rawNode = ctx) } private fun handleArraySubscriptExpression(ctx: IASTArraySubscriptExpression): Expression { - val arraySubsExpression = newSubscriptExpression(ctx.rawSignature) + val arraySubsExpression = newSubscriptExpression(rawNode = ctx) handle(ctx.arrayExpression)?.let { arraySubsExpression.arrayExpression = it } handle(ctx.argument)?.let { arraySubsExpression.subscriptExpression = it } return arraySubsExpression } private fun handleNewExpression(ctx: CPPASTNewExpression): Expression { - val code = ctx.rawSignature val t = frontend.typeOf(ctx.typeId) val init = ctx.initializer @@ -180,7 +179,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : return if (ctx.isArrayAllocation) { t.array() val arrayMods = (ctx.typeId.abstractDeclarator as IASTArrayDeclarator).arrayModifiers - val arrayCreate = newNewArrayExpression(code) + val arrayCreate = newNewArrayExpression(rawNode = ctx) arrayCreate.type = t for (arrayMod in arrayMods) { val constant = handle(arrayMod.constantExpression) @@ -192,7 +191,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : arrayCreate } else { // new returns a pointer, so we need to reference the type by pointer - val newExpression = newNewExpression(code, t.pointer(), ctx) + val newExpression = newNewExpression(type = t.pointer(), rawNode = ctx) val declSpecifier = ctx.typeId.declSpecifier as? IASTNamedTypeSpecifier // Resolve possible templates if (declSpecifier?.name is CPPASTTemplateId) { @@ -270,7 +269,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : } private fun handleDeleteExpression(ctx: CPPASTDeleteExpression): DeleteExpression { - val deleteExpression = newDeleteExpression(ctx.rawSignature) + val deleteExpression = newDeleteExpression(rawNode = ctx) for (name in ctx.implicitDestructorNames) { log.debug("Implicit constructor name {}", name) } @@ -279,7 +278,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : } private fun handleCastExpression(ctx: IASTCastExpression): Expression { - val castExpression = newCastExpression(ctx.rawSignature) + val castExpression = newCastExpression(rawNode = ctx) castExpression.expression = handle(ctx.operand) ?: ProblemExpression("could not parse inner expression") castExpression.setCastOperator(ctx.operator) @@ -314,7 +313,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : base, unknownType(), if (ctx.isPointerDereference) "->" else ".", - ctx.rawSignature + rawNode = ctx ) } @@ -371,7 +370,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : operatorCode, ctx.isPostfixOperator, !ctx.isPostfixOperator, - ctx.rawSignature + rawNode = ctx ) if (input != null) { unaryOperator.input = input @@ -386,7 +385,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : reference is MemberExpression -> { val baseType = reference.base.type.root assert(baseType !is SecondOrderType) - callExpression = newMemberCallExpression(reference, code = ctx.rawSignature) + callExpression = newMemberCallExpression(reference, rawNode = ctx) if ( (ctx.functionNameExpression as? IASTFieldReference)?.fieldName is CPPASTTemplateId @@ -408,10 +407,10 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : reference is BinaryOperator && (reference.operatorCode == ".*" || reference.operatorCode == "->*") -> { // This is a function pointer call to a class method. We keep this as a binary - // operator - // with the .* or ->* operator code, so that we can resolve this later in the + // operator with the .* or ->* operator code, so that we can resolve this later in + // the // FunctionPointerCallResolver - callExpression = newMemberCallExpression(reference, code = ctx.rawSignature) + callExpression = newMemberCallExpression(reference, rawNode = ctx) } reference is UnaryOperator && reference.operatorCode == "*" -> { // Classic C-style function pointer call -> let's extract the target @@ -424,7 +423,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : .templateName .toString() val ref = newReference(name) - callExpression = newCallExpression(ref, name, ctx.rawSignature, true) + callExpression = newCallExpression(ref, name, template = true, rawNode = ctx) getTemplateArguments( (ctx.functionNameExpression as IASTIdExpression).name as CPPASTTemplateId ) @@ -440,7 +439,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : } else -> { callExpression = - newCallExpression(reference, reference?.name, ctx.rawSignature, false) + newCallExpression(reference, reference?.name, template = false, rawNode = ctx) } } @@ -462,11 +461,11 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : // this expression could actually be a field / member expression, but somehow CDT only // recognizes them as a member expression if it has an explicit 'this' // TODO: handle this? convert the declared reference expression into a member expression? - return newReference(ctx.name.toString(), unknownType(), ctx.rawSignature) + return newReference(ctx.name.toString(), unknownType(), rawNode = ctx) } private fun handleExpressionList(exprList: IASTExpressionList): ExpressionList { - val expressionList = newExpressionList(exprList.rawSignature) + val expressionList = newExpressionList(rawNode = exprList) for (expr in exprList.expressions) { handle(expr)?.let { expressionList.addExpression(it) } } @@ -494,7 +493,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : else -> String(ASTStringUtil.getBinaryOperatorString(ctx)) } - val binaryOperator = newBinaryOperator(operatorCode, ctx.rawSignature) + val binaryOperator = newBinaryOperator(operatorCode, rawNode = ctx) val lhs = handle(ctx.operand1) ?: newProblemExpression("could not parse lhs") val rhs = if (ctx.operand2 != null) { @@ -506,13 +505,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : if (lhs is CastExpression && frontend.config.inferenceConfiguration.guessCastExpressions) { // this really is a combination of a cast and a unary operator - val op = - newUnaryOperator( - operatorCode, - postfix = true, - prefix = false, - code = ctx.rawSignature - ) + val op = newUnaryOperator(operatorCode, postfix = true, prefix = false, rawNode = ctx) op.input = rhs op.location = frontend.locationOf(ctx.operand2) lhs.expression = op @@ -548,18 +541,18 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : return when (ctx.kind) { lk_integer_constant -> handleIntegerLiteral(ctx) lk_float_constant -> handleFloatLiteral(ctx) - lk_char_constant -> newLiteral(ctx.value[1], primitiveType("char"), ctx.rawSignature) + lk_char_constant -> newLiteral(ctx.value[1], primitiveType("char"), rawNode = ctx) lk_string_literal -> newLiteral( String(ctx.value.slice(IntRange(1, ctx.value.size - 2)).toCharArray()), primitiveType("char").array(), - ctx.rawSignature + rawNode = ctx ) lk_this -> handleThisLiteral(ctx) - lk_true -> newLiteral(true, primitiveType("bool"), ctx.rawSignature) - lk_false -> newLiteral(false, primitiveType("bool"), ctx.rawSignature) - lk_nullptr -> newLiteral(null, objectType("nullptr_t"), ctx.rawSignature) - else -> newLiteral(String(ctx.value), unknownType(), ctx.rawSignature) + lk_true -> newLiteral(true, primitiveType("bool"), rawNode = ctx) + lk_false -> newLiteral(false, primitiveType("bool"), rawNode = ctx) + lk_nullptr -> newLiteral(null, objectType("nullptr_t"), rawNode = ctx) + else -> newLiteral(String(ctx.value), unknownType(), rawNode = ctx) } } @@ -578,8 +571,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : oneLhs = handle(des.subscriptExpression) } is CPPASTFieldDesignator -> { - oneLhs = - newReference(des.name.toString(), unknownType(), des.getRawSignature()) + oneLhs = newReference(des.name.toString(), unknownType(), rawNode = des) } is CPPASTArrayRangeDesignator -> { oneLhs = @@ -606,7 +598,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : } } - val die = newDesignatedInitializerExpression(ctx.rawSignature) + val die = newDesignatedInitializerExpression(rawNode = ctx) die.lhs = lhs die.rhs = rhs @@ -628,8 +620,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : oneLhs = handle(des.subscriptExpression) } is CPPASTFieldDesignator -> { - oneLhs = - newReference(des.name.toString(), unknownType(), des.getRawSignature()) + oneLhs = newReference(des.name.toString(), unknownType(), rawNode = des) } is CPPASTArrayRangeDesignator -> { oneLhs = @@ -656,7 +647,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : } } - val die = newDesignatedInitializerExpression(ctx.rawSignature) + val die = newDesignatedInitializerExpression(rawNode = ctx) die.lhs = lhs die.rhs = rhs @@ -754,7 +745,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : } ) - return newLiteral(numberValue, type, ctx.rawSignature) + return newLiteral(numberValue, type, rawNode = ctx) } catch (ex: NumberFormatException) { // It could be that we cannot parse the literal, in this case we return an error return ProblemExpression("could not parse literal: ${ex.message}") @@ -766,15 +757,14 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : return try { when (suffix) { - "f" -> newLiteral(strippedValue.toFloat(), primitiveType("float"), ctx.rawSignature) + "f" -> newLiteral(strippedValue.toFloat(), primitiveType("float"), rawNode = ctx) "l" -> newLiteral( strippedValue.toBigDecimal(), primitiveType("long double"), - ctx.rawSignature + rawNode = ctx ) - else -> - newLiteral(strippedValue.toDouble(), primitiveType("double"), ctx.rawSignature) + else -> newLiteral(strippedValue.toDouble(), primitiveType("double"), rawNode = ctx) } } catch (ex: NumberFormatException) { // It could be that we cannot parse the literal, in this case we return an error @@ -794,7 +784,7 @@ class ExpressionHandler(lang: CXXLanguageFrontend) : // We do want to make sure that the type of the expression is at least a pointer. val pointerType = recordType.pointer() - return newReference("this", pointerType, ctx.rawSignature, ctx) + return newReference("this", pointerType, rawNode = ctx) } private val IASTLiteralExpression.valueWithSuffix: Pair diff --git a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/InitializerHandler.kt b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/InitializerHandler.kt index dd7be1da52..d2c4cdcb8f 100644 --- a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/InitializerHandler.kt +++ b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/InitializerHandler.kt @@ -57,7 +57,7 @@ class InitializerHandler(lang: CXXLanguageFrontend) : } private fun handleConstructorInitializer(ctx: CPPASTConstructorInitializer): Expression { - val constructExpression = newConstructExpression(ctx.rawSignature) + val constructExpression = newConstructExpression(rawNode = ctx) constructExpression.type = (frontend.declaratorHandler.lastNode as? VariableDeclaration)?.type ?: unknownType() @@ -79,7 +79,7 @@ class InitializerHandler(lang: CXXLanguageFrontend) : val targetType = (frontend.declaratorHandler.lastNode as? ValueDeclaration)?.type ?: unknownType() - val expression = newInitializerListExpression(targetType, ctx.rawSignature) + val expression = newInitializerListExpression(targetType, rawNode = ctx) for (clause in ctx.clauses) { frontend.expressionHandler.handle(clause)?.let { diff --git a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/ParameterDeclarationHandler.kt b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/ParameterDeclarationHandler.kt index 79e0c240f2..536e094743 100644 --- a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/ParameterDeclarationHandler.kt +++ b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/ParameterDeclarationHandler.kt @@ -52,7 +52,7 @@ class ParameterDeclarationHandler(lang: CXXLanguageFrontend) : val type = frontend.typeOf(ctx.declarator, ctx.declSpecifier) val paramVariableDeclaration = - newParameterDeclaration(ctx.declarator.name.toString(), type, false, ctx.rawSignature) + newParameterDeclaration(ctx.declarator.name.toString(), type, false, rawNode = ctx) // Add default values if (ctx.declarator.initializer != null) { diff --git a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/StatementHandler.kt b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/StatementHandler.kt index dc759a1f01..b98a0c3d9f 100644 --- a/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/StatementHandler.kt +++ b/cpg-language-cxx/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/StatementHandler.kt @@ -88,7 +88,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleEmptyStatement(nullStatement: IASTNullStatement): EmptyStatement { - return newEmptyStatement(nullStatement.rawSignature) + return newEmptyStatement(rawNode = nullStatement) } private fun handleTryBlockStatement(tryBlockStatement: CPPASTTryBlockStatement): TryStatement { @@ -106,7 +106,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleCatchHandler(catchHandler: ICPPASTCatchHandler): CatchClause { - val catchClause = newCatchClause(catchHandler.rawSignature) + val catchClause = newCatchClause(rawNode = catchHandler) frontend.scopeManager.enterScope(catchClause) val body = frontend.statementHandler.handle(catchHandler.catchBody) @@ -127,7 +127,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleIfStatement(ctx: IASTIfStatement): IfStatement { - val statement = newIfStatement(ctx.rawSignature) + val statement = newIfStatement(rawNode = ctx) frontend.scopeManager.enterScope(statement) @@ -157,14 +157,14 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleLabelStatement(ctx: IASTLabelStatement): LabelStatement { - val statement = newLabelStatement(ctx.rawSignature) + val statement = newLabelStatement(rawNode = ctx) statement.subStatement = handle(ctx.nestedStatement) statement.label = ctx.name.toString() return statement } private fun handleGotoStatement(ctx: IASTGotoStatement): GotoStatement { - val statement = newGotoStatement(ctx.rawSignature) + val statement = newGotoStatement(rawNode = ctx) val assigneeTargetLabel = BiConsumer { _: Any, to: Node -> statement.targetLabel = to as LabelStatement } @@ -189,7 +189,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleWhileStatement(ctx: IASTWhileStatement): WhileStatement { - val statement = newWhileStatement(ctx.rawSignature) + val statement = newWhileStatement(rawNode = ctx) frontend.scopeManager.enterScope(statement) @@ -211,7 +211,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleDoStatement(ctx: IASTDoStatement): DoStatement { - val statement = newDoStatement(ctx.rawSignature) + val statement = newDoStatement(rawNode = ctx) frontend.scopeManager.enterScope(statement) statement.condition = frontend.expressionHandler.handle(ctx.condition) statement.statement = handle(ctx.body) @@ -220,7 +220,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleForStatement(ctx: IASTForStatement): ForStatement { - val statement = newForStatement(ctx.rawSignature) + val statement = newForStatement(rawNode = ctx) frontend.scopeManager.enterScope(statement) @@ -256,7 +256,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleForEachStatement(ctx: CPPASTRangeBasedForStatement): ForEachStatement { - val statement = newForEachStatement(ctx.rawSignature) + val statement = newForEachStatement(rawNode = ctx) frontend.scopeManager.enterScope(statement) val decl = frontend.declarationHandler.handle(ctx.declaration) val `var` = newDeclarationStatement(decl?.code) @@ -270,12 +270,12 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleBreakStatement(ctx: IASTBreakStatement): BreakStatement { - return newBreakStatement(ctx.rawSignature) + return newBreakStatement(rawNode = ctx) // C++ has no labeled break } private fun handleContinueStatement(ctx: IASTContinueStatement): ContinueStatement { - return newContinueStatement(ctx.rawSignature) + return newContinueStatement(rawNode = ctx) // C++ has no labeled continue } @@ -292,9 +292,9 @@ class StatementHandler(lang: CXXLanguageFrontend) : private fun handleDeclarationStatement(ctx: IASTDeclarationStatement): DeclarationStatement { return if (ctx.declaration is IASTASMDeclaration) { - newASMDeclarationStatement(ctx.rawSignature) + newASMDeclarationStatement(rawNode = ctx) } else { - val declarationStatement = newDeclarationStatement(ctx.rawSignature) + val declarationStatement = newDeclarationStatement(rawNode = ctx) val declaration = frontend.declarationHandler.handle(ctx.declaration) if (declaration is DeclarationSequence) { declarationStatement.declarations = declaration.asList() @@ -306,7 +306,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleReturnStatement(ctx: IASTReturnStatement): ReturnStatement { - val returnStatement = newReturnStatement(ctx.rawSignature) + val returnStatement = newReturnStatement(rawNode = ctx) // Parse the return value if (ctx.returnValue != null) { @@ -317,7 +317,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleCompoundStatement(ctx: IASTCompoundStatement): Block { - val block = newBlock(ctx.rawSignature) + val block = newBlock(rawNode = ctx) frontend.scopeManager.enterScope(block) @@ -334,7 +334,7 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleSwitchStatement(ctx: IASTSwitchStatement): SwitchStatement { - val switchStatement = newSwitchStatement(ctx.rawSignature) + val switchStatement = newSwitchStatement(rawNode = ctx) frontend.scopeManager.enterScope(switchStatement) @@ -361,12 +361,12 @@ class StatementHandler(lang: CXXLanguageFrontend) : } private fun handleCaseStatement(ctx: IASTCaseStatement): CaseStatement { - val caseStatement = newCaseStatement(ctx.rawSignature) + val caseStatement = newCaseStatement(rawNode = ctx) caseStatement.caseExpression = frontend.expressionHandler.handle(ctx.expression) return caseStatement } private fun handleDefaultStatement(ctx: IASTDefaultStatement): DefaultStatement { - return newDefaultStatement(ctx.rawSignature) + return newDefaultStatement(rawNode = ctx) } }