[PATCH] Convert other drivers to use WrapperNode.

Shankar Kalpathi Easwaran shankarke at gmail.com
Wed Jan 7 20:06:50 PST 2015


REPOSITORY
  rL LLVM

================
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;
+  };
+
----------------
How is the attribute accessed from the file ? I didnt see a accessor function, am I missing some detail ?

================
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;
+      }
----------------
how is attributes going to be passed ?

http://reviews.llvm.org/D6874

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






More information about the llvm-commits mailing list