From 1dc9543c97656977916a2beca9a8ebf64b99f02c Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Wed, 26 Aug 2026 14:31:47 +0000 Subject: [PATCH 1/2] Fix #14988: Add relative path to preprocessor dump --- lib/preprocessor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 8fe715db864..11bf0c376a8 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -1067,10 +1067,10 @@ void Preprocessor::dump(std::ostream &out) const for (const simplecpp::MacroUsage ¯oUsage: mMacroUsage) { out << " " << std::endl; for (const simplecpp::IfCond &ifCond: mIfCond) { out << " Date: Thu, 27 Aug 2026 11:02:57 +0000 Subject: [PATCH 2/2] Test --- test/testpreprocessor.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index f1cffe50486..01ae240fd1b 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -386,6 +386,8 @@ class TestPreprocessor : public TestFixture { TEST_CASE(writeLocations); TEST_CASE(pragmaAsm); + + TEST_CASE(dumpPreprocessor); } template @@ -3204,6 +3206,30 @@ class TestPreprocessor : public TestFixture { const char code[] = "#pragma asm\n"; ASSERT_THROW_INTERNAL(getcodeforcfg(settingsDefault, *this, code, "", "test.cpp"), InternalError::SYNTAX); } + + void dumpPreprocessor() { + const char code[] = "#if M == 0\n" + "#endif\n;\n"; + std::vector files; + simplecpp::OutputList outputList; + + Settings settings; + settings.relativePaths = true; + settings.basePaths.emplace_back("/some/path"); + + simplecpp::TokenList tokens1(code, files, "/some/path/test.cpp", {}, &outputList); + Preprocessor preprocessor(tokens1, settings, *this, Standards::Language::CPP); + (void)preprocessor.preprocess("", files, outputList); + (void)preprocessor.reportOutput(outputList, true); + + std::ostringstream ostr; + preprocessor.dump(ostr); + ASSERT_EQUALS( + " \n" + " \n" + " \n", + ostr.str()); + } }; REGISTER_TEST(TestPreprocessor)