bump simplecpp

This commit is contained in:
Daniel Marjamäki 2017-08-13 13:59:09 +02:00
parent a007ba7d3c
commit 31ef266036
2 changed files with 29 additions and 22 deletions

View File

@ -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;
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()
@ -1026,22 +1027,22 @@ namespace simplecpp {
* @param output destination tokenlist
* @param rawtok macro token
* @param macros list of macros
* @param files the files
* @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<TokenString,Macro> &macros,
std::vector<std::string> &files) const {
std::vector<std::string> &inputFiles) const {
std::set<TokenString> 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<TokenString,Macro>::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<std::string> &expandedmacros) const {
static bool isReplaced(const std::set<std::string> &expandedmacros) {
// return true if size > 1
std::set<std::string>::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

View File

@ -52,6 +52,8 @@ namespace simplecpp {
public:
explicit Location(const std::vector<std::string> &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<std::string> &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<std::string> &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);