diff --git a/Makefile b/Makefile index 9ba1ceda0839..56fd1b69ae30 100644 --- a/Makefile +++ b/Makefile @@ -632,7 +632,7 @@ $(libcppdir)/settings.o: lib/settings.cpp externals/picojson/picojson.h lib/addo $(libcppdir)/summaries.o: lib/summaries.cpp lib/addoninfo.h lib/analyzerinfo.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/summaries.cpp -$(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/mathlib.h lib/path.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h +$(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/suppressions.cpp $(libcppdir)/templatesimplifier.o: lib/templatesimplifier.cpp lib/addoninfo.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 6047647fcd5a..31122583e241 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -232,12 +232,12 @@ bool CppCheckExecutor::reportSuppressions(const Settings &settings, const Suppre for (std::list::const_iterator i = files.cbegin(); i != files.cend(); ++i) { err |= SuppressionList::reportUnmatchedSuppressions( - suppressions.getUnmatchedLocalSuppressions(i->path(), unusedFunctionCheckEnabled), errorLogger); + suppressions.getUnmatchedLocalSuppressions(*i, unusedFunctionCheckEnabled), errorLogger); } for (std::list::const_iterator i = fileSettings.cbegin(); i != fileSettings.cend(); ++i) { err |= SuppressionList::reportUnmatchedSuppressions( - suppressions.getUnmatchedLocalSuppressions(i->filename(), unusedFunctionCheckEnabled), errorLogger); + suppressions.getUnmatchedLocalSuppressions(i->file, unusedFunctionCheckEnabled), errorLogger); } } err |= SuppressionList::reportUnmatchedSuppressions(suppressions.getUnmatchedGlobalSuppressions(unusedFunctionCheckEnabled), errorLogger); diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 38d60a54ed2d..9cbe1245fd3a 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -155,13 +155,13 @@ static std::string getCtuInfoFileName(const std::string &dumpFile) } static void createDumpFile(const Settings& settings, - const std::string& filename, + const FileWithDetails& file, std::ofstream& fdump, std::string& dumpFile) { if (!settings.dump && settings.addons.empty()) return; - dumpFile = getDumpFileName(settings, filename); + dumpFile = getDumpFileName(settings, file.spath()); fdump.open(dumpFile); if (!fdump.is_open()) @@ -171,6 +171,7 @@ static void createDumpFile(const Settings& settings, std::ofstream fout(getCtuInfoFileName(dumpFile)); } + // TODO: enforcedLang should be already applied in FileWithDetails object std::string language; switch (settings.enforcedLang) { case Standards::Language::C: @@ -181,8 +182,9 @@ static void createDumpFile(const Settings& settings, break; case Standards::Language::None: { + // TODO: get language from FileWithDetails object // TODO: error out on unknown language? - const Standards::Language lang = Path::identify(filename, settings.cppHeaderProbe); + const Standards::Language lang = Path::identify(file.spath(), settings.cppHeaderProbe); if (lang == Standards::Language::CPP) language = " language=\"cpp\""; else if (lang == Standards::Language::C) @@ -411,18 +413,19 @@ static bool reportClangErrors(std::istream &is, const std::function&1") : ("2> " + clangStderr); if (!mSettings.buildDir.empty()) { std::ofstream fout(clangcmd); @@ -492,7 +495,7 @@ unsigned int CppCheck::checkClang(const std::string &path) try { Tokenizer tokenizer(mSettings, *this); - tokenizer.list.appendFileIfNew(path); + tokenizer.list.appendFileIfNew(file.spath()); std::istringstream ast(output2); clangimport::parseClangAstDump(tokenizer, ast); ValueFlow::setValues(tokenizer.list, @@ -507,7 +510,7 @@ unsigned int CppCheck::checkClang(const std::string &path) // create dumpfile std::ofstream fdump; std::string dumpFile; - createDumpFile(mSettings, path, fdump, dumpFile); + createDumpFile(mSettings, file, fdump, dumpFile); if (fdump.is_open()) { // TODO: use tinyxml2 to create XML fdump << "\n"; @@ -524,16 +527,16 @@ unsigned int CppCheck::checkClang(const std::string &path) } // run addons - executeAddons(dumpFile, path); + executeAddons(dumpFile, file); } catch (const InternalError &e) { - const ErrorMessage errmsg = ErrorMessage::fromInternalError(e, nullptr, path, "Bailing out from analysis: Processing Clang AST dump failed"); + const ErrorMessage errmsg = ErrorMessage::fromInternalError(e, nullptr, file.spath(), "Bailing out from analysis: Processing Clang AST dump failed"); reportErr(errmsg); } catch (const TerminateException &) { // Analysis is terminated return mExitCode; } catch (const std::exception &e) { - internalError(path, std::string("Processing Clang AST dump failed: ") + e.what()); + internalError(file.spath(), std::string("Processing Clang AST dump failed: ") + e.what()); } return mExitCode; @@ -542,15 +545,15 @@ unsigned int CppCheck::checkClang(const std::string &path) unsigned int CppCheck::check(const FileWithDetails &file) { if (mSettings.clang) - return checkClang(file.spath()); + return checkClang(file); - return checkFile(file.spath(), emptyString); + return checkFile(file, emptyString); } unsigned int CppCheck::check(const FileWithDetails &file, const std::string &content) { std::istringstream iss(content); - return checkFile(file.spath(), emptyString, &iss); + return checkFile(file, emptyString, &iss); } unsigned int CppCheck::check(const FileSettings &fs) @@ -583,7 +586,7 @@ unsigned int CppCheck::check(const FileSettings &fs) mUnusedFunctionsCheck->updateFunctionData(*temp.mUnusedFunctionsCheck); return returnValue; } - const unsigned int returnValue = temp.checkFile(fs.sfilename(), fs.cfg); + const unsigned int returnValue = temp.checkFile(fs.file, fs.cfg); mSettings.supprs.nomsg.addSuppressions(temp.mSettings.supprs.nomsg.getSuppressions()); if (mUnusedFunctionsCheck) mUnusedFunctionsCheck->updateFunctionData(*temp.mUnusedFunctionsCheck); @@ -598,7 +601,7 @@ static simplecpp::TokenList createTokenList(const std::string& filename, std::ve return {filename, files, outputList}; } -unsigned int CppCheck::checkFile(const std::string& filename, const std::string &cfgname, std::istream* fileStream) +unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string &cfgname, std::istream* fileStream) { // TODO: move to constructor when CppCheck no longer owns the settings if (mSettings.checks.isEnabled(Checks::unusedFunction) && !mUnusedFunctionsCheck) @@ -609,10 +612,10 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string if (Settings::terminated()) return mExitCode; - const Timer fileTotalTimer(mSettings.showtime == SHOWTIME_MODES::SHOWTIME_FILE_TOTAL, filename); + const Timer fileTotalTimer(mSettings.showtime == SHOWTIME_MODES::SHOWTIME_FILE_TOTAL, file.spath()); if (!mSettings.quiet) { - std::string fixedpath = Path::toNativeSeparators(filename); + std::string fixedpath = Path::toNativeSeparators(file.spath()); mErrorLogger.reportOut(std::string("Checking ") + fixedpath + ' ' + cfgname + std::string("..."), Color::FgGreen); if (mSettings.verbose) { @@ -638,18 +641,18 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string } try { - if (mSettings.library.markupFile(filename)) { + if (mSettings.library.markupFile(file.spath())) { if (mUnusedFunctionsCheck && mSettings.useSingleJob() && mSettings.buildDir.empty()) { // this is not a real source file - we just want to tokenize it. treat it as C anyways as the language needs to be determined. Tokenizer tokenizer(mSettings, *this); // enforce the language since markup files are special and do not adhere to the enforced language tokenizer.list.setLang(Standards::Language::C, true); if (fileStream) { - tokenizer.list.createTokens(*fileStream, filename); + tokenizer.list.createTokens(*fileStream, file.spath()); } else { - std::ifstream in(filename); - tokenizer.list.createTokens(in, filename); + std::ifstream in(file.spath()); + tokenizer.list.createTokens(in, file.spath()); } mUnusedFunctionsCheck->parseTokens(tokenizer, mSettings); } @@ -658,7 +661,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string simplecpp::OutputList outputList; std::vector files; - simplecpp::TokenList tokens1 = createTokenList(filename, files, &outputList, fileStream); + simplecpp::TokenList tokens1 = createTokenList(file.spath(), files, &outputList, fileStream); // If there is a syntax error, report it and stop const auto output_it = std::find_if(outputList.cbegin(), outputList.cend(), [](const simplecpp::Output &output){ @@ -666,14 +669,14 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string }); if (output_it != outputList.cend()) { const simplecpp::Output &output = *output_it; - std::string file = Path::fromNativeSeparators(output.location.file()); + std::string locfile = Path::fromNativeSeparators(output.location.file()); if (mSettings.relativePaths) - file = Path::getRelativePath(file, mSettings.basePaths); + locfile = Path::getRelativePath(locfile, mSettings.basePaths); - ErrorMessage::FileLocation loc1(file, output.location.line, output.location.col); + ErrorMessage::FileLocation loc1(locfile, output.location.line, output.location.col); ErrorMessage errmsg({std::move(loc1)}, - "", + "", // TODO: is this correct? Severity::error, output.msg, "syntaxError", @@ -689,11 +692,11 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string if (!mSettings.plistOutput.empty()) { std::string filename2; - if (filename.find('/') != std::string::npos) - filename2 = filename.substr(filename.rfind('/') + 1); + if (file.spath().find('/') != std::string::npos) + filename2 = file.spath().substr(file.spath().rfind('/') + 1); else - filename2 = filename; - const std::size_t fileNameHash = std::hash {}(filename); + filename2 = file.spath(); + const std::size_t fileNameHash = std::hash {}(file.spath()); filename2 = mSettings.plistOutput + filename2.substr(0, filename2.find('.')) + "_" + std::to_string(fileNameHash) + ".plist"; mPlistFile.open(filename2); mPlistFile << ErrorLogger::plistHeader(version(), files); @@ -730,7 +733,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string // Calculate hash so it can be compared with old hash / future hashes const std::size_t hash = preprocessor.calculateHash(tokens1, toolinfo.str()); std::list errors; - if (!mAnalyzerInformation.analyzeFile(mSettings.buildDir, filename, cfgname, hash, errors)) { + if (!mAnalyzerInformation.analyzeFile(mSettings.buildDir, file.spath(), cfgname, hash, errors)) { while (!errors.empty()) { reportErr(errors.front()); errors.pop_front(); @@ -744,7 +747,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string // write dump file xml prolog std::ofstream fdump; std::string dumpFile; - createDumpFile(mSettings, filename, fdump, dumpFile); + createDumpFile(mSettings, file, fdump, dumpFile); if (fdump.is_open()) { fdump << dumpProlog; if (!mSettings.dump) @@ -791,7 +794,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string if (!mSettings.force && configurations.size() > mSettings.maxConfigs) { if (mSettings.severity.isEnabled(Severity::information)) { - tooManyConfigsError(Path::toNativeSeparators(filename),configurations.size()); + tooManyConfigsError(Path::toNativeSeparators(file.spath()),configurations.size()); } else { mTooManyConfigs = true; } @@ -866,7 +869,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string // If only errors are printed, print filename after the check if (!mSettings.quiet && (!mCurrentConfig.empty() || checkCount > 1)) { - std::string fixedpath = Path::toNativeSeparators(filename); + std::string fixedpath = Path::toNativeSeparators(file.spath()); mErrorLogger.reportOut("Checking " + fixedpath + ": " + mCurrentConfig + "...", Color::FgGreen); } @@ -906,7 +909,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string const std::size_t hash = tokenizer.list.calculateHash(); if (hashes.find(hash) != hashes.end()) { if (mSettings.debugwarnings) - purgedConfigurationMessage(filename, mCurrentConfig); + purgedConfigurationMessage(file.spath(), mCurrentConfig); continue; } hashes.insert(hash); @@ -921,14 +924,14 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string if (!hasValidConfig && currCfg == *configurations.rbegin()) { // If there is no valid configuration then report error.. - std::string file = Path::fromNativeSeparators(o.location.file()); + std::string locfile = Path::fromNativeSeparators(o.location.file()); if (mSettings.relativePaths) - file = Path::getRelativePath(file, mSettings.basePaths); + locfile = Path::getRelativePath(locfile, mSettings.basePaths); - ErrorMessage::FileLocation loc1(file, o.location.line, o.location.col); + ErrorMessage::FileLocation loc1(locfile, o.location.line, o.location.col); ErrorMessage errmsg({std::move(loc1)}, - filename, + file.spath(), Severity::error, o.msg, "preprocessorErrorDirective", @@ -942,7 +945,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string return mExitCode; } catch (const InternalError &e) { - ErrorMessage errmsg = ErrorMessage::fromInternalError(e, &tokenizer.list, filename); + ErrorMessage errmsg = ErrorMessage::fromInternalError(e, &tokenizer.list, file.spath()); reportErr(errmsg); } } @@ -954,7 +957,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string for (const std::string &s : configurationError) msg += '\n' + s; - const std::string locFile = Path::toNativeSeparators(filename); + const std::string locFile = Path::toNativeSeparators(file.spath()); ErrorMessage::FileLocation loc(locFile, 0, 0); ErrorMessage errmsg({std::move(loc)}, locFile, @@ -971,17 +974,17 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string fdump.close(); } - executeAddons(dumpFile, filename); + executeAddons(dumpFile, file); } catch (const TerminateException &) { // Analysis is terminated return mExitCode; } catch (const std::runtime_error &e) { - internalError(filename, std::string("Checking file failed: ") + e.what()); + internalError(file.spath(), std::string("Checking file failed: ") + e.what()); } catch (const std::bad_alloc &) { - internalError(filename, "Checking file failed: out of memory"); + internalError(file.spath(), "Checking file failed: out of memory"); } catch (const InternalError &e) { - const ErrorMessage errmsg = ErrorMessage::fromInternalError(e, nullptr, filename, "Bailing out from analysis: Checking file failed"); + const ErrorMessage errmsg = ErrorMessage::fromInternalError(e, nullptr, file.spath(), "Bailing out from analysis: Checking file failed"); reportErr(errmsg); } @@ -992,7 +995,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string // In jointSuppressionReport mode, unmatched suppressions are // collected after all files are processed if (!mSettings.useSingleJob() && (mSettings.severity.isEnabled(Severity::information) || mSettings.checkConfiguration)) { - SuppressionList::reportUnmatchedSuppressions(mSettings.supprs.nomsg.getUnmatchedLocalSuppressions(filename, (bool)mUnusedFunctionsCheck), *this); + SuppressionList::reportUnmatchedSuppressions(mSettings.supprs.nomsg.getUnmatchedLocalSuppressions(file, (bool)mUnusedFunctionsCheck), *this); } mErrorList.clear(); @@ -1376,11 +1379,11 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list) } #endif -void CppCheck::executeAddons(const std::string& dumpFile, const std::string& file0) +void CppCheck::executeAddons(const std::string& dumpFile, const FileWithDetails& file) { if (!dumpFile.empty()) { std::vector f{dumpFile}; - executeAddons(f, file0); + executeAddons(f, file.spath()); } } diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 039564679161..b4236f1ce9a4 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -172,12 +172,12 @@ class CPPCHECKLIB CppCheck : ErrorLogger { /** * @brief Check a file using stream - * @param filename file name + * @param file the file * @param cfgname cfg name * @param fileStream stream the file content can be read from * @return number of errors found */ - unsigned int checkFile(const std::string& filename, const std::string &cfgname, std::istream* fileStream = nullptr); + unsigned int checkFile(const FileWithDetails& file, const std::string &cfgname, std::istream* fileStream = nullptr); /** * @brief Check normal tokens @@ -189,7 +189,7 @@ class CPPCHECKLIB CppCheck : ErrorLogger { * Execute addons */ void executeAddons(const std::vector& files, const std::string& file0); - void executeAddons(const std::string &dumpFile, const std::string& file0); + void executeAddons(const std::string &dumpFile, const FileWithDetails& file); /** * Execute addons @@ -205,7 +205,7 @@ class CPPCHECKLIB CppCheck : ErrorLogger { void executeRules(const std::string &tokenlist, const TokenList &list); #endif - unsigned int checkClang(const std::string &path); + unsigned int checkClang(const FileWithDetails &file); /** * @brief Errors and warnings are directed here. diff --git a/lib/filesettings.h b/lib/filesettings.h index 0f00577926fb..7328c9453fc4 100644 --- a/lib/filesettings.h +++ b/lib/filesettings.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -37,17 +38,21 @@ class FileWithDetails FileWithDetails(std::string path, std::size_t size) : mPath(std::move(path)) + , mPathSimplified(Path::simplifyPath(mPath)) , mSize(size) - {} + { + if (mPath.empty()) + throw std::runtime_error("empty path specified"); + } const std::string& path() const { return mPath; } - std::string spath() const + const std::string& spath() const { - return Path::simplifyPath(mPath); + return mPathSimplified; } std::size_t size() const @@ -56,6 +61,7 @@ class FileWithDetails } private: std::string mPath; + std::string mPathSimplified; std::size_t mSize; }; @@ -75,7 +81,7 @@ struct CPPCHECKLIB FileSettings { { return file.path(); } - std::string sfilename() const + const std::string& sfilename() const { return file.spath(); } diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 5986367b1896..aaccaff3fae7 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -20,6 +20,7 @@ #include "errorlogger.h" #include "errortypes.h" +#include "filesettings.h" #include "path.h" #include "utils.h" #include "token.h" @@ -475,9 +476,8 @@ void SuppressionList::dump(std::ostream & out) const out << " " << std::endl; } -std::list SuppressionList::getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const +std::list SuppressionList::getUnmatchedLocalSuppressions(const FileWithDetails &file, const bool unusedFunctionChecking) const { - std::string tmpFile = Path::simplifyPath(file); std::list result; for (const Suppression &s : mSuppressions) { if (s.matched || ((s.lineNumber != Suppression::NO_LINE) && !s.checked)) @@ -490,7 +490,7 @@ std::list SuppressionList::getUnmatchedLocalSuppre continue; if (!unusedFunctionChecking && s.errorId == ID_UNUSEDFUNCTION) continue; - if (tmpFile.empty() || !s.isLocal() || s.fileName != tmpFile) + if (!s.isLocal() || s.fileName != file.spath()) continue; result.push_back(s); } diff --git a/lib/suppressions.h b/lib/suppressions.h index 98a582a985a8..b7a779795bb7 100644 --- a/lib/suppressions.h +++ b/lib/suppressions.h @@ -37,6 +37,7 @@ class Tokenizer; class ErrorMessage; class ErrorLogger; enum class Certainty; +class FileWithDetails; /** @brief class for handling suppressions */ class CPPCHECKLIB SuppressionList { @@ -227,7 +228,7 @@ class CPPCHECKLIB SuppressionList { * @brief Returns list of unmatched local (per-file) suppressions. * @return list of unmatched suppressions */ - std::list getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const; + std::list getUnmatchedLocalSuppressions(const FileWithDetails &file, const bool unusedFunctionChecking) const; /** * @brief Returns list of unmatched global (glob pattern) suppressions. diff --git a/oss-fuzz/Makefile b/oss-fuzz/Makefile index 5d4a77403a45..9f3250394ba5 100644 --- a/oss-fuzz/Makefile +++ b/oss-fuzz/Makefile @@ -311,7 +311,7 @@ $(libcppdir)/settings.o: ../lib/settings.cpp ../externals/picojson/picojson.h .. $(libcppdir)/summaries.o: ../lib/summaries.cpp ../lib/addoninfo.h ../lib/analyzerinfo.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/sourcelocation.h ../lib/standards.h ../lib/summaries.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/summaries.cpp -$(libcppdir)/suppressions.o: ../lib/suppressions.cpp ../externals/tinyxml2/tinyxml2.h ../lib/color.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/mathlib.h ../lib/path.h ../lib/standards.h ../lib/suppressions.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h +$(libcppdir)/suppressions.o: ../lib/suppressions.cpp ../externals/tinyxml2/tinyxml2.h ../lib/color.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/filesettings.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/standards.h ../lib/suppressions.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/suppressions.cpp $(libcppdir)/templatesimplifier.o: ../lib/templatesimplifier.cpp ../lib/addoninfo.h ../lib/color.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/standards.h ../lib/suppressions.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 85d015a30033..4fa552679ec6 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -1194,18 +1194,18 @@ class TestSuppressions : public TestFixture { SuppressionList::Suppression suppression("unusedFunction", "test.c", 3); suppression.checked = true; // have to do this because fixes for #5704 ASSERT_EQUALS("", suppressions.addSuppression(std::move(suppression))); - ASSERT_EQUALS(true, !suppressions.getUnmatchedLocalSuppressions("test.c", true).empty()); + ASSERT_EQUALS(true, !suppressions.getUnmatchedLocalSuppressions(FileWithDetails("test.c"), true).empty()); ASSERT_EQUALS(false, !suppressions.getUnmatchedGlobalSuppressions(true).empty()); - ASSERT_EQUALS(false, !suppressions.getUnmatchedLocalSuppressions("test.c", false).empty()); + ASSERT_EQUALS(false, !suppressions.getUnmatchedLocalSuppressions(FileWithDetails("test.c"), false).empty()); ASSERT_EQUALS(false, !suppressions.getUnmatchedGlobalSuppressions(false).empty()); } void globalsuppress_unusedFunction() const { // #4946 - wrong report of "unmatchedSuppression" for "unusedFunction" SuppressionList suppressions; ASSERT_EQUALS("", suppressions.addSuppressionLine("unusedFunction:*")); - ASSERT_EQUALS(false, !suppressions.getUnmatchedLocalSuppressions("test.c", true).empty()); + ASSERT_EQUALS(false, !suppressions.getUnmatchedLocalSuppressions(FileWithDetails("test.c"), true).empty()); ASSERT_EQUALS(true, !suppressions.getUnmatchedGlobalSuppressions(true).empty()); - ASSERT_EQUALS(false, !suppressions.getUnmatchedLocalSuppressions("test.c", false).empty()); + ASSERT_EQUALS(false, !suppressions.getUnmatchedLocalSuppressions(FileWithDetails("test.c"), false).empty()); ASSERT_EQUALS(false, !suppressions.getUnmatchedGlobalSuppressions(false).empty()); }