[PATCH] Convert other drivers to use WrapperNode.

Rui Ueyama ruiu at google.com
Thu Jan 8 10:10:50 PST 2015


================
Comment at: include/lld/ReaderWriter/ELFLinkingContext.h:293-313
@@ -292,1 +292,23 @@
 
+  /// \brief The attributes class provides a way for a input file to look into
+  /// all the positional attributes that were specified in the command line.
+  /// There are few positional operators and the number of arguments to the
+  /// ELFFileNode class keeps growing. This achieves code to be clean as well.
+  class Attributes {
+  public:
+    Attributes()
+        : _isWholeArchive(false), _asNeeded(false), _isDashlPrefix(false),
+          _isSysRooted(false) {}
+    void setWholeArchive(bool isWholeArchive) {
+      _isWholeArchive = isWholeArchive;
+    }
+    void setAsNeeded(bool asNeeded) { _asNeeded = asNeeded; }
+    void setDashlPrefix(bool isDashlPrefix) { _isDashlPrefix = isDashlPrefix; }
+    void setSysRooted(bool isSysRooted) { _isSysRooted = isSysRooted; }
+
+    bool _isWholeArchive;
+    bool _asNeeded;
+    bool _isDashlPrefix;
+    bool _isSysRooted;
+  };
+
----------------
shankarke wrote:
> How is the attribute accessed from the file ? I didnt see a accessor function, am I missing some detail ?
Well, that would be a question for you. :) The code was incomplete. I moved this piece of code from other file to this file. It's not new. Apparently we need more code to support these attributes but that's out of scope of this patch.

================
Comment at: lib/Driver/GnuLdDriver.cpp:261-280
@@ -254,9 +260,22 @@
     for (const script::Path &path : group->getPaths()) {
       // TODO : Propagate Set WholeArchive/dashlPrefix
-      ELFFileNode::Attributes attr;
+      ELFLinkingContext::Attributes attr;
       attr.setSysRooted(sysroot);
       attr.setAsNeeded(path._asNeeded);
       attr.setDashlPrefix(path._isDashlPrefix);
-      ++numfiles;
-      inputGraph->addInputElement(llvm::make_unique<ELFFileNode>(
-                                      ctx, ctx.allocateString(path._path), attr));
+
+      ErrorOr<StringRef> pathOrErr = path._isDashlPrefix
+          ? ctx.searchLibrary(path._path) : ctx.searchFile(path._path, sysroot);
+      if (std::error_code ec = pathOrErr.getError())
+        return make_dynamic_error_code(
+            Twine("Unable to find file ") + path._path + ": " + ec.message());
+
+      std::vector<std::unique_ptr<File>> files
+          = parseFile(ctx, pathOrErr.get(), false);
+      for (std::unique_ptr<File> &file : files) {
+        if (ctx.logInputFiles())
+          diag << file->path() << "\n";
+        inputGraph->addInputElement(
+            std::unique_ptr<InputElement>(new WrapperNode(std::move(file))));
+        ++numfiles;
+      }
----------------
shankarke wrote:
> how is attributes going to be passed ? 
Attributes are not passed at this moment at least, and that's not actually a new behavior. ELFFileNode didn't use that attribute (other than printing a debug message). Maybe we should remove that. I'd think that doesn't have to be done in this patch.

http://reviews.llvm.org/D6874

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list