@@ -624,6 +624,20 @@ static simplecpp::TokenList createTokenList(const std::string& filename, std::ve
624
624
return {filename, files, outputList};
625
625
}
626
626
627
+ static std::size_t calculateHash (const Preprocessor& preprocessor, const simplecpp::TokenList& tokens, const Settings& settings)
628
+ {
629
+ std::ostringstream toolinfo;
630
+ toolinfo << CPPCHECK_VERSION_STRING;
631
+ toolinfo << (settings.severity .isEnabled (Severity::warning) ? ' w' : ' ' );
632
+ toolinfo << (settings.severity .isEnabled (Severity::style) ? ' s' : ' ' );
633
+ toolinfo << (settings.severity .isEnabled (Severity::performance) ? ' p' : ' ' );
634
+ toolinfo << (settings.severity .isEnabled (Severity::portability) ? ' p' : ' ' );
635
+ toolinfo << (settings.severity .isEnabled (Severity::information) ? ' i' : ' ' );
636
+ toolinfo << settings.userDefines ;
637
+ settings.supprs .nomsg .dump (toolinfo);
638
+ return preprocessor.calculateHash (tokens, toolinfo.str ());
639
+ }
640
+
627
641
unsigned int CppCheck::checkFile (const FileWithDetails& file, const std::string &cfgname, std::istream* fileStream)
628
642
{
629
643
// TODO: move to constructor when CppCheck no longer owns the settings
@@ -752,19 +766,8 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
752
766
mAnalyzerInformation .reset (new AnalyzerInformation);
753
767
754
768
if (mAnalyzerInformation ) {
755
- // Get toolinfo
756
- std::ostringstream toolinfo;
757
- toolinfo << CPPCHECK_VERSION_STRING;
758
- toolinfo << (mSettings .severity .isEnabled (Severity::warning) ? ' w' : ' ' );
759
- toolinfo << (mSettings .severity .isEnabled (Severity::style) ? ' s' : ' ' );
760
- toolinfo << (mSettings .severity .isEnabled (Severity::performance) ? ' p' : ' ' );
761
- toolinfo << (mSettings .severity .isEnabled (Severity::portability) ? ' p' : ' ' );
762
- toolinfo << (mSettings .severity .isEnabled (Severity::information) ? ' i' : ' ' );
763
- toolinfo << mSettings .userDefines ;
764
- mSettings .supprs .nomsg .dump (toolinfo);
765
-
766
769
// Calculate hash so it can be compared with old hash / future hashes
767
- const std::size_t hash = preprocessor. calculateHash (tokens1, toolinfo. str () );
770
+ const std::size_t hash = calculateHash (preprocessor, tokens1, mSettings );
768
771
std::list<ErrorMessage> errors;
769
772
if (!mAnalyzerInformation ->analyzeFile (mSettings .buildDir , file.spath (), cfgname, hash, errors)) {
770
773
while (!errors.empty ()) {
0 commit comments