[lld] r311537 - [ELF] - Do not report multiple errors for single one in ScriptLexer::setError.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 23 01:48:40 PDT 2017
Author: grimar
Date: Wed Aug 23 01:48:39 2017
New Revision: 311537
URL: http://llvm.org/viewvc/llvm-project?rev=311537&view=rev
Log:
[ELF] - Do not report multiple errors for single one in ScriptLexer::setError.
Previously up to 3 errors were reported at once,
with patch we always will report only one,
just like in other linker code.
Differential revision: https://reviews.llvm.org/D37015
Modified:
lld/trunk/ELF/ScriptLexer.cpp
lld/trunk/test/ELF/linkerscript/diagnostic.s
lld/trunk/test/ELF/linkerscript/linkerscript.s
Modified: lld/trunk/ELF/ScriptLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptLexer.cpp?rev=311537&r1=311536&r2=311537&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptLexer.cpp (original)
+++ lld/trunk/ELF/ScriptLexer.cpp Wed Aug 23 01:48:39 2017
@@ -78,15 +78,11 @@ void ScriptLexer::setError(const Twine &
if (ErrorCount)
return;
- if (!Pos) {
- error(getCurrentLocation() + ": " + Msg);
- return;
- }
-
- std::string S = getCurrentLocation() + ": ";
- error(S + Msg);
- error(S + getLine());
- error(S + std::string(getColumnNumber(), ' ') + "^");
+ std::string S = (getCurrentLocation() + ": " + Msg).str();
+ if (Pos)
+ S += "\n>>> " + getLine().str() + "\n>>> " +
+ std::string(getColumnNumber(), ' ') + "^";
+ error(S);
}
// Split S into linker script tokens.
Modified: lld/trunk/test/ELF/linkerscript/diagnostic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/diagnostic.s?rev=311537&r1=311536&r2=311537&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/diagnostic.s (original)
+++ lld/trunk/test/ELF/linkerscript/diagnostic.s Wed Aug 23 01:48:39 2017
@@ -50,9 +50,9 @@
# RUN: echo ".temp : { *(.temp) } }" >> %t.script
# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \
# RUN: FileCheck -check-prefix=ERR6 -strict-whitespace %s
-# ERR6: error: {{.*}}.script:1:
-# ERR6-NEXT: error: {{.*}}.script:1: UNKNOWN_TAG {
-# ERR6-NEXT: error: {{.*}}.script:1: ^
+# ERR6: error: {{.*}}.script:1: unknown directive: UNKNOWN_TAG
+# ERR6-NEXT: >>> UNKNOWN_TAG {
+# ERR6-NEXT: >>> ^
## One more check that text of lines and pointer to 'bad' token are working ok.
# RUN: echo "SECTIONS {" > %t.script
@@ -62,8 +62,8 @@
# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \
# RUN: FileCheck -check-prefix=ERR7 -strict-whitespace %s
# ERR7: error: {{.*}}.script:4: malformed number: .temp
-# ERR7-NEXT: error: {{.*}}.script:4: boom .temp : { *(.temp) } }
-# ERR7-NEXT: error: {{.*}}.script:4: ^
+# ERR7-NEXT: >>> boom .temp : { *(.temp) } }
+# ERR7-NEXT: >>> ^
## Check tokenize() error
# RUN: echo "SECTIONS {}" > %t.script
@@ -89,8 +89,8 @@
# RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \
# RUN: FileCheck -check-prefix=ERR10 -strict-whitespace %s
# ERR10: error: {{.*}}.script.inc:4: malformed number: .temp
-# ERR10-NEXT: error: {{.*}}.script.inc:4: boom .temp : { *(.temp) } }
-# ERR10-NEXT: error: {{.*}}.script.inc:4: ^
+# ERR10-NEXT: >>> boom .temp : { *(.temp) } }
+# ERR10-NEXT: >>> ^
## Check error reporting in script with INCLUDE directive.
# RUN: echo "SECTIONS {" > %t.script.inc
Modified: lld/trunk/test/ELF/linkerscript/linkerscript.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript.s?rev=311537&r1=311536&r2=311537&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript.s Wed Aug 23 01:48:39 2017
@@ -38,7 +38,7 @@
# RUN: not ld.lld %t.script > %t.log 2>&1
# RUN: FileCheck -check-prefix=INCLUDE_ERR %s < %t.log
# INCLUDE_ERR: error: {{.+}}.script:1: cannot open foo.script
-# INCLUDE_ERR-NEXT: error: {{.+}}.script:1: INCLUDE "foo.script"
+# INCLUDE_ERR-NEXT: INCLUDE "foo.script"
# RUN: ld.lld -L %T %t.script %t
# RUN: echo "FOO(BAR)" > %t.script
More information about the llvm-commits
mailing list