[PATCH] D37013: [ELF] - Add additional information about location when emiting linkerscript's parsing errors.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 23 02:54:58 PDT 2017
grimar updated this revision to Diff 112321.
grimar added a comment.
- Addressed review comments.
https://reviews.llvm.org/D37013
Files:
ELF/ScriptLexer.cpp
ELF/ScriptLexer.h
ELF/ScriptParser.cpp
test/ELF/linkerscript/assert.s
test/ELF/linkerscript/diagnostic.s
Index: test/ELF/linkerscript/diagnostic.s
===================================================================
--- test/ELF/linkerscript/diagnostic.s
+++ test/ELF/linkerscript/diagnostic.s
@@ -61,7 +61,8 @@
# RUN: echo "boom .temp : { *(.temp) } }" >> %t.script
# 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: error: {{.*}}.script:4: unable to parse description for output section 'boom':
+# ERR7-NEXT: >>> malformed number: .temp
# ERR7-NEXT: >>> boom .temp : { *(.temp) } }
# ERR7-NEXT: >>> ^
@@ -88,7 +89,8 @@
# RUN: echo "INCLUDE \"%t.script.inc\"" > %t.script
# 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: error: {{.*}}.script.inc:4: unable to parse description for output section 'boom':
+# ERR10-NEXT: >>> malformed number: .temp
# ERR10-NEXT: >>> boom .temp : { *(.temp) } }
# ERR10-NEXT: >>> ^
Index: test/ELF/linkerscript/assert.s
===================================================================
--- test/ELF/linkerscript/assert.s
+++ test/ELF/linkerscript/assert.s
@@ -33,7 +33,8 @@
# RUN: echo "SECTIONS { .foo : { ASSERT(1, \"true\") } }" > %t7.script
# RUN: not ld.lld -shared -o %t7 --script %t7.script %t1.o > %t.log 2>&1
# RUN: FileCheck %s -check-prefix=CHECK-SEMI < %t.log
-# CHECK-SEMI: error: {{.*}}.script:1: ; expected, but got }
+# CHECK-SEMI: error: {{.*}}.script:1: unable to parse description for output section '.foo':
+# CHECK-SEMI-NEXT: >>> ; expected, but got }
.section .foo, "a"
.quad 0
Index: ELF/ScriptParser.cpp
===================================================================
--- ELF/ScriptParser.cpp
+++ ELF/ScriptParser.cpp
@@ -604,6 +604,8 @@
}
OutputSection *ScriptParser::readOutputSectionDescription(StringRef OutSec) {
+ ErrorPrefix = "unable to parse description for output section '" +
+ OutSec.str() + "':\n>>> ";
OutputSection *Cmd =
Script->createOutputSection(OutSec, getCurrentLocation());
@@ -666,6 +668,7 @@
// Consume optional comma following output section command.
consume(",");
+ ErrorPrefix = "";
return Cmd;
}
Index: ELF/ScriptLexer.h
===================================================================
--- ELF/ScriptLexer.h
+++ ELF/ScriptLexer.h
@@ -39,6 +39,7 @@
std::vector<StringRef> Tokens;
bool InExpr = false;
size_t Pos = 0;
+ std::string ErrorPrefix;
private:
void maybeSplitExpr();
Index: ELF/ScriptLexer.cpp
===================================================================
--- ELF/ScriptLexer.cpp
+++ ELF/ScriptLexer.cpp
@@ -78,7 +78,7 @@
if (ErrorCount)
return;
- std::string S = (getCurrentLocation() + ": " + Msg).str();
+ std::string S = getCurrentLocation() + ": " + ErrorPrefix + Msg.str();
if (Pos)
S += "\n>>> " + getLine().str() + "\n>>> " +
std::string(getColumnNumber(), ' ') + "^";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37013.112321.patch
Type: text/x-patch
Size: 3110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170823/6d01a0e1/attachment.bin>
More information about the llvm-commits
mailing list