Fixed #4594 (Analyzing errors about system headers not being found)
This commit is contained in:
parent
ee942c5592
commit
59d636742e
|
@ -814,14 +814,11 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe
|
||||||
|
|
||||||
fin.open(cur.c_str());
|
fin.open(cur.c_str());
|
||||||
if (!fin.is_open()) {
|
if (!fin.is_open()) {
|
||||||
if (_settings && !_settings->nomsg.isSuppressed("missingInclude", Path::fromNativeSeparators(cur), 1)) {
|
missingInclude(cur,
|
||||||
missingIncludeFlag = true;
|
1,
|
||||||
if (_settings->checkConfiguration) {
|
cur,
|
||||||
missingInclude(Path::toNativeSeparators(Path::getPathFromFilename(cur)),
|
UserHeader
|
||||||
1,
|
);
|
||||||
cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::string fileData = read(fin, filename);
|
std::string fileData = read(fin, filename);
|
||||||
|
@ -2088,14 +2085,11 @@ std::string Preprocessor::handleIncludes(const std::string &code, const std::str
|
||||||
filepath = path;
|
filepath = path;
|
||||||
std::ifstream fin;
|
std::ifstream fin;
|
||||||
if (!openHeader(filename, includePaths, filepath, fin)) {
|
if (!openHeader(filename, includePaths, filepath, fin)) {
|
||||||
if (_settings && !_settings->nomsg.isSuppressed("missingInclude", Path::fromNativeSeparators(filename), linenr)) {
|
missingInclude(Path::toNativeSeparators(filePath),
|
||||||
missingIncludeFlag = true;
|
linenr,
|
||||||
|
filename,
|
||||||
if (_settings->checkConfiguration)
|
headerType
|
||||||
missingInclude(Path::toNativeSeparators(filePath),
|
);
|
||||||
linenr,
|
|
||||||
filename);
|
|
||||||
}
|
|
||||||
ostr << std::endl;
|
ostr << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2216,31 +2210,35 @@ void Preprocessor::handleIncludes(std::string &code, const std::string &filePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_settings->nomsg.isSuppressed("missingInclude", Path::fromNativeSeparators(f), linenr)) {
|
missingInclude(Path::toNativeSeparators(f),
|
||||||
missingIncludeFlag = true;
|
linenr,
|
||||||
if (_errorLogger && _settings->checkConfiguration) {
|
filename,
|
||||||
missingInclude(Path::toNativeSeparators(f),
|
headerType);
|
||||||
linenr,
|
|
||||||
filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report that include is missing
|
// Report that include is missing
|
||||||
void Preprocessor::missingInclude(const std::string &filename, unsigned int linenr, const std::string &header)
|
void Preprocessor::missingInclude(const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType)
|
||||||
{
|
{
|
||||||
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
|
const std::string msgtype = (headerType==SystemHeader)?"missingIncludeSystem":"missingInclude";
|
||||||
if (!filename.empty()) {
|
if (!_settings->nomsg.isSuppressed(msgtype, Path::fromNativeSeparators(filename), linenr)) {
|
||||||
ErrorLogger::ErrorMessage::FileLocation loc;
|
missingIncludeFlag = true;
|
||||||
loc.line = linenr;
|
if (_errorLogger && _settings->checkConfiguration) {
|
||||||
loc.setfile(filename);
|
|
||||||
locationList.push_back(loc);
|
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
|
||||||
|
if (!filename.empty()) {
|
||||||
|
ErrorLogger::ErrorMessage::FileLocation loc;
|
||||||
|
loc.line = linenr;
|
||||||
|
loc.setfile(Path::toNativeSeparators(filename));
|
||||||
|
locationList.push_back(loc);
|
||||||
|
}
|
||||||
|
ErrorLogger::ErrorMessage errmsg(locationList, Severity::information, "Include file: \"" + header + "\" not found.",
|
||||||
|
msgtype, false);
|
||||||
|
errmsg.file0 = file0;
|
||||||
|
_errorLogger->reportInfo(errmsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ErrorLogger::ErrorMessage errmsg(locationList, Severity::information, "Include file: \"" + header + "\" not found.", "missingInclude", false);
|
|
||||||
errmsg.file0 = file0;
|
|
||||||
_errorLogger->reportInfo(errmsg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3039,7 +3037,8 @@ void Preprocessor::getErrorMessages(ErrorLogger *errorLogger, const Settings *se
|
||||||
{
|
{
|
||||||
Settings settings2(*settings);
|
Settings settings2(*settings);
|
||||||
Preprocessor preprocessor(&settings2, errorLogger);
|
Preprocessor preprocessor(&settings2, errorLogger);
|
||||||
preprocessor.missingInclude("", 1, "");
|
preprocessor.missingInclude("", 1, "", UserHeader);
|
||||||
|
preprocessor.missingInclude("", 1, "", SystemHeader);
|
||||||
preprocessor.validateCfgError("X");
|
preprocessor.validateCfgError("X");
|
||||||
preprocessor.error("", 1, "#error message"); // #error ..
|
preprocessor.error("", 1, "#error message"); // #error ..
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void missingInclude(const std::string &filename, unsigned int linenr, const std::string &header);
|
void missingInclude(const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType);
|
||||||
|
|
||||||
void error(const std::string &filename, unsigned int linenr, const std::string &msg);
|
void error(const std::string &filename, unsigned int linenr, const std::string &msg);
|
||||||
|
|
||||||
|
|
|
@ -3362,7 +3362,7 @@ private:
|
||||||
ASSERT_EQUALS("[test.c:1]: (information) Include file: \"missing-include!!.h\" not found.\n", errout.str());
|
ASSERT_EQUALS("[test.c:1]: (information) Include file: \"missing-include!!.h\" not found.\n", errout.str());
|
||||||
|
|
||||||
errout.str("");
|
errout.str("");
|
||||||
settings.nomsg.addSuppression("missingInclude");
|
settings.nomsg.addSuppression("missingIncludeSystem");
|
||||||
preprocessor.handleIncludes(code,"test.c",includePaths,defs);
|
preprocessor.handleIncludes(code,"test.c",includePaths,defs);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue