Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions externals/simplecpp/simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3134,6 +3134,21 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const
return openHeaderIncludePath(f, dui, header);
return ret;
}
static bool IsFileExists(const std::string& simplePath)
{
if (simplePath.empty())
{
return false;
}

std::ifstream ifs(simplePath);
if (ifs.good())
{
return true;
}

return false;
}

static std::string getFileName(const std::map<std::string, simplecpp::TokenList *> &filedata, const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader)
{
Expand All @@ -3144,11 +3159,18 @@ static std::string getFileName(const std::map<std::string, simplecpp::TokenList
return (filedata.find(header) != filedata.end()) ? simplecpp::simplifyPath(header) : "";
}

if (!systemheader) {
const std::string relativeFilename = getRelativeFileName(sourcefile, header);
if (filedata.find(relativeFilename) != filedata.end())
return relativeFilename;
}
if (!systemheader) {
const std::string relativeFilename = getRelativeFileName(sourcefile, header);
if (filedata.find(relativeFilename) != filedata.end())
return relativeFilename;

// If relativeFilename is not found in filedata, check if it exists on disk
// If the file exists, load it
if (IsFileExists(relativeFilename))
{
return "";
}
}

for (std::list<std::string>::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) {
std::string s = simplecpp::simplifyPath(getIncludePathFileName(*it, header));
Expand Down
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6158,7 +6158,7 @@ void Tokenizer::dump(std::ostream &out) const
}
containers.insert(tok->valueType()->container);
}
if (!tok->varId() && tok->scope()->isExecutable() && Token::Match(tok, "%name% (")) {
if (!tok->varId() && tok->scope() && tok->scope()->isExecutable() && Token::Match(tok, "%name% (")) {
if (mSettings.library.isnoreturn(tok))
outs += " noreturn=\"true\"";
}
Expand Down