Mercurial > hg > CbC > CbC_llvm
diff lld/ELF/ScriptLexer.cpp @ 221:79ff65ed7e25
LLVM12 Original
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Jun 2021 19:15:29 +0900 |
parents | 0572611fdcc8 |
children | 5f17cb93ff66 |
line wrap: on
line diff
--- a/lld/ELF/ScriptLexer.cpp Tue Jun 15 19:13:43 2021 +0900 +++ b/lld/ELF/ScriptLexer.cpp Tue Jun 15 19:15:29 2021 +0900 @@ -52,6 +52,8 @@ // Returns 1-based line number of the current token. size_t ScriptLexer::getLineNumber() { + if (pos == 0) + return 1; StringRef s = getCurrentMB().getBuffer(); StringRef tok = tokens[pos - 1]; return s.substr(0, tok.data() - s.data()).count('\n') + 1; @@ -144,7 +146,7 @@ if (s.startswith("/*")) { size_t e = s.find("*/", 2); if (e == StringRef::npos) { - error("unclosed comment in a linker script"); + setError("unclosed comment in a linker script"); return ""; } s = s.substr(e + 2); @@ -292,7 +294,9 @@ MemoryBufferRef ScriptLexer::getCurrentMB() { // Find input buffer containing the current token. - assert(!mbs.empty() && pos > 0); + assert(!mbs.empty()); + if (pos == 0) + return mbs.back(); for (MemoryBufferRef mb : mbs) if (encloses(mb.getBuffer(), tokens[pos - 1])) return mb;