CLI: add -isystem include paths when running Clang

This commit is contained in:
Daniel Marjamäki 2020-02-02 16:35:42 +01:00
parent 894497e704
commit a9f55f4985
2 changed files with 9 additions and 5 deletions

View File

@ -251,7 +251,8 @@ const char * CppCheck::extraVersion()
unsigned int CppCheck::check(const std::string &path) unsigned int CppCheck::check(const std::string &path)
{ {
if (mSettings.clang) { if (mSettings.clang) {
mErrorLogger.reportOut(std::string("Checking ") + path + "..."); if (!mSettings.quiet)
mErrorLogger.reportOut(std::string("Checking ") + path + "...");
const std::string clang = Path::isCPP(path) ? "clang++" : "clang"; const std::string clang = Path::isCPP(path) ? "clang++" : "clang";
const std::string temp = mSettings.buildDir + (Path::isCPP(path) ? "/__temp__.cpp" : "/__temp__.c"); const std::string temp = mSettings.buildDir + (Path::isCPP(path) ? "/__temp__.cpp" : "/__temp__.c");
@ -364,8 +365,10 @@ unsigned int CppCheck::check(const ImportProject::FileSettings &fs)
temp.mSettings.userUndefs = fs.undefs; temp.mSettings.userUndefs = fs.undefs;
if (fs.platformType != Settings::Unspecified) if (fs.platformType != Settings::Unspecified)
temp.mSettings.platform(fs.platformType); temp.mSettings.platform(fs.platformType);
if (mSettings.clang) if (mSettings.clang) {
temp.mSettings.includePaths.insert(temp.mSettings.includePaths.end(), fs.systemIncludePaths.cbegin(), fs.systemIncludePaths.cend());
temp.check(Path::simplifyPath(fs.filename)); temp.check(Path::simplifyPath(fs.filename));
}
std::ifstream fin(fs.filename); std::ifstream fin(fs.filename);
return temp.checkFile(Path::simplifyPath(fs.filename), fs.cfg, fin); return temp.checkFile(Path::simplifyPath(fs.filename), fs.cfg, fin);
} }

View File

@ -255,9 +255,10 @@ void ImportProject::FileSettings::parseCommand(const std::string &command)
defs += ';'; defs += ';';
} else if (F=='U') } else if (F=='U')
undefs.insert(fval); undefs.insert(fval);
else if (F=='I') else if (F=='I') {
includePaths.push_back(fval); if (std::find(includePaths.begin(), includePaths.end(), fval) == includePaths.end())
else if (F=='s' && fval.compare(0,2,"td") == 0) { includePaths.push_back(fval);
} else if (F=='s' && fval.compare(0,2,"td") == 0) {
++pos; ++pos;
const std::string stdval = readUntil(command, &pos, " "); const std::string stdval = readUntil(command, &pos, " ");
standard = stdval; standard = stdval;