@@ -620,6 +620,20 @@ static simplecpp::TokenList createTokenList(const std::string& filename, std::ve
620
620
return {filename, files, outputList};
621
621
}
622
622
623
+ static std::size_t calculateHash (const Preprocessor& preprocessor, const simplecpp::TokenList& tokens, const Settings& settings)
624
+ {
625
+ std::ostringstream toolinfo;
626
+ toolinfo << CPPCHECK_VERSION_STRING;
627
+ toolinfo << (settings.severity .isEnabled (Severity::warning) ? ' w' : ' ' );
628
+ toolinfo << (settings.severity .isEnabled (Severity::style) ? ' s' : ' ' );
629
+ toolinfo << (settings.severity .isEnabled (Severity::performance) ? ' p' : ' ' );
630
+ toolinfo << (settings.severity .isEnabled (Severity::portability) ? ' p' : ' ' );
631
+ toolinfo << (settings.severity .isEnabled (Severity::information) ? ' i' : ' ' );
632
+ toolinfo << settings.userDefines ;
633
+ settings.supprs .nomsg .dump (toolinfo);
634
+ return preprocessor.calculateHash (tokens, toolinfo.str ());
635
+ }
636
+
623
637
unsigned int CppCheck::checkFile (const FileWithDetails& file, const std::string &cfgname, std::istream* fileStream)
624
638
{
625
639
// TODO: move to constructor when CppCheck no longer owns the settings
@@ -740,19 +754,8 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
740
754
preprocessor.removeComments (tokens1);
741
755
742
756
if (!mSettings .buildDir .empty ()) {
743
- // Get toolinfo
744
- std::ostringstream toolinfo;
745
- toolinfo << CPPCHECK_VERSION_STRING;
746
- toolinfo << (mSettings .severity .isEnabled (Severity::warning) ? ' w' : ' ' );
747
- toolinfo << (mSettings .severity .isEnabled (Severity::style) ? ' s' : ' ' );
748
- toolinfo << (mSettings .severity .isEnabled (Severity::performance) ? ' p' : ' ' );
749
- toolinfo << (mSettings .severity .isEnabled (Severity::portability) ? ' p' : ' ' );
750
- toolinfo << (mSettings .severity .isEnabled (Severity::information) ? ' i' : ' ' );
751
- toolinfo << mSettings .userDefines ;
752
- mSettings .supprs .nomsg .dump (toolinfo);
753
-
754
757
// Calculate hash so it can be compared with old hash / future hashes
755
- const std::size_t hash = preprocessor. calculateHash (tokens1, toolinfo. str () );
758
+ const std::size_t hash = calculateHash (preprocessor, tokens1, mSettings );
756
759
std::list<ErrorMessage> errors;
757
760
if (!mAnalyzerInformation .analyzeFile (mSettings .buildDir , file.spath (), cfgname, hash, errors)) {
758
761
while (!errors.empty ()) {
0 commit comments