@@ -330,17 +330,17 @@ static std::vector<std::string> split(const std::string &str, const std::string
330330 return ret;
331331}
332332
333- static std::string getDumpFileName (const Settings& settings, const std::string& filename, int fileIndex )
333+ static std::string getDumpFileName (const Settings& settings, const FileWithDetails& file )
334334{
335335 std::string extension = " .dump" ;
336- if (fileIndex > 0 )
337- extension = " ." + std::to_string (fileIndex ) + extension;
336+ if (file. fsFileId () > 0 )
337+ extension = " ." + std::to_string (file. fsFileId () ) + extension;
338338 if (!settings.dump && settings.buildDir .empty ())
339339 extension = " ." + std::to_string (settings.pid ) + extension;
340340
341341 if (!settings.dump && !settings.buildDir .empty ())
342- return AnalyzerInformation::getAnalyzerInfoFile (settings.buildDir , filename , " " , fileIndex ) + extension;
343- return filename + extension;
342+ return AnalyzerInformation::getAnalyzerInfoFile (settings.buildDir , file. spath () , " " , file. fsFileId () ) + extension;
343+ return file. spath () + extension;
344344}
345345
346346static std::string getCtuInfoFileName (const std::string &dumpFile)
@@ -350,13 +350,12 @@ static std::string getCtuInfoFileName(const std::string &dumpFile)
350350
351351static void createDumpFile (const Settings& settings,
352352 const FileWithDetails& file,
353- int fileIndex,
354353 std::ofstream& fdump,
355354 std::string& dumpFile)
356355{
357356 if (!settings.dump && settings.addons .empty ())
358357 return ;
359- dumpFile = getDumpFileName (settings, file. spath (), fileIndex );
358+ dumpFile = getDumpFileName (settings, file);
360359
361360 fdump.open (dumpFile);
362361 if (!fdump.is_open ())
@@ -660,7 +659,7 @@ static std::string getClangFlags(const Settings& setting, Standards::Language la
660659}
661660
662661// TODO: clear error list before returning
663- unsigned int CppCheck::checkClang (const FileWithDetails &file, int fileIndex )
662+ unsigned int CppCheck::checkClang (const FileWithDetails &file)
664663{
665664 // TODO: clear exitcode
666665
@@ -673,7 +672,7 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file, int fileIndex)
673672 // TODO: get language from FileWithDetails object
674673 std::string clangStderr;
675674 if (!mSettings .buildDir .empty ())
676- clangStderr = AnalyzerInformation::getAnalyzerInfoFile (mSettings .buildDir , file.spath (), " " , fileIndex ) + " .clang-stderr" ;
675+ clangStderr = AnalyzerInformation::getAnalyzerInfoFile (mSettings .buildDir , file.spath (), " " , file. fsFileId () ) + " .clang-stderr" ;
677676
678677 std::string exe = mSettings .clangExecutable ;
679678#ifdef _WIN32
@@ -747,7 +746,7 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file, int fileIndex)
747746 // create dumpfile
748747 std::ofstream fdump;
749748 std::string dumpFile;
750- createDumpFile (mSettings , file, fileIndex, fdump, dumpFile);
749+ createDumpFile (mSettings , file, fdump, dumpFile);
751750 if (fdump.is_open ()) {
752751 fdump << getLibraryDumpData ();
753752 // TODO: use tinyxml2 to create XML
@@ -791,9 +790,9 @@ unsigned int CppCheck::check(const FileWithDetails &file)
791790
792791 unsigned int returnValue;
793792 if (mSettings .clang )
794- returnValue = checkClang (file, 0 );
793+ returnValue = checkClang (file);
795794 else
796- returnValue = checkFile (file, " " , 0 );
795+ returnValue = checkFile (file, " " );
797796
798797 // TODO: call analyseClangTidy()
799798
@@ -802,7 +801,7 @@ unsigned int CppCheck::check(const FileWithDetails &file)
802801
803802unsigned int CppCheck::checkBuffer (const FileWithDetails &file, const char * data, std::size_t size)
804803{
805- return checkBuffer (file, " " , 0 , data, size);
804+ return checkBuffer (file, " " , data, size);
806805}
807806
808807unsigned int CppCheck::check (const FileSettings &fs)
@@ -838,7 +837,7 @@ unsigned int CppCheck::check(const FileSettings &fs)
838837 }
839838 // need to pass the externally provided ErrorLogger instead of our internal wrapper
840839 CppCheck temp (tempSettings, mSuppressions , mErrorLoggerDirect , mTimerResults , mUseGlobalSuppressions , mExecuteCommand );
841- const unsigned int returnValue = temp.checkFile (fs.file , fs.cfg , fs. fileIndex );
840+ const unsigned int returnValue = temp.checkFile (fs.file , fs.cfg );
842841 if (mUnusedFunctionsCheck )
843842 mUnusedFunctionsCheck ->updateFunctionData (*temp.mUnusedFunctionsCheck );
844843 while (!temp.mFileInfo .empty ()) {
@@ -875,20 +874,20 @@ std::size_t CppCheck::calculateHash(const Preprocessor& preprocessor, const std:
875874 return preprocessor.calculateHash (toolinfo.str ());
876875}
877876
878- unsigned int CppCheck::checkBuffer (const FileWithDetails &file, const std::string &cfgname, int fileIndex, const char * data, std::size_t size)
877+ unsigned int CppCheck::checkBuffer (const FileWithDetails &file, const std::string &cfgname, const char * data, std::size_t size)
879878{
880879 const auto f = [&file, data, size](std::vector<std::string>& files, simplecpp::OutputList* outputList) {
881880 return simplecpp::TokenList{{data, size}, files, file.spath (), outputList};
882881 };
883- return checkInternal (file, cfgname, fileIndex, f);
882+ return checkInternal (file, cfgname, f);
884883}
885884
886- unsigned int CppCheck::checkFile (const FileWithDetails& file, const std::string &cfgname, int fileIndex )
885+ unsigned int CppCheck::checkFile (const FileWithDetails& file, const std::string &cfgname)
887886{
888887 const auto f = [&file](std::vector<std::string>& files, simplecpp::OutputList* outputList) {
889888 return simplecpp::TokenList{file.spath (), files, outputList};
890889 };
891- return checkInternal (file, cfgname, fileIndex, f);
890+ return checkInternal (file, cfgname, f);
892891}
893892
894893void CppCheck::checkPlistOutput (const FileWithDetails& file, const std::vector<std::string>& files)
@@ -906,7 +905,7 @@ void CppCheck::checkPlistOutput(const FileWithDetails& file, const std::vector<s
906905 }
907906}
908907
909- unsigned int CppCheck::checkInternal (const FileWithDetails& file, const std::string &cfgname, int fileIndex, const CreateTokenListFn& createTokenList)
908+ unsigned int CppCheck::checkInternal (const FileWithDetails& file, const std::string &cfgname, const CreateTokenListFn& createTokenList)
910909{
911910 // TODO: move to constructor when CppCheck no longer owns the settings
912911 if (mSettings .checks .isEnabled (Checks::unusedFunction) && !mUnusedFunctionsCheck )
@@ -974,7 +973,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
974973 mLogger ->setAnalyzerInfo (nullptr );
975974
976975 std::list<ErrorMessage> errors;
977- analyzerInformation->analyzeFile (mSettings .buildDir , file.spath (), cfgname, fileIndex , hash, errors);
976+ analyzerInformation->analyzeFile (mSettings .buildDir , file.spath (), cfgname, file. fsFileId () , hash, errors);
978977 analyzerInformation->setFileInfo (" CheckUnusedFunctions" , mUnusedFunctionsCheck ->analyzerInfo (tokenizer));
979978 analyzerInformation->close ();
980979 }
@@ -1020,7 +1019,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
10201019 // Calculate hash so it can be compared with old hash / future hashes
10211020 const std::size_t hash = calculateHash (preprocessor, file.spath ());
10221021 std::list<ErrorMessage> errors;
1023- if (!analyzerInformation->analyzeFile (mSettings .buildDir , file.spath (), cfgname, fileIndex , hash, errors)) {
1022+ if (!analyzerInformation->analyzeFile (mSettings .buildDir , file.spath (), cfgname, file. fsFileId () , hash, errors)) {
10241023 while (!errors.empty ()) {
10251024 mErrorLogger .reportErr (errors.front ());
10261025 errors.pop_front ();
@@ -1077,7 +1076,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
10771076 // write dump file xml prolog
10781077 std::ofstream fdump;
10791078 std::string dumpFile;
1080- createDumpFile (mSettings , file, fileIndex, fdump, dumpFile);
1079+ createDumpFile (mSettings , file, fdump, dumpFile);
10811080 if (fdump.is_open ()) {
10821081 fdump << getLibraryDumpData ();
10831082 fdump << dumpProlog;
@@ -1200,7 +1199,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
12001199#endif
12011200
12021201 // Simplify tokens into normal form, skip rest of iteration if failed
1203- if (!tokenizer.simplifyTokens1 (currentConfig, fileIndex ))
1202+ if (!tokenizer.simplifyTokens1 (currentConfig, file. fsFileId () ))
12041203 continue ;
12051204
12061205 // dump xml if --dump
@@ -1631,12 +1630,12 @@ void CppCheck::executeAddonsWholeProgram(const std::list<FileWithDetails> &files
16311630
16321631 std::vector<std::string> ctuInfoFiles;
16331632 for (const auto &f: files) {
1634- const std::string &dumpFileName = getDumpFileName (mSettings , f. path (), 0 );
1633+ const std::string &dumpFileName = getDumpFileName (mSettings , f);
16351634 ctuInfoFiles.push_back (getCtuInfoFileName (dumpFileName));
16361635 }
16371636
1638- for (const auto &f : fileSettings) {
1639- const std::string &dumpFileName = getDumpFileName (mSettings , f. filename (), f. fileIndex );
1637+ for (const auto &fs : fileSettings) {
1638+ const std::string &dumpFileName = getDumpFileName (mSettings , fs. file );
16401639 ctuInfoFiles.push_back (getCtuInfoFileName (dumpFileName));
16411640 }
16421641
@@ -1748,7 +1747,7 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings)
17481747 std::string line;
17491748
17501749 if (!mSettings .buildDir .empty ()) {
1751- const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile (mSettings .buildDir , fileSettings.filename (), " " , fileSettings.fileIndex );
1750+ const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile (mSettings .buildDir , fileSettings.sfilename (), " " , fileSettings.file . fsFileId () );
17521751 std::ofstream fcmd (analyzerInfoFile + " .clang-tidy-cmd" );
17531752 fcmd << istr.str ();
17541753 }
0 commit comments