[PATCH] D23609: [ELF] - Linkerscript: support VERSION command.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 31 10:48:16 PDT 2016


grimar added a comment.

In https://reviews.llvm.org/D23609#530513, @ruiu wrote:

> Obviously, this patch contains duplicate code which does not look good. Let me create a patch based on this to describe what I was trying to say.


Actually I think I completely understand what you want to see. Something like below probably.
There are still duplications of messages, and only a part of code can be extracted here with no pain.
I can continue working on that tomorrow if you think it is the right direction.

  void ScriptParser::readVersionScript() {
    StringRef Msg = "anonymous version definition is used in "
                    "combination with other version definitions";
    if (skip("{")) {
      readVersionDeclaration("");
      if (!atEOF())
        setError(Msg);
      return;
    }
  
    while (!atEOF() && !Error)
      readNamedVersion();
  }
  
  void ScriptParser::readNamedVersion() {
    StringRef Msg = "anonymous version definition is used in "
                    "combination with other version definitions";
    StringRef VerStr = next();
    if (VerStr == "{") {
      setError(Msg);
      return;
    }
    expect("{");
    readVersionDeclaration(VerStr);
  }
  
  void ScriptParser::readVersion() {
    expect("{");
    if (skip("{")) {
      readVersionDeclaration("");
      expect("}");
      return;
    }
  
    while (!Error) {
      readNamedVersion();
      if (peek() == "}")
        break;
    }
    expect("}");
  }


https://reviews.llvm.org/D23609





More information about the llvm-commits mailing list