Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add newlines to strings passed to simplecpp readfile
  • Loading branch information
glankk committed Aug 5, 2026
commit 64fcfd1df81d8efd78cdffb3be03c10dab435497
2 changes: 1 addition & 1 deletion lib/importproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ namespace {
}

static bool evalCondition(const std::string& condition, const ProjectConfiguration &p) {
std::string c = '(' + condition + ")";
std::string c = '(' + condition + ")\n";
replaceAll(c, "$(Configuration)", p.configuration);
replaceAll(c, "$(Platform)", p.platformStr);

Expand Down
2 changes: 1 addition & 1 deletion lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static std::vector<std::string> getnames(const char *names)

static void gettokenlistfromvalid(const std::string& valid, TokenList& tokenList)
{
const std::string str(valid + ',');
const std::string str(valid + ",\n");
tokenList.createTokensFromBuffer(str.data(), str.size()); // TODO: check result?
for (Token *tok = tokenList.front(); tok; tok = tok->next()) {
if (Token::Match(tok,"- %num%")) {
Expand Down
2 changes: 1 addition & 1 deletion lib/programmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ static std::shared_ptr<Token> createTokenFromExpression(const std::string& retur
{
std::shared_ptr<TokenList> tokenList = std::make_shared<TokenList>(settings, cpp ? Standards::Language::CPP : Standards::Language::C);
{
const std::string code = "return " + returnValue + ";";
const std::string code = "return " + returnValue + ";\n";
if (!tokenList->createTokensFromBuffer(code.data(), code.size()))
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8093,7 +8093,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
if (!typestr.empty()) {
ValueType valuetype;
TokenList tokenList(mSettings, tok->isCpp() ? Standards::Language::CPP : Standards::Language::C);
const std::string str(typestr+";");
const std::string str(typestr+";\n");
tokenList.createTokensFromBuffer(str.data(), str.size()); // TODO: check result?
tokenList.simplifyStdType();
if (parsedecl(tokenList.front(), &valuetype, mDefaultSignedness, mSettings)) {
Expand Down Expand Up @@ -8186,7 +8186,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
continue;
}
TokenList tokenList(mSettings, tok->isCpp() ? Standards::Language::CPP : Standards::Language::C);
const std::string str(typestr+";");
const std::string str(typestr+";\n");
if (tokenList.createTokensFromBuffer(str.data(), str.size())) {
ValueType vt;
tokenList.simplifyPlatformTypes();
Expand Down
5 changes: 3 additions & 2 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,8 @@ static bool isNotEqual(std::pair<const Token*, const Token*> x, std::pair<const
static bool isNotEqual(std::pair<const Token*, const Token*> x, const std::string& y, bool cpp, const Settings& settings)
{
TokenList tokenList(settings, cpp ? Standards::Language::CPP : Standards::Language::C);
tokenList.createTokensFromBuffer(y.data(), y.size()); // TODO: check result?
const std::string str(y + "\n");
tokenList.createTokensFromBuffer(str.data(), str.size()); // TODO: check result?
return isNotEqual(x, std::make_pair(tokenList.front(), tokenList.back()));
}
static bool isNotEqual(std::pair<const Token*, const Token*> x, const ValueType* y, bool cpp, const Settings& settings)
Expand Down Expand Up @@ -7095,7 +7096,7 @@ static bool getMinMaxValues(const std::string& typestr,
MathLib::bigint& maxvalue)
{
TokenList typeTokens(settings, cpp ? Standards::Language::CPP : Standards::Language::C);
const std::string str(typestr + ";");
const std::string str(typestr + ";\n");
if (!typeTokens.createTokensFromBuffer(str.data(), str.size()))
return false;
typeTokens.simplifyPlatformTypes();
Expand Down