@@ -814,14 +814,11 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe
814814
815815 fin.open (cur.c_str ());
816816 if (!fin.is_open ()) {
817- if (_settings && !_settings->nomsg .isSuppressed (" missingInclude" , Path::fromNativeSeparators (cur), 1 )) {
818- missingIncludeFlag = true ;
819- if (_settings->checkConfiguration ) {
820- missingInclude (Path::toNativeSeparators (Path::getPathFromFilename (cur)),
821- 1 ,
822- cur);
823- }
824- }
817+ missingInclude (cur,
818+ 1 ,
819+ cur,
820+ UserHeader
821+ );
825822 continue ;
826823 }
827824 std::string fileData = read (fin, filename);
@@ -2088,14 +2085,11 @@ std::string Preprocessor::handleIncludes(const std::string &code, const std::str
20882085 filepath = path;
20892086 std::ifstream fin;
20902087 if (!openHeader (filename, includePaths, filepath, fin)) {
2091- if (_settings && !_settings->nomsg .isSuppressed (" missingInclude" , Path::fromNativeSeparators (filename), linenr)) {
2092- missingIncludeFlag = true ;
2093-
2094- if (_settings->checkConfiguration )
2095- missingInclude (Path::toNativeSeparators (filePath),
2096- linenr,
2097- filename);
2098- }
2088+ missingInclude (Path::toNativeSeparators (filePath),
2089+ linenr,
2090+ filename,
2091+ headerType
2092+ );
20992093 ostr << std::endl;
21002094 continue ;
21012095 }
@@ -2216,31 +2210,35 @@ void Preprocessor::handleIncludes(std::string &code, const std::string &filePath
22162210 }
22172211 }
22182212
2219- if (!_settings->nomsg .isSuppressed (" missingInclude" , Path::fromNativeSeparators (f), linenr)) {
2220- missingIncludeFlag = true ;
2221- if (_errorLogger && _settings->checkConfiguration ) {
2222- missingInclude (Path::toNativeSeparators (f),
2223- linenr,
2224- filename);
2225- }
2226- }
2213+ missingInclude (Path::toNativeSeparators (f),
2214+ linenr,
2215+ filename,
2216+ headerType);
22272217 }
22282218 }
22292219}
22302220
22312221// Report that include is missing
2232- void Preprocessor::missingInclude (const std::string &filename, unsigned int linenr, const std::string &header)
2222+ void Preprocessor::missingInclude (const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType )
22332223{
2234- std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
2235- if (!filename.empty ()) {
2236- ErrorLogger::ErrorMessage::FileLocation loc;
2237- loc.line = linenr;
2238- loc.setfile (filename);
2239- locationList.push_back (loc);
2224+ const std::string msgtype = (headerType==SystemHeader)?" missingIncludeSystem" :" missingInclude" ;
2225+ if (!_settings->nomsg .isSuppressed (msgtype, Path::fromNativeSeparators (filename), linenr)) {
2226+ missingIncludeFlag = true ;
2227+ if (_errorLogger && _settings->checkConfiguration ) {
2228+
2229+ std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
2230+ if (!filename.empty ()) {
2231+ ErrorLogger::ErrorMessage::FileLocation loc;
2232+ loc.line = linenr;
2233+ loc.setfile (Path::toNativeSeparators (filename));
2234+ locationList.push_back (loc);
2235+ }
2236+ ErrorLogger::ErrorMessage errmsg (locationList, Severity::information, " Include file: \" " + header + " \" not found." ,
2237+ msgtype, false );
2238+ errmsg.file0 = file0;
2239+ _errorLogger->reportInfo (errmsg);
2240+ }
22402241 }
2241- ErrorLogger::ErrorMessage errmsg (locationList, Severity::information, " Include file: \" " + header + " \" not found." , " missingInclude" , false );
2242- errmsg.file0 = file0;
2243- _errorLogger->reportInfo (errmsg);
22442242}
22452243
22462244/* *
@@ -3039,7 +3037,8 @@ void Preprocessor::getErrorMessages(ErrorLogger *errorLogger, const Settings *se
30393037{
30403038 Settings settings2 (*settings);
30413039 Preprocessor preprocessor (&settings2, errorLogger);
3042- preprocessor.missingInclude (" " , 1 , " " );
3040+ preprocessor.missingInclude (" " , 1 , " " , UserHeader);
3041+ preprocessor.missingInclude (" " , 1 , " " , SystemHeader);
30433042 preprocessor.validateCfgError (" X" );
30443043 preprocessor.error (" " , 1 , " #error message" ); // #error ..
30453044}
0 commit comments