diff options
Diffstat (limited to 'lld/ELF/ScriptLexer.cpp')
| -rw-r--r-- | lld/ELF/ScriptLexer.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lld/ELF/ScriptLexer.cpp b/lld/ELF/ScriptLexer.cpp index 236a188324cd..e0a8ed7121a8 100644 --- a/lld/ELF/ScriptLexer.cpp +++ b/lld/ELF/ScriptLexer.cpp @@ -34,6 +34,8 @@ #include "ScriptLexer.h" #include "lld/Common/ErrorHandler.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/ErrorHandling.h" +#include <algorithm> using namespace llvm; using namespace lld; @@ -132,10 +134,14 @@ void ScriptLexer::tokenize(MemoryBufferRef mb) { continue; } - // ">foo" is parsed to ">" and "foo", but ">>" is parsed to ">>". - // "|", "||", "&" and "&&" are different operators. - if (s.startswith("<<") || s.startswith("<=") || s.startswith(">>") || - s.startswith(">=") || s.startswith("||") || s.startswith("&&")) { + // Some operators form separate tokens. + if (s.startswith("<<=") || s.startswith(">>=")) { + vec.push_back(s.substr(0, 3)); + s = s.substr(3); + continue; + } + if (s.size() > 1 && ((s[1] == '=' && strchr("*/+-<>&|", s[0])) || + (s[0] == s[1] && strchr("<>&|", s[0])))) { vec.push_back(s.substr(0, 2)); s = s.substr(2); continue; @@ -190,7 +196,7 @@ bool ScriptLexer::atEOF() { return errorCount() || tokens.size() == pos; } // Split a given string as an expression. // This function returns "3", "*" and "5" for "3*5" for example. static std::vector<StringRef> tokenizeExpr(StringRef s) { - StringRef ops = "+-*/:!~=<>"; // List of operators + StringRef ops = "!~*/+-<>?:="; // List of operators // Quoted strings are literal strings, so we don't want to split it. if (s.startswith("\"")) |
