From 31ef266036377ed783cb660ab6a3a3da9f1dea3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 13 Aug 2017 13:59:09 +0200 Subject: [PATCH] bump simplecpp --- externals/simplecpp/simplecpp.cpp | 35 ++++++++++++++++--------------- externals/simplecpp/simplecpp.h | 16 +++++++++----- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index c03e86822..22fac5089 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -202,14 +202,15 @@ simplecpp::TokenList::~TokenList() clear(); } -void simplecpp::TokenList::operator=(const TokenList &other) +simplecpp::TokenList &simplecpp::TokenList::operator=(const TokenList &other) { - if (this == &other) - return; - clear(); - for (const Token *tok = other.cfront(); tok; tok = tok->next) - push_back(new Token(*tok)); - sizeOfType = other.sizeOfType; + if (this != &other) { + clear(); + for (const Token *tok = other.cfront(); tok; tok = tok->next) + push_back(new Token(*tok)); + sizeOfType = other.sizeOfType; + } + return *this; } void simplecpp::TokenList::clear() @@ -1023,25 +1024,25 @@ namespace simplecpp { /** * Expand macro. This will recursively expand inner macros. - * @param output destination tokenlist - * @param rawtok macro token - * @param macros list of macros - * @param files the files + * @param output destination tokenlist + * @param rawtok macro token + * @param macros list of macros + * @param inputFiles the input files * @return token after macro * @throw Can throw wrongNumberOfParameters or invalidHashHash */ const Token * expand(TokenList * const output, const Token * rawtok, const std::map ¯os, - std::vector &files) const { + std::vector &inputFiles) const { std::set expandedmacros; - TokenList output2(files); + TokenList output2(inputFiles); if (functionLike() && rawtok->next && rawtok->next->op == '(') { // Copy macro call to a new tokenlist with no linebreaks const Token * const rawtok1 = rawtok; - TokenList rawtokens2(files); + TokenList rawtokens2(inputFiles); rawtokens2.push_back(new Token(rawtok->str, rawtok1->location)); rawtok = rawtok->next; rawtokens2.push_back(new Token(rawtok->str, rawtok1->location)); @@ -1084,7 +1085,7 @@ namespace simplecpp { const std::map::const_iterator macro = macros.find(macro2tok->str); if (macro == macros.end() || !macro->second.functionLike()) break; - TokenList rawtokens2(files); + TokenList rawtokens2(inputFiles); const Location loc(macro2tok->location); while (macro2tok) { Token *next = macro2tok->next; @@ -1640,7 +1641,7 @@ namespace simplecpp { return nextTok; } - bool isReplaced(const std::set &expandedmacros) const { + static bool isReplaced(const std::set &expandedmacros) { // return true if size > 1 std::set::const_iterator it = expandedmacros.begin(); if (it == expandedmacros.end()) @@ -1760,7 +1761,7 @@ static bool isAbsolutePath(const std::string &path) { if (path.length() >= 3 && path[0] > 0 && std::isalpha(path[0]) && path[1] == ':' && (path[2] == '\\' || path[2] == '/')) return true; - return path.length() > 1U && (path[0] == '/' || path[0] == '/'); + return path.length() > 1U && (path[0] == '/' || path[0] == '\\'); } #else #define realFilename(f) f diff --git a/externals/simplecpp/simplecpp.h b/externals/simplecpp/simplecpp.h index a30385c1c..21fa55254 100644 --- a/externals/simplecpp/simplecpp.h +++ b/externals/simplecpp/simplecpp.h @@ -52,6 +52,8 @@ namespace simplecpp { public: explicit Location(const std::vector &f) : files(f), fileIndex(0), line(1U), col(0U) {} + Location(const Location &loc) : files(loc.files), fileIndex(loc.fileIndex), line(loc.line), col(loc.col) {} + Location &operator=(const Location &other) { if (this != &other) { fileIndex = other.fileIndex; @@ -77,14 +79,15 @@ namespace simplecpp { } const std::string& file() const { - static const std::string temp; - return fileIndex < files.size() ? files[fileIndex] : temp; + return fileIndex < files.size() ? files[fileIndex] : emptyFileName; } const std::vector &files; unsigned int fileIndex; unsigned int line; unsigned int col; + private: + const std::string emptyFileName; }; /** @@ -147,6 +150,9 @@ namespace simplecpp { void printOut() const; private: TokenString string; + + // Not implemented - prevent assignment + Token &operator=(const Token &tok); }; /** Output from preprocessor */ @@ -173,13 +179,13 @@ namespace simplecpp { TokenList(std::istream &istr, std::vector &filenames, const std::string &filename=std::string(), OutputList *outputList = 0); TokenList(const TokenList &other); ~TokenList(); - void operator=(const TokenList &other); + TokenList &operator=(const TokenList &other); void clear(); bool empty() const { return !frontToken; } - void push_back(Token *token); + void push_back(Token *tok); void dump() const; std::string stringify() const; @@ -246,7 +252,7 @@ namespace simplecpp { void constFoldComparison(Token *tok); void constFoldBitwise(Token *tok); void constFoldLogicalOp(Token *tok); - void constFoldQuestionOp(Token **tok); + void constFoldQuestionOp(Token **tok1); std::string readUntil(std::istream &istr, const Location &location, const char start, const char end, OutputList *outputList);