From 2db6bf4bdf13b9d3ae1c44b43a91cb74a1a77d45 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Tue, 3 Mar 2026 09:00:42 +0300 Subject: [PATCH] fixed recovering of includes --- src/Utils/SgUtils.cpp | 16 +++++++++++++--- src/Utils/version.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Utils/SgUtils.cpp b/src/Utils/SgUtils.cpp index 82f0c19..cb009ff 100644 --- a/src/Utils/SgUtils.cpp +++ b/src/Utils/SgUtils.cpp @@ -577,10 +577,20 @@ string removeIncludeStatsAndUnparse(SgFile *file, const char *fileName, const ch for (auto& incl : inclByPos.second) inlcude += (renameIncludes ? renameInclude(incl) : incl); - if (st->comments()) - st->setComments((inlcude + st->comments()).c_str()); + //check inserted operators + SgStatement* toInsert = st; + do { + auto lexPrev = toInsert->lexPrev(); + if (lexPrev && lexPrev->variant() > 0 && lexPrev->lineNumber() < 0) + toInsert = lexPrev; + else + break; + } while (true); + + if (toInsert->comments()) + toInsert->setComments((inlcude + toInsert->comments()).c_str()); else - st->addComment(inlcude.c_str()); + toInsert->addComment(inlcude.c_str()); } } diff --git a/src/Utils/version.h b/src/Utils/version.h index 92f77c0..a2b444e 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2465" +#define VERSION_SPF "2466"