◐ Shell
clean mode source ↗

added `DUI::clearIncludeCache` to clear the non-existing files cache by firewave · Pull Request #287 · cppcheck-opensource/simplecpp

Expand Up @@ -2796,6 +2796,11 @@ class NonExistingFilesCache { m_pathSet.insert(path); }
void clear() { ScopedLock lock(m_criticalSection); m_pathSet.clear(); }
private: std::set<std::string> m_pathSet; CRITICAL_SECTION m_criticalSection; Expand All @@ -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 { nonExistingFilesCache.add(simplePath); return ""; } #else f.open(path.c_str()); return f.is_open() ? simplecpp::simplifyPath(path) : ""; #ifdef SIMPLECPP_WINDOWS nonExistingFilesCache.add(simplePath); #endif return ""; }
static std::string getRelativeFileName(const std::string &sourcefile, const std::string &header) Expand Down Expand Up @@ -2907,6 +2908,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; Expand Down Expand Up @@ -3032,6 +3038,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))); Expand Down