[PATCH] D26795: [ELF] Better error reporting for linker scripts

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 18 09:57:38 PST 2016


ruiu added inline comments.


================
Comment at: ELF/LinkerScript.cpp:1131
+
+void ScriptParser::setError(const Twine &Msg) {
+  if (Error)
----------------
Currently, error reporting is zero-cost if there's no error (we find an error location after an error is raised), and that seemed to be a nice hack to use a StringRef's pointer to find a location. However, it didn't work well for INCLUDE as you know. I think we don't want to keep the hack that's proved to be working not well.

Linker scripts are small, so it is OK to do more and use more memory when tokenizing them.

How about this? We can change tokenize to return not only tokens but token locations as a parallel array, like this.

  std::pair<std::vector<StringRef>, std::vector<std::string>>
  tokenize(MemoryBufferRef MB);

ScriptParser class then store the vectors to Tokens and LineNo.


https://reviews.llvm.org/D26795





More information about the llvm-commits mailing list