[lld] ae4279b - [LLD][ELF] - Linkerscript: report location for the "unclosed comment in a linker script" error.

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 01:39:04 PDT 2020


Author: Georgii Rymar
Date: 2020-07-24T11:38:26+03:00
New Revision: ae4279bd3e8d61dbcff5e30e5090db94fb5a3b0e

URL: https://github.com/llvm/llvm-project/commit/ae4279bd3e8d61dbcff5e30e5090db94fb5a3b0e
DIFF: https://github.com/llvm/llvm-project/commit/ae4279bd3e8d61dbcff5e30e5090db94fb5a3b0e.diff

LOG: [LLD][ELF] - Linkerscript: report location for the "unclosed comment in a linker script" error.

Currently we print "error: unclosed comment in a linker script", which doesn't
provide information about the real error location.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46793.

Differential revision: https://reviews.llvm.org/D84300

Added: 
    

Modified: 
    lld/ELF/ScriptLexer.cpp
    lld/ELF/ScriptLexer.h
    lld/test/ELF/linkerscript/diag6.test

Removed: 
    


################################################################################
diff  --git a/lld/ELF/ScriptLexer.cpp b/lld/ELF/ScriptLexer.cpp
index 9ac8447eef0e..4b16974dd134 100644
--- a/lld/ELF/ScriptLexer.cpp
+++ b/lld/ELF/ScriptLexer.cpp
@@ -146,7 +146,7 @@ StringRef ScriptLexer::skipSpace(StringRef s) {
     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);

diff  --git a/lld/ELF/ScriptLexer.h b/lld/ELF/ScriptLexer.h
index 306d428e98fe..526268e3f65b 100644
--- a/lld/ELF/ScriptLexer.h
+++ b/lld/ELF/ScriptLexer.h
@@ -24,7 +24,7 @@ class ScriptLexer {
 
   void setError(const Twine &msg);
   void tokenize(MemoryBufferRef mb);
-  static StringRef skipSpace(StringRef s);
+  StringRef skipSpace(StringRef s);
   bool atEOF();
   StringRef next();
   StringRef peek();

diff  --git a/lld/test/ELF/linkerscript/diag6.test b/lld/test/ELF/linkerscript/diag6.test
index 276fd1e3cc73..0ec0400040b5 100644
--- a/lld/test/ELF/linkerscript/diag6.test
+++ b/lld/test/ELF/linkerscript/diag6.test
@@ -4,4 +4,4 @@
 
 SECTIONS /*
 
-CHECK: error: unclosed comment in a linker script
+CHECK: error: {{.*}}diag6.test:1: unclosed comment in a linker script


        


More information about the llvm-commits mailing list