bumped simplecpp to 9dc2c3df53
(#4726)
This commit is contained in:
parent
a8fd5cbaf4
commit
99acd3145e
|
@ -2796,6 +2796,11 @@ public:
|
||||||
m_pathSet.insert(path);
|
m_pathSet.insert(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
ScopedLock lock(m_criticalSection);
|
||||||
|
m_pathSet.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<std::string> m_pathSet;
|
std::set<std::string> m_pathSet;
|
||||||
CRITICAL_SECTION m_criticalSection;
|
CRITICAL_SECTION m_criticalSection;
|
||||||
|
@ -2807,22 +2812,18 @@ static NonExistingFilesCache nonExistingFilesCache;
|
||||||
|
|
||||||
static std::string openHeader(std::ifstream &f, const std::string &path)
|
static std::string openHeader(std::ifstream &f, const std::string &path)
|
||||||
{
|
{
|
||||||
#ifdef SIMPLECPP_WINDOWS
|
|
||||||
std::string simplePath = simplecpp::simplifyPath(path);
|
std::string simplePath = simplecpp::simplifyPath(path);
|
||||||
|
#ifdef SIMPLECPP_WINDOWS
|
||||||
if (nonExistingFilesCache.contains(simplePath))
|
if (nonExistingFilesCache.contains(simplePath))
|
||||||
return ""; // file is known not to exist, skip expensive file open call
|
return ""; // file is known not to exist, skip expensive file open call
|
||||||
|
#endif
|
||||||
f.open(simplePath.c_str());
|
f.open(simplePath.c_str());
|
||||||
if (f.is_open())
|
if (f.is_open())
|
||||||
return simplePath;
|
return simplePath;
|
||||||
else {
|
#ifdef SIMPLECPP_WINDOWS
|
||||||
nonExistingFilesCache.add(simplePath);
|
nonExistingFilesCache.add(simplePath);
|
||||||
return "";
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
f.open(path.c_str());
|
|
||||||
return f.is_open() ? simplecpp::simplifyPath(path) : "";
|
|
||||||
#endif
|
#endif
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string getRelativeFileName(const std::string &sourcefile, const std::string &header)
|
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) {
|
if (systemheader) {
|
||||||
ret = openHeaderIncludePath(f, dui, header);
|
ret = openHeaderIncludePath(f, dui, header);
|
||||||
if (ret.empty())
|
|
||||||
return openHeaderRelative(f, sourcefile, header);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2894,8 +2893,8 @@ static std::string getFileName(const std::map<std::string, simplecpp::TokenList
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filedata.find(relativeFilename) != filedata.end())
|
if (systemheader && filedata.find(header) != filedata.end())
|
||||||
return relativeFilename;
|
return header;
|
||||||
|
|
||||||
return "";
|
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)
|
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::map<std::string, simplecpp::TokenList*> ret;
|
||||||
|
|
||||||
std::list<const Token *> filelist;
|
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)
|
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);
|
std::map<std::string, std::size_t> sizeOfType(rawtokens.sizeOfType);
|
||||||
sizeOfType.insert(std::make_pair("char", sizeof(char)));
|
sizeOfType.insert(std::make_pair("char", sizeof(char)));
|
||||||
sizeOfType.insert(std::make_pair("short", sizeof(short)));
|
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 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)));
|
const std::string header(realFilename(inctok->str().substr(1U, inctok->str().size() - 2U)));
|
||||||
std::string header2 = getFileName(filedata, rawtok->location.file(), header, dui, systemheader);
|
std::string header2 = getFileName(filedata, rawtok->location.file(), header, dui, systemheader);
|
||||||
if (header2.empty()) {
|
if (header2.empty()) {
|
||||||
|
|
|
@ -314,12 +314,13 @@ namespace simplecpp {
|
||||||
* On the command line these are configured by -D, -U, -I, --include, -std
|
* On the command line these are configured by -D, -U, -I, --include, -std
|
||||||
*/
|
*/
|
||||||
struct SIMPLECPP_LIB DUI {
|
struct SIMPLECPP_LIB DUI {
|
||||||
DUI() {}
|
DUI() : clearIncludeCache(false) {}
|
||||||
std::list<std::string> defines;
|
std::list<std::string> defines;
|
||||||
std::set<std::string> undefined;
|
std::set<std::string> undefined;
|
||||||
std::list<std::string> includePaths;
|
std::list<std::string> includePaths;
|
||||||
std::list<std::string> includes;
|
std::list<std::string> includes;
|
||||||
std::string std;
|
std::string std;
|
||||||
|
bool clearIncludeCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
SIMPLECPP_LIB long long characterLiteralToLL(const std::string& str);
|
SIMPLECPP_LIB long long characterLiteralToLL(const std::string& str);
|
||||||
|
|
|
@ -2483,6 +2483,7 @@ private:
|
||||||
ASSERT_EQUALS(true, Preprocessor::missingSystemIncludeFlag);
|
ASSERT_EQUALS(true, Preprocessor::missingSystemIncludeFlag);
|
||||||
|
|
||||||
ASSERT_EQUALS("[test.c:1]: (information) Include file: \"missing.h\" not found.\n"
|
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());
|
"[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;
|
Preprocessor::missingIncludeFlag = false;
|
||||||
|
|
Loading…
Reference in New Issue