// 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;
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;
# RUN: mkdir -p %t.dir
+# RUN: echo > %tempty.list
+# RUN: not ld.lld --dynamic-list %tempty.list 2>&1 | FileCheck --check-prefix=EMPTY %s
+# EMPTY: error: {{.*}}.list:1: unexpected EOF
+
# RUN: echo foobar > %t1
# RUN: not ld.lld --dynamic-list %t1 2>&1 | FileCheck -check-prefix=ERR1 %s
# ERR1: {{.*}}:1: { expected, but got foobar
// RUN: not ld.lld --version-script %terr1.script -shared %t.o -o /dev/null 2>&1 | \
// RUN: FileCheck -check-prefix=ERR1 %s
// ERR1: {{.*}}:1: unclosed quote
+
+// RUN: echo > %tempty.ver
+// RUN: not ld.lld --version-script %tempty.ver 2>&1 | \
+// RUN: FileCheck --check-prefix=ERR2 %s
+// ERR2: error: {{.*}}.ver:1: unexpected EOF