From 4a2ae357a2136cc9d152de86ed2e070d117c53ab Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 8 Jun 2019 11:12:34 +0300 Subject: [PATCH] - report implicitly initialized variable in code generator once Vectors are no longer reported several times Previously, warnings were issued per every register --- src/scripting/backend/codegen.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index c0dd7db91..6cada2d36 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -11358,6 +11358,9 @@ ExpEmit FxLocalVariableDeclaration::Emit(VMFunctionBuilder *build) auto& registers = build->Registers[regType]; RegNum = registers.Get(RegCount); + // Check for reused registers and clean them if needed + bool useDirtyRegisters = false; + for (int reg = RegNum, end = RegNum + RegCount; reg < end; ++reg) { if (!registers.IsDirty(reg)) @@ -11365,7 +11368,7 @@ ExpEmit FxLocalVariableDeclaration::Emit(VMFunctionBuilder *build) continue; } - ScriptPosition.Message(MSG_DEBUGMSG, "Implicit initialization of variable %s\n", Name.GetChars()); + useDirtyRegisters = true; switch (regType) { @@ -11390,6 +11393,11 @@ ExpEmit FxLocalVariableDeclaration::Emit(VMFunctionBuilder *build) break; } } + + if (useDirtyRegisters) + { + ScriptPosition.Message(MSG_DEBUGMSG, "Implicit initialization of variable %s", Name.GetChars()); + } } else {