@@ -123,16 +123,17 @@ class CppCheck::CppCheckLogger : public ErrorLogger
123123 mErrorList .clear ();
124124 }
125125
126- void openPlist (const std::string& filename, const std::vector<std::string>& files)
126+ void openPlist (const std::string& filename, const std::vector<std::string>* files)
127127 {
128128 mPlistFile .open (filename);
129- mPlistFile << ErrorLogger::plistHeader (version (), files);
129+ mPlistFile << ErrorLogger::plistHeader (version ());
130+ mPlistFilenames = files;
130131 }
131132
132133 void closePlist ()
133134 {
134135 if (mPlistFile .is_open ()) {
135- mPlistFile << ErrorLogger::plistFooter ();
136+ mPlistFile << ErrorLogger::plistFooter (mPlistFilenames );
136137 mPlistFile .close ();
137138 }
138139 }
@@ -275,6 +276,7 @@ class CppCheck::CppCheckLogger : public ErrorLogger
275276 using Location = std::pair<std::string, int >;
276277 std::map<Location, std::set<std::string>> mLocationMacros ; // What macros are used on a location?
277278
279+ const std::vector<std::string>* mPlistFilenames {};
278280 std::ofstream mPlistFile ;
279281
280282 unsigned int mExitCode {};
@@ -994,22 +996,12 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
994996 filename2 = file.spath ();
995997 const std::size_t fileNameHash = std::hash<std::string> {}(file.spath ());
996998 filename2 = mSettings .plistOutput + filename2.substr (0 , filename2.find (' .' )) + " _" + std::to_string (fileNameHash) + " .plist" ;
997- mLogger ->openPlist (filename2, files);
998- }
999-
1000- std::string dumpProlog;
1001- if (mSettings .dump || !mSettings .addons .empty ()) {
1002- dumpProlog += getDumpFileContentsRawTokens (files, tokens1);
999+ mLogger ->openPlist (filename2, &files);
10031000 }
10041001
10051002 // Parse comments and then remove them
10061003 preprocessor.addRemarkComments (tokens1, mLogger ->remarkComments ());
10071004 preprocessor.inlineSuppressions (tokens1, mSuppressions .nomsg );
1008- if (mSettings .dump || !mSettings .addons .empty ()) {
1009- std::ostringstream oss;
1010- mSuppressions .nomsg .dump (oss);
1011- dumpProlog += oss.str ();
1012- }
10131005 tokens1.removeComments ();
10141006
10151007 if (!mSettings .buildDir .empty ()) {
@@ -1106,7 +1098,6 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
11061098 createDumpFile (mSettings , file, fileIndex, fdump, dumpFile);
11071099 if (fdump.is_open ()) {
11081100 fdump << getLibraryDumpData ();
1109- fdump << dumpProlog;
11101101 if (!mSettings .dump )
11111102 filesDeleter.addFile (dumpFile);
11121103 }
@@ -1289,8 +1280,11 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
12891280 }
12901281
12911282 // TODO: will not be closed if we encountered an exception
1292- // dumped all configs, close root </dumps> element now
12931283 if (fdump.is_open ()) {
1284+ // dump all filenames, raw tokens, suppressions
1285+ fdump << getDumpFileContentsRawTokens (files, tokens1);
1286+ mSuppressions .nomsg .dump (fdump);
1287+ // dumped all configs, close root </dumps> element now
12941288 fdump << " </dumps>" << std::endl;
12951289 fdump.close ();
12961290 }
0 commit comments