From 11a296cb02d0be6a4af11eb8bd2e9d243e0c7beb Mon Sep 17 00:00:00 2001 From: PKEuS Date: Wed, 9 May 2012 09:54:43 -0700 Subject: [PATCH] Fixed #2708: Print message before checking and after checking is interrupted if there are too many preprocessor configurations Removed redundant suppression check because the same check is done inside reportErr again. --- lib/cppcheck.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 82c22bfec..57dcd925b 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -172,6 +172,26 @@ unsigned int CppCheck::processFile(const std::string& filename) configurations.push_back(_settings.userDefines); } + if (!_settings._force && configurations.size() >= _settings._maxConfigs) { + const std::string fixedpath = Path::toNativeSeparators(filename); + ErrorLogger::ErrorMessage::FileLocation location; + location.setfile(fixedpath); + const std::list loclist(1, location); + std::ostringstream msg; + msg << "Too many #ifdef configurations - cppcheck will only check " << _settings._maxConfigs << " of " << configurations.size() << ".\n" + "The checking of the file will be interrupted because there are too many " + "#ifdef configurations. Checking of all #ifdef configurations can be forced " + "by --force command line option or from GUI preferences. However that may " + "increase the checking time."; + ErrorLogger::ErrorMessage errmsg(loclist, + Severity::information, + msg.str(), + "toomanyconfigs", + false); + + reportErr(errmsg); + } + int checkCount = 0; for (std::list::const_iterator it = configurations.begin(); it != configurations.end(); ++it) { // Check only a few configurations (default 12), after that bail out, unless --force @@ -183,20 +203,13 @@ unsigned int CppCheck::processFile(const std::string& filename) location.setfile(fixedpath); std::list loclist; loclist.push_back(location); - const std::string msg("Interrupted checking because of too many #ifdef configurations.\n" - "The checking of the file was interrupted because there were too many " - "#ifdef configurations. Checking of all #ifdef configurations can be forced " - "by --force command line option or from GUI preferences. However that may " - "increase the checking time."); ErrorLogger::ErrorMessage errmsg(loclist, Severity::information, - msg, + "Interrupted checking because of too many #ifdef configurations.", "toomanyconfigs", false); - if (!_settings.nomsg.isSuppressedLocal(errmsg._id, fixedpath, location.line)) { - reportErr(errmsg); - } + reportErr(errmsg); break; }