@@ -2796,6 +2796,11 @@ class NonExistingFilesCache {
2796
2796
m_pathSet.insert (path);
2797
2797
}
2798
2798
2799
+ void clear () {
2800
+ ScopedLock lock (m_criticalSection);
2801
+ m_pathSet.clear ();
2802
+ }
2803
+
2799
2804
private:
2800
2805
std::set<std::string> m_pathSet;
2801
2806
CRITICAL_SECTION m_criticalSection;
@@ -2807,22 +2812,18 @@ static NonExistingFilesCache nonExistingFilesCache;
2807
2812
2808
2813
static std::string openHeader (std::ifstream &f, const std::string &path)
2809
2814
{
2810
- #ifdef SIMPLECPP_WINDOWS
2811
2815
std::string simplePath = simplecpp::simplifyPath (path);
2816
+ #ifdef SIMPLECPP_WINDOWS
2812
2817
if (nonExistingFilesCache.contains (simplePath))
2813
2818
return " " ; // file is known not to exist, skip expensive file open call
2814
-
2819
+ # endif
2815
2820
f.open (simplePath.c_str ());
2816
2821
if (f.is_open ())
2817
2822
return simplePath;
2818
- else {
2819
- nonExistingFilesCache.add (simplePath);
2820
- return " " ;
2821
- }
2822
- #else
2823
- f.open (path.c_str ());
2824
- return f.is_open () ? simplecpp::simplifyPath (path) : " " ;
2823
+ #ifdef SIMPLECPP_WINDOWS
2824
+ nonExistingFilesCache.add (simplePath);
2825
2825
#endif
2826
+ return " " ;
2826
2827
}
2827
2828
2828
2829
static std::string getRelativeFileName (const std::string &sourcefile, const std::string &header)
@@ -2905,6 +2906,11 @@ static bool hasFile(const std::map<std::string, simplecpp::TokenList *> &filedat
2905
2906
2906
2907
std::map<std::string, simplecpp::TokenList*> simplecpp::load (const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList)
2907
2908
{
2909
+ #ifdef SIMPLECPP_WINDOWS
2910
+ if (dui.clearIncludeCache )
2911
+ nonExistingFilesCache .clear ();
2912
+ #endif
2913
+
2908
2914
std::map<std::string, simplecpp::TokenList*> ret;
2909
2915
2910
2916
std::list<const Token *> filelist;
@@ -3030,6 +3036,11 @@ static std::string getTimeDefine(struct tm *timep)
3030
3036
3031
3037
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)
3032
3038
{
3039
+ #ifdef SIMPLECPP_WINDOWS
3040
+ if (dui.clearIncludeCache )
3041
+ nonExistingFilesCache.clear ();
3042
+ #endif
3043
+
3033
3044
std::map<std::string, std::size_t > sizeOfType (rawtokens.sizeOfType );
3034
3045
sizeOfType.insert (std::make_pair (" char" , sizeof (char )));
3035
3046
sizeOfType.insert (std::make_pair (" short" , sizeof (short )));
0 commit comments