@@ -95,34 +95,36 @@ static bool skipAnalysis(const std::string &analyzerInfoFile, std::size_t hash,
9595 return true ;
9696}
9797
98+ std::string AnalyzerInformation::getAnalyzerInfoFileFromFilesTxt (std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg)
99+ {
100+ std::string line;
101+ const std::string end (' :' + cfg + ' :' + Path::simplifyPath (sourcefile));
102+ while (std::getline (filesTxt,line)) {
103+ if (line.size () <= end.size () + 2U )
104+ continue ;
105+ if (!endsWith (line, end.c_str (), end.size ()))
106+ continue ;
107+ return line.substr (0 ,line.find (' :' ));
108+ }
109+ return " " ;
110+ }
111+
98112std::string AnalyzerInformation::getAnalyzerInfoFile (const std::string &buildDir, const std::string &sourcefile, const std::string &cfg)
99113{
100- const std::string files (buildDir + " /files.txt" );
101- std::ifstream fin (files);
114+ std::ifstream fin (Path::join (buildDir, " files.txt" ));
102115 if (fin.is_open ()) {
103- std::string line;
104- const std::string end (' :' + cfg + ' :' + sourcefile);
105- while (std::getline (fin,line)) {
106- if (line.size () <= end.size () + 2U )
107- continue ;
108- if (!endsWith (line, end.c_str (), end.size ()))
109- continue ;
110- std::ostringstream ostr;
111- ostr << buildDir << ' /' << line.substr (0 ,line.find (' :' ));
112- return ostr.str ();
113- }
116+ const std::string& ret = getAnalyzerInfoFileFromFilesTxt (fin, sourcefile, cfg);
117+ if (!ret.empty ())
118+ return Path::join (buildDir, ret);
114119 }
115120
116- std::string filename = Path::fromNativeSeparators (buildDir);
117- if (!endsWith (filename, ' /' ))
118- filename += ' /' ;
119121 const std::string::size_type pos = sourcefile.rfind (' /' );
120- if (pos == std::string::npos)
121- filename += sourcefile;
122+ std::string filename;
123+ if (pos != std::string::npos)
124+ filename = sourcefile;
122125 else
123- filename += sourcefile.substr (pos+1 );
124- filename += " .analyzerinfo" ;
125- return filename;
126+ filename = sourcefile.substr (pos + 1 );
127+ return Path::join (buildDir, filename) + " .analyzerinfo" ;
126128}
127129
128130bool AnalyzerInformation::analyzeFile (const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t hash, std::list<ErrorMessage> *errors)
0 commit comments