From 50fb13bdf03cbe859d5b9be2eb54b87cfbf9af4b Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 19 Nov 2025 14:06:33 +0100 Subject: [PATCH] got rid of test-only `Directive` constructor --- lib/preprocessor.cpp | 6 ------ lib/preprocessor.h | 1 - test/testunusedvar.cpp | 5 ++++- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 91b2e1f9ebb..b315766f8e6 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -51,12 +51,6 @@ Directive::Directive(const simplecpp::Location & _loc, std::string _str) : str(std::move(_str)) {} -Directive::Directive(std::string _file, const int _linenr, std::string _str) : - file(std::move(_file)), - linenr(_linenr), - str(std::move(_str)) -{} - Directive::DirectiveToken::DirectiveToken(const simplecpp::Token & _tok) : line(_tok.location.line), column(_tok.location.col), diff --git a/lib/preprocessor.h b/lib/preprocessor.h index 4f64cc19100..562d91fe877 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -69,7 +69,6 @@ struct CPPCHECKLIB Directive { /** record a directive (possibly filtering src) */ Directive(const simplecpp::Location & _loc, std::string _str); - Directive(std::string _file, int _linenr, std::string _str); }; class CPPCHECKLIB RemarkComment { diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 231e64e1fde..97eb8747a8d 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -1632,7 +1632,10 @@ class TestUnusedVar : public TestFixture { void structmember15() { // #3088 std::list directives; - directives.emplace_back("test.cpp", 1, "#pragma pack(1)"); + std::vector f = { "test.cpp" }; + simplecpp::Location loc(f); + loc.line = 1; + directives.emplace_back(loc, "#pragma pack(1)"); checkStructMemberUsage("\nstruct Foo { int x; int y; };", dinit(CheckStructMemberUsageOptions, $.directives = &directives)); ASSERT_EQUALS("", errout_str()); }