MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / fsSetIncludePaths

Method fsSetIncludePaths

lib/importproject.cpp:275–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275void ImportProject::fsSetIncludePaths(FileSettings& fs, const std::string &basepath, const std::list<std::string> &in, std::map<std::string, std::string, cppcheck::stricmp> &variables)
276{
277 std::set<std::string> found;
278 // NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
279 const std::list<std::string> copyIn(in);
280 fs.includePaths.clear();
281 for (const std::string &ipath : copyIn) {
282 if (ipath.empty())
283 continue;
284 if (startsWith(ipath,"%("))
285 continue;
286 std::string s(Path::fromNativeSeparators(ipath));
287 if (!found.insert(s).second)
288 continue;
289 if (s[0] == '/' || (s.size() > 1U && s.compare(1,2,":/") == 0)) {
290 if (!endsWith(s,'/'))
291 s += '/';
292 fs.includePaths.push_back(std::move(s));
293 continue;
294 }
295
296 if (endsWith(s,'/')) // this is a temporary hack, simplifyPath can crash if path ends with '/'
297 s.pop_back();
298
299 if (s.find("$(") == std::string::npos) {
300 s = Path::simplifyPath(basepath + s);
301 } else {
302 if (!simplifyPathWithVariables(s, variables))
303 continue;
304 }
305 if (s.empty())
306 continue;
307 fs.includePaths.push_back(s.back() == '/' ? s : (s + '/'));
308 }
309}
310
311ImportProject::Type ImportProject::import(const std::string &filename, Settings *settings, Suppressions *supprs)
312{

Callers

nothing calls this directly

Calls 10

simplifyPathFunction · 0.85
startsWithFunction · 0.70
endsWithFunction · 0.70
clearMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
compareMethod · 0.45
push_backMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected