bumped simplecpp to 9dc2c3df53 (#4726)

This commit is contained in:
Oliver Stöneberg 2023-01-20 15:41:32 +01:00 committed by GitHub
parent a8fd5cbaf4
commit 99acd3145e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 15 deletions

View File

@ -2796,6 +2796,11 @@ public:
m_pathSet.insert(path);
}
void clear() {
ScopedLock lock(m_criticalSection);
m_pathSet.clear();
}
private:
std::set<std::string> m_pathSet;
CRITICAL_SECTION m_criticalSection;
@ -2807,22 +2812,18 @@ static NonExistingFilesCache nonExistingFilesCache;
static std::string openHeader(std::ifstream &f, const std::string &path)
{
#ifdef SIMPLECPP_WINDOWS
std::string simplePath = simplecpp::simplifyPath(path);
#ifdef SIMPLECPP_WINDOWS
if (nonExistingFilesCache.contains(simplePath))
return ""; // file is known not to exist, skip expensive file open call
#endif
f.open(simplePath.c_str());
if (f.is_open())
return simplePath;
else {
#ifdef SIMPLECPP_WINDOWS
nonExistingFilesCache.add(simplePath);
return "";
}
#else
f.open(path.c_str());
return f.is_open() ? simplecpp::simplifyPath(path) : "";
#endif
return "";
}
static std::string getRelativeFileName(const std::string &sourcefile, const std::string &header)
@ -2864,8 +2865,6 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const
if (systemheader) {
ret = openHeaderIncludePath(f, dui, header);
if (ret.empty())
return openHeaderRelative(f, sourcefile, header);
return ret;
}
@ -2894,8 +2893,8 @@ static std::string getFileName(const std::map<std::string, simplecpp::TokenList
return s;
}
if (filedata.find(relativeFilename) != filedata.end())
return relativeFilename;
if (systemheader && filedata.find(header) != filedata.end())
return header;
return "";
}
@ -2907,6 +2906,11 @@ static bool hasFile(const std::map<std::string, simplecpp::TokenList *> &filedat
std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList)
{
#ifdef SIMPLECPP_WINDOWS
if (dui.clearIncludeCache)
nonExistingFilesCache .clear();
#endif
std::map<std::string, simplecpp::TokenList*> ret;
std::list<const Token *> filelist;
@ -3032,6 +3036,11 @@ static std::string getTimeDefine(struct tm *timep)
void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector<std::string> &files, std::map<std::string, simplecpp::TokenList *> &filedata, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list<simplecpp::MacroUsage> *macroUsage, std::list<simplecpp::IfCond> *ifCond)
{
#ifdef SIMPLECPP_WINDOWS
if (dui.clearIncludeCache)
nonExistingFilesCache.clear();
#endif
std::map<std::string, std::size_t> sizeOfType(rawtokens.sizeOfType);
sizeOfType.insert(std::make_pair("char", sizeof(char)));
sizeOfType.insert(std::make_pair("short", sizeof(short)));
@ -3223,7 +3232,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
const Token * const inctok = inc2.cfront();
const bool systemheader = (inctok->op == '<');
const bool systemheader = (inctok->str()[0] == '<');
const std::string header(realFilename(inctok->str().substr(1U, inctok->str().size() - 2U)));
std::string header2 = getFileName(filedata, rawtok->location.file(), header, dui, systemheader);
if (header2.empty()) {

View File

@ -314,12 +314,13 @@ namespace simplecpp {
* On the command line these are configured by -D, -U, -I, --include, -std
*/
struct SIMPLECPP_LIB DUI {
DUI() {}
DUI() : clearIncludeCache(false) {}
std::list<std::string> defines;
std::set<std::string> undefined;
std::list<std::string> includePaths;
std::list<std::string> includes;
std::string std;
bool clearIncludeCache;
};
SIMPLECPP_LIB long long characterLiteralToLL(const std::string& str);

View File

@ -2483,6 +2483,7 @@ private:
ASSERT_EQUALS(true, Preprocessor::missingSystemIncludeFlag);
ASSERT_EQUALS("[test.c:1]: (information) Include file: \"missing.h\" not found.\n"
"[test.c:2]: (information) Include file: <header.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.\n"
"[test.c:3]: (information) Include file: <missing2.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.\n", errout.str());
Preprocessor::missingIncludeFlag = false;