Skip to content

Commit

Permalink
bumped simplecpp to 1.1.3 (#6422)
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed May 23, 2024
1 parent d518020 commit 2a1500f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions externals/simplecpp/simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
#include <cassert>
#include <cctype>
#include <climits>
#include <cstddef>
#include <cstddef> // IWYU pragma: keep
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <exception>
#include <fstream> // IWYU pragma: keep
#include <fstream>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <set>
#include <sstream> // IWYU pragma: keep
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -1980,7 +1980,7 @@ namespace simplecpp {
if (tok->next->str() == "(")
++paren;
else if (tok->next->str() == ")")
--paren;
--paren;
if (paren == 0)
return tok->next->next;
tok = tok->next;
Expand Down Expand Up @@ -2614,11 +2614,20 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
}

/** Evaluate __has_include(file) */
static bool isCpp17OrLater(const simplecpp::DUI &dui)
{
const std::string std_ver = simplecpp::getCppStdString(dui.std);
return !std_ver.empty() && (std_ver >= "201703L");
}

static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const std::string &sourcefile, const std::string &header, bool systemheader);
static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI &dui)
{
if (!isCpp17OrLater(dui))
return;

for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
if (tok->str() != "__has_include")
if (tok->str() != HAS_INCLUDE)
continue;
simplecpp::Token *tok1 = tok->next;
if (!tok1) {
Expand Down Expand Up @@ -3277,7 +3286,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
// use a dummy vector for the macros because as this is not part of the file and would add an empty entry - e.g. /usr/include/poll.h
std::vector<std::string> dummy;

const bool hasInclude = (dui.std.size() == 5 && dui.std.compare(0,3,"c++") == 0 && dui.std >= "c++17");
const bool hasInclude = isCpp17OrLater(dui);
MacroMap macros;
for (std::list<std::string>::const_iterator it = dui.defines.begin(); it != dui.defines.end(); ++it) {
const std::string &macrostr = *it;
Expand Down

0 comments on commit 2a1500f

Please sign in to comment.