diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 293ea793a..12eed1044 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -662,7 +662,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string CheckUnusedFunctions checkUnusedFunctions(nullptr, nullptr, nullptr); try { - Preprocessor preprocessor(mSettings, mSettings.nomsg, this); + Preprocessor preprocessor(mSettings, this); std::set configurations; simplecpp::OutputList outputList; @@ -739,7 +739,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string } // Parse comments and then remove them - preprocessor.inlineSuppressions(tokens1); + preprocessor.inlineSuppressions(tokens1, mSettings.nomsg); if (mSettings.dump || !mSettings.addons.empty()) { mSettings.nomsg.dump(dumpProlog); } diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 1e3c8ef9b..377d64518 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -64,7 +64,7 @@ Directive::Directive(std::string _file, const int _linenr, const std::string &_s char Preprocessor::macroChar = char(1); -Preprocessor::Preprocessor(const Settings& settings, Suppressions &suppressions, ErrorLogger *errorLogger) : mSettings(settings), mSuppressions(suppressions), mErrorLogger(errorLogger) +Preprocessor::Preprocessor(const Settings& settings, ErrorLogger *errorLogger) : mSettings(settings), mErrorLogger(errorLogger) {} Preprocessor::~Preprocessor() @@ -184,15 +184,15 @@ static void addinlineSuppressions(const simplecpp::TokenList &tokens, const Sett } } -void Preprocessor::inlineSuppressions(const simplecpp::TokenList &tokens) +void Preprocessor::inlineSuppressions(const simplecpp::TokenList &tokens, Suppressions &suppressions) { if (!mSettings.inlineSuppressions) return; std::list err; - ::addinlineSuppressions(tokens, mSettings, mSuppressions, err); + ::addinlineSuppressions(tokens, mSettings, suppressions, err); for (std::map::const_iterator it = mTokenLists.cbegin(); it != mTokenLists.cend(); ++it) { if (it->second) - ::addinlineSuppressions(*it->second, mSettings, mSuppressions, err); + ::addinlineSuppressions(*it->second, mSettings, suppressions, err); } for (const BadInlineSuppression &bad : err) { error(bad.location.file(), bad.location.line, bad.errmsg); @@ -752,14 +752,15 @@ std::string Preprocessor::getcode(const simplecpp::TokenList &tokens1, const std return ret.str(); } -std::string Preprocessor::getcode(const std::string &filedata, const std::string &cfg, const std::string &filename) +std::string Preprocessor::getcode(const std::string &filedata, const std::string &cfg, const std::string &filename, Suppressions *inlineSuppression) { simplecpp::OutputList outputList; std::vector files; std::istringstream istr(filedata); simplecpp::TokenList tokens1(istr, files, Path::simplifyPath(filename), &outputList); - inlineSuppressions(tokens1); + if (inlineSuppression) + inlineSuppressions(tokens1, *inlineSuppression); tokens1.removeComments(); removeComments(); setDirectives(tokens1); @@ -833,41 +834,26 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, const // Report that include is missing void Preprocessor::missingInclude(const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType) { - if (!mSettings.checks.isEnabled(Checks::missingInclude)) + if (!mSettings.checks.isEnabled(Checks::missingInclude) || !mErrorLogger) return; - std::string fname = Path::fromNativeSeparators(filename); - std::string errorId = (headerType==SystemHeader) ? "missingIncludeSystem" : "missingInclude"; - Suppressions::ErrorMessage errorMessage; - errorMessage.errorId = errorId; - errorMessage.setFileName(std::move(fname)); - errorMessage.lineNumber = linenr; - if (mSuppressions.isSuppressed(errorMessage)) - return; - - if (mErrorLogger) { - std::list locationList; - if (!filename.empty()) { - ErrorMessage::FileLocation loc; - loc.line = linenr; - loc.setfile(Path::toNativeSeparators(filename)); - locationList.push_back(std::move(loc)); - } - ErrorMessage errmsg(std::move(locationList), mFile0, Severity::information, - (headerType==SystemHeader) ? - "Include file: <" + header + "> not found. Please note: Cppcheck does not need standard library headers to get proper results." : - "Include file: \"" + header + "\" not found.", - std::move(errorId), - Certainty::normal); - mErrorLogger->reportErr(errmsg); + std::list locationList; + if (!filename.empty()) { + locationList.emplace_back(filename, linenr); } + ErrorMessage errmsg(std::move(locationList), mFile0, Severity::information, + (headerType==SystemHeader) ? + "Include file: <" + header + "> not found. Please note: Cppcheck does not need standard library headers to get proper results." : + "Include file: \"" + header + "\" not found.", + (headerType==SystemHeader) ? "missingIncludeSystem" : "missingInclude", + Certainty::normal); + mErrorLogger->reportErr(errmsg); } void Preprocessor::getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) { Settings settings2(*settings); - Suppressions supressions2; - Preprocessor preprocessor(settings2, supressions2, errorLogger); + Preprocessor preprocessor(settings2, errorLogger); preprocessor.missingInclude(emptyString, 1, emptyString, UserHeader); preprocessor.missingInclude(emptyString, 1, emptyString, SystemHeader); preprocessor.error(emptyString, 1, "#error message"); // #error .. diff --git a/lib/preprocessor.h b/lib/preprocessor.h index de2973ba1..240a403d1 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -84,10 +84,10 @@ public: /** character that is inserted in expanded macros */ static char macroChar; - explicit Preprocessor(const Settings& settings, Suppressions &suppressions, ErrorLogger *errorLogger = nullptr); + explicit Preprocessor(const Settings& settings, ErrorLogger *errorLogger = nullptr); virtual ~Preprocessor(); - void inlineSuppressions(const simplecpp::TokenList &tokens); + void inlineSuppressions(const simplecpp::TokenList &tokens, Suppressions &suppressions); void setDirectives(const simplecpp::TokenList &tokens); void setDirectives(const std::list &directives) { @@ -147,11 +147,15 @@ public: /** * Get preprocessed code for a given configuration + * + * Note: for testing only. + * * @param filedata file data including preprocessing 'if', 'define', etc * @param cfg configuration to read out * @param filename name of source file + * @param inlineSuppression the inline suppressions */ - std::string getcode(const std::string &filedata, const std::string &cfg, const std::string &filename); + std::string getcode(const std::string &filedata, const std::string &cfg, const std::string &filename, Suppressions *inlineSuppression = nullptr); /** * Calculate HASH. Using toolinfo, tokens1, filedata. @@ -189,7 +193,6 @@ private: void error(const std::string &filename, unsigned int linenr, const std::string &msg); const Settings& mSettings; - Suppressions &mSuppressions; ErrorLogger *mErrorLogger; /** list of all directives met while preprocessing file */ diff --git a/test/cli/test-other.py b/test/cli/test-other.py index 80dd63180..29db8ea0c 100644 --- a/test/cli/test-other.py +++ b/test/cli/test-other.py @@ -45,4 +45,19 @@ def test_missing_include_check_config(tmpdir): __test_missing_include_check_config(tmpdir, False) def test_missing_include_check_config_j(tmpdir): - __test_missing_include_check_config(tmpdir, True) \ No newline at end of file + __test_missing_include_check_config(tmpdir, True) + +def test_missing_include_inline_suppr(tmpdir): + test_file = os.path.join(tmpdir, 'test.c') + with open(test_file, 'wt') as f: + f.write(""" + // cppcheck-suppress missingInclude + #include "missing.h" + // cppcheck-suppress missingIncludeSystem + #include + """) + + args = ['--enable=missingInclude', '--inline-suppr', test_file] + + _, _, stderr = cppcheck(args) + assert stderr == '' \ No newline at end of file diff --git a/test/testclass.cpp b/test/testclass.cpp index ba58c5f92..2f672b91f 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -265,7 +265,7 @@ private: Settings settings; settings.severity.enable(Severity::warning); - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); // Tokenize.. Tokenizer tokenizer(&settings, this, &preprocessor); @@ -371,7 +371,7 @@ private: // Clear the error log errout.str(""); - Preprocessor preprocessor(settings0, settings0.nomsg, nullptr); + Preprocessor preprocessor(settings0); // Tokenize.. Tokenizer tokenizer(&settings0, this, &preprocessor); @@ -525,7 +525,7 @@ private: // Clear the error log errout.str(""); - Preprocessor preprocessor(settings1, settings1.nomsg, nullptr); + Preprocessor preprocessor(settings1); // Tokenize.. Tokenizer tokenizer(&settings1, this, &preprocessor); @@ -688,7 +688,7 @@ private: // Clear the error log errout.str(""); - Preprocessor preprocessor(settings0, settings0.nomsg, nullptr); + Preprocessor preprocessor(settings0); // Tokenize.. Tokenizer tokenizer(&settings0, this, &preprocessor); @@ -1137,7 +1137,7 @@ private: // Clear the error log errout.str(""); - Preprocessor preprocessor(settings0, settings0.nomsg, nullptr); + Preprocessor preprocessor(settings0); // Tokenize.. Tokenizer tokenizer(&settings0, this, &preprocessor); @@ -1613,7 +1613,7 @@ private: // Clear the error log errout.str(""); - Preprocessor preprocessor(settings1, settings1.nomsg, nullptr); + Preprocessor preprocessor(settings1); // Tokenize.. Tokenizer tokenizer(&settings1, this, &preprocessor); @@ -2577,7 +2577,7 @@ private: settings0.certainty.setEnabled(Certainty::inconclusive, inconclusive); settings0.severity.enable(Severity::warning); - Preprocessor preprocessor(settings0, settings0.nomsg, nullptr); + Preprocessor preprocessor(settings0); // Tokenize.. Tokenizer tokenizer(&settings0, this, &preprocessor); @@ -2896,11 +2896,11 @@ private: checkNoMemset_(file, line, code, settings); } - void checkNoMemset_(const char* file, int line, const char code[], Settings &settings) { + void checkNoMemset_(const char* file, int line, const char code[], const Settings &settings) { // Clear the error log errout.str(""); - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); // Tokenize.. Tokenizer tokenizer(&settings, this, &preprocessor); @@ -3533,7 +3533,7 @@ private: // Clear the error log errout.str(""); - Preprocessor preprocessor(settings1, settings1.nomsg, nullptr); + Preprocessor preprocessor(settings1); // Tokenize.. Tokenizer tokenizer(&settings1, this, &preprocessor); @@ -3573,7 +3573,7 @@ private: s = &settings0; s->certainty.setEnabled(Certainty::inconclusive, inconclusive); - Preprocessor preprocessor(*s, s->nomsg, nullptr); + Preprocessor preprocessor(*s); // Tokenize.. Tokenizer tokenizer(s, this, &preprocessor); @@ -7254,7 +7254,7 @@ private: // Check.. settings0.certainty.setEnabled(Certainty::inconclusive, true); - Preprocessor preprocessor(settings0, settings0.nomsg, nullptr); + Preprocessor preprocessor(settings0); // Tokenize.. Tokenizer tokenizer(&settings0, this, &preprocessor); @@ -7292,7 +7292,7 @@ private: Settings settings; settings.severity.enable(Severity::performance); - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); // Tokenize.. Tokenizer tokenizer(&settings, this, &preprocessor); @@ -7506,7 +7506,7 @@ private: // Clear the error log errout.str(""); - Preprocessor preprocessor(settings0, settings0.nomsg, nullptr); + Preprocessor preprocessor(settings0); // Tokenize.. Tokenizer tokenizer(&settings0, this, &preprocessor); @@ -7624,7 +7624,7 @@ private: settings.severity.enable(Severity::warning); settings.certainty.setEnabled(Certainty::inconclusive, inconclusive); - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); // Tokenize.. Tokenizer tokenizer(&settings, this, &preprocessor); @@ -7973,7 +7973,7 @@ private: Settings settings; settings.severity.enable(Severity::style); - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); // Tokenize.. Tokenizer tokenizer(&settings, this, &preprocessor); @@ -8151,7 +8151,7 @@ private: settings.safeChecks.classes = true; settings.severity.enable(Severity::warning); - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); // Tokenize.. Tokenizer tokenizer(&settings, this, &preprocessor); @@ -8174,7 +8174,7 @@ private: // Clear the error log errout.str(""); - Preprocessor preprocessor(settings1, settings1.nomsg, nullptr); + Preprocessor preprocessor(settings1); // Tokenize.. Tokenizer tokenizer(&settings1, this, &preprocessor); @@ -8373,7 +8373,7 @@ private: // Clear the error log errout.str(""); - Preprocessor preprocessor(settings1, settings1.nomsg, nullptr); + Preprocessor preprocessor(settings1); // Tokenize.. Tokenizer tokenizer(&settings1, this, &preprocessor); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 0610a9a75..2e5afa951 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -155,7 +155,7 @@ private: std::map filedata; simplecpp::preprocess(tokens2, tokens1, files, filedata, simplecpp::DUI()); - Preprocessor preprocessor(*settings, settings->nomsg, nullptr); + Preprocessor preprocessor(*settings); preprocessor.setDirectives(tokens1); // Tokenizer.. diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 60930028e..f252d564b 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -288,7 +288,7 @@ private: std::string checkCodeInternal_(const std::string &code, const char* filename, const char* file, int line) { errout.str(""); - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); // tokenize.. Tokenizer tokenizer(&settings, this, &preprocessor); diff --git a/test/testother.cpp b/test/testother.cpp index f4278a09c..320279ff6 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -307,7 +307,7 @@ private: settings->certainty.setEnabled(Certainty::inconclusive, inconclusive); settings->verbose = verbose; - Preprocessor preprocessor(*settings, settings->nomsg, nullptr); + Preprocessor preprocessor(*settings); // Tokenize.. Tokenizer tokenizer(settings, this, &preprocessor); @@ -347,7 +347,7 @@ private: std::map filedata; simplecpp::preprocess(tokens2, tokens1, files, filedata, simplecpp::DUI()); - Preprocessor preprocessor(*settings, settings->nomsg, nullptr); + Preprocessor preprocessor(*settings); preprocessor.setDirectives(tokens1); // Tokenizer.. @@ -1572,7 +1572,7 @@ private: settings.severity.enable(Severity::style); settings.standards.cpp = Standards::CPP03; // #5560 - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); // Tokenize.. Tokenizer tokenizerCpp(&settings, this, &preprocessor); @@ -1778,7 +1778,7 @@ private: settings.certainty.setEnabled(Certainty::inconclusive, inconclusive); settings.platform.defaultSign = 's'; - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); // Tokenize.. Tokenizer tokenizer(&settings, this, &preprocessor); diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 96e0efedf..7e9a3d0dc 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -45,7 +45,7 @@ class TestPreprocessor : public TestFixture { public: TestPreprocessor() : TestFixture("TestPreprocessor") - , preprocessor0(settings0, settings0.nomsg, this) { + , preprocessor0(settings0, this) { settings0.severity.enable(Severity::information); } @@ -63,7 +63,7 @@ public: if (errorLogger) { Settings settings; - Preprocessor p(settings, settings.nomsg, errorLogger); + Preprocessor p(settings, errorLogger); p.reportOutput(outputList, true); } @@ -202,7 +202,7 @@ private: TEST_CASE(invalid_define_2); // #4036 - hang for: '#define () {(int f(x) }' // inline suppression, missingInclude/missingIncludeSystem - TEST_CASE(inline_suppression_for_missing_include); + TEST_CASE(inline_suppressions); // Using -D to predefine symbols TEST_CASE(predefine1); @@ -295,7 +295,7 @@ private: settings.userDefines = arg + 2; if (arg && std::strncmp(arg,"-U",2)==0) settings.userUndefs.insert(arg+2); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); std::vector files; std::istringstream istr(filedata); simplecpp::TokenList tokens(istr,files); @@ -361,7 +361,7 @@ private: errout.str(""); Settings settings; settings.userDefines = "__cplusplus"; - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); const std::string code("#error hello world!\n"); preprocessor.getcode(code, "X", "test.c"); ASSERT_EQUALS("[test.c:1]: (error) #error hello world!\n", errout.str()); @@ -374,7 +374,7 @@ private: errout.str(""); Settings settings; settings.userDefines = "TEST"; - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); const std::string code("#file \"ab.h\"\n#error hello world!\n#endfile"); preprocessor.getcode(code, "TEST", "test.c"); ASSERT_EQUALS("[ab.h:1]: (error) #error hello world!\n", errout.str()); @@ -385,7 +385,7 @@ private: errout.str(""); Settings settings; settings.userDefines = "TEST"; - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); const std::string code("#file \"ab.h\"\n\n#endfile\n#error aaa"); preprocessor.getcode(code, "TEST", "test.c"); ASSERT_EQUALS("[test.c:2]: (error) #error aaa\n", errout.str()); @@ -397,7 +397,7 @@ private: Settings settings; settings.userDefines = "FOO"; settings.force = true; // No message if --force is given - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); const std::string code("#error hello world!\n"); preprocessor.getcode(code, "X", "test.c"); ASSERT_EQUALS("", errout.str()); @@ -462,7 +462,7 @@ private: void setPlatformInfo() { Settings settings; - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); // read code with simplecpp.. const char filedata[] = "#if sizeof(long) == 4\n" @@ -1944,23 +1944,23 @@ private: preprocess("#define () {(int f(x) }\n", actual); // don't hang } - void inline_suppression_for_missing_include() { + void inline_suppressions() { + errout.str(""); + Settings settings; settings.inlineSuppressions = true; settings.severity.clear(); settings.checks.enable(Checks::missingInclude); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); const std::string code("// cppcheck-suppress missingInclude\n" "#include \"missing.h\"\n" "// cppcheck-suppress missingIncludeSystem\n" "#include \n"); - // Don't report that the include is missing - errout.str(""); - preprocessor.getcode(code, "", "test.c"); - ASSERT_EQUALS("", errout.str()); + Suppressions inlineSuppr; + preprocessor.getcode(code, "", "test.c", &inlineSuppr); - auto suppressions = settings.nomsg.getSuppressions(); + auto suppressions = inlineSuppr.getSuppressions(); ASSERT_EQUALS(2, suppressions.size()); auto suppr = suppressions.front(); @@ -1968,16 +1968,16 @@ private: ASSERT_EQUALS("missingInclude", suppr.errorId); ASSERT_EQUALS("test.c", suppr.fileName); ASSERT_EQUALS(2, suppr.lineNumber); - ASSERT_EQUALS(true, suppr.checked); - ASSERT_EQUALS(true, suppr.matched); + ASSERT_EQUALS(false, suppr.checked); + ASSERT_EQUALS(false, suppr.matched); suppr = suppressions.front(); suppressions.pop_front(); ASSERT_EQUALS("missingIncludeSystem", suppr.errorId); ASSERT_EQUALS("test.c", suppr.fileName); ASSERT_EQUALS(4, suppr.lineNumber); - ASSERT_EQUALS(true, suppr.checked); - ASSERT_EQUALS(true, suppr.matched); + ASSERT_EQUALS(false, suppr.checked); + ASSERT_EQUALS(false, suppr.matched); } void predefine1() { @@ -2305,7 +2305,7 @@ private: errout.str(""); Settings settings; settings.userDefines = "foo"; - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); const std::string code("#error hello world!\n"); preprocessor.getcode(code, "X", "./././test.c"); ASSERT_EQUALS("[test.c:1]: (error) #error hello world!\n", errout.str()); @@ -2343,7 +2343,7 @@ private: " \n"; std::ostringstream ostr; - Preprocessor preprocessor(settings0, settings0.nomsg, this); + Preprocessor preprocessor(settings0, this); preprocessor.getcode(filedata, "", "test.c"); preprocessor.dump(ostr); ASSERT_EQUALS(dumpdata, ostr.str()); @@ -2370,7 +2370,7 @@ private: " \n"; std::ostringstream ostr; - Preprocessor preprocessor(settings0, settings0.nomsg, this); + Preprocessor preprocessor(settings0, this); preprocessor.getcode(filedata, "", "test.c"); preprocessor.dump(ostr); ASSERT_EQUALS(dumpdata, ostr.str()); @@ -2387,7 +2387,7 @@ private: " \n"; std::ostringstream ostr; - Preprocessor preprocessor(settings0, settings0.nomsg, this); + Preprocessor preprocessor(settings0, this); preprocessor.getcode(filedata, "", "test.c"); preprocessor.dump(ostr); ASSERT_EQUALS(dumpdata, ostr.str()); @@ -2401,7 +2401,7 @@ private: settings.checks.enable(Checks::missingInclude); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); ScopedFile header("header.h", ""); @@ -2420,7 +2420,7 @@ private: settings.checks.enable(Checks::missingInclude); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); std::string code("#include \"header.h\""); errout.str(""); @@ -2437,7 +2437,7 @@ private: settings.checks.enable(Checks::missingInclude); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); ScopedFile header("header.h", "", "inc"); @@ -2457,7 +2457,7 @@ private: settings.includePaths.emplace_back("inc"); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); ScopedFile header("header.h", "", "inc"); @@ -2477,7 +2477,7 @@ private: settings.includePaths.emplace_back("inc"); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); ScopedFile header("header.h", "", Path::getCurrentPath()); @@ -2496,7 +2496,7 @@ private: settings.checks.enable(Checks::missingInclude); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); const std::string header = Path::join(Path::getCurrentPath(), "header.h"); @@ -2515,7 +2515,7 @@ private: settings.checks.enable(Checks::missingInclude); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); ScopedFile header("header.h", ""); @@ -2534,7 +2534,7 @@ private: settings.checks.enable(Checks::missingInclude); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); std::string code("#include "); errout.str(""); @@ -2553,7 +2553,7 @@ private: setTemplateFormat("simple"); settings.includePaths.emplace_back("system"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); ScopedFile header("header.h", "", "system"); @@ -2573,7 +2573,7 @@ private: settings.includePaths.emplace_back("inc"); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); ScopedFile header("header.h", "", Path::getCurrentPath()); @@ -2592,7 +2592,7 @@ private: settings.checks.enable(Checks::missingInclude); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); const std::string header = Path::join(Path::getCurrentPath(), "header.h"); @@ -2611,7 +2611,7 @@ private: settings.checks.enable(Checks::missingInclude); settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); ScopedFile header("header.h", ""); ScopedFile header2("header2.h", ""); @@ -2637,7 +2637,7 @@ private: settings.templateFormat = "simple"; // has no effect setTemplateFormat("simple"); - Preprocessor preprocessor(settings, settings.nomsg, this); + Preprocessor preprocessor(settings, this); ScopedFile header("header.h", ""); ScopedFile header2("header2.h", ""); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index e7c5ec0a6..693ebcc79 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6647,7 +6647,7 @@ private: "int PTR4 q4_var RBR4 = 0;\n"; // Preprocess file.. - Preprocessor preprocessor(settings0, settings0.nomsg); + Preprocessor preprocessor(settings0); std::list configurations; std::string filedata; std::istringstream fin(raw_code); @@ -7398,7 +7398,7 @@ private: std::map filedata; simplecpp::preprocess(tokens2, tokens1, files, filedata, simplecpp::DUI()); - Preprocessor preprocessor(settings0, settings0.nomsg, nullptr); + Preprocessor preprocessor(settings0); preprocessor.setDirectives(tokens1); // Tokenizer.. diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index c2405013f..803fd476b 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -259,7 +259,7 @@ private: // Clear the error buffer.. errout.str(""); - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); if (directives) preprocessor.setDirectives(*directives); @@ -284,7 +284,7 @@ private: std::map filedata; simplecpp::preprocess(tokens2, tokens1, files, filedata, simplecpp::DUI()); - Preprocessor preprocessor(settings, settings.nomsg, nullptr); + Preprocessor preprocessor(settings); preprocessor.setDirectives(tokens1); // Tokenizer..