[lld] r189865 - [PECOFF] Fix fixme by making PECOFFLinkingContext non-const.

Rui Ueyama ruiu at google.com
Tue Sep 3 15:33:56 PDT 2013


Author: ruiu
Date: Tue Sep  3 17:33:56 2013
New Revision: 189865

URL: http://llvm.org/viewvc/llvm-project?rev=189865&view=rev
Log:
[PECOFF] Fix fixme by making PECOFFLinkingContext non-const.

Modified:
    lld/trunk/include/lld/ReaderWriter/Reader.h
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp

Modified: lld/trunk/include/lld/ReaderWriter/Reader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/Reader.h?rev=189865&r1=189864&r2=189865&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/Reader.h (original)
+++ lld/trunk/include/lld/ReaderWriter/Reader.h Tue Sep  3 17:33:56 2013
@@ -21,6 +21,7 @@ class ELFLinkingContext;
 class File;
 class LinkerInput;
 class LinkingContext;
+class PECOFFLinkingContext;
 
 /// \brief An abstract class for reading object files, library files, and
 /// executable files.
@@ -54,7 +55,7 @@ typedef ErrorOr<Reader &> ReaderFunc(con
 std::unique_ptr<Reader> createReaderELF(const ELFLinkingContext &);
 std::unique_ptr<Reader> createReaderMachO(const LinkingContext &);
 std::unique_ptr<Reader> createReaderNative(const LinkingContext &);
-std::unique_ptr<Reader> createReaderPECOFF(const LinkingContext &);
+std::unique_ptr<Reader> createReaderPECOFF(PECOFFLinkingContext &);
 std::unique_ptr<Reader> createReaderYAML(const LinkingContext &);
 } // end namespace lld
 

Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=189865&r1=189864&r2=189865&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Tue Sep  3 17:33:56 2013
@@ -14,6 +14,7 @@
 
 #include "lld/Core/File.h"
 #include "lld/Driver/Driver.h"
+#include "lld/ReaderWriter/PECOFFLinkingContext.h"
 #include "lld/ReaderWriter/Reader.h"
 #include "lld/ReaderWriter/ReaderArchive.h"
 
@@ -655,8 +656,9 @@ private:
 
 class ReaderCOFF : public Reader {
 public:
-  explicit ReaderCOFF(const LinkingContext &context)
-      : Reader(context), _readerArchive(context, *this) {}
+  explicit ReaderCOFF(PECOFFLinkingContext &context)
+      : Reader(context), _readerArchive(context, *this),
+        _PECOFFLinkingContext(context) {}
 
   error_code parseFile(std::unique_ptr<MemoryBuffer> &mb,
                        std::vector<std::unique_ptr<File>> &result) const {
@@ -681,12 +683,6 @@ private:
       llvm::dbgs() << ".drectve: " << directives << "\n";
     });
 
-    // Remove const from _context.
-    // FIXME: Rename LinkingContext -> LinkingContext and treat it a mutable
-    // object
-    // in the core linker.
-    PECOFFLinkingContext *targetInfo = (PECOFFLinkingContext *)&_context;
-
     // Split the string into tokens, as the shell would do for argv.
     SmallVector<const char *, 16> tokens;
     tokens.push_back("link");  // argv[0] is the command name. Will be ignored.
@@ -699,7 +695,8 @@ private:
     const char **argv = &tokens[0];
     std::string errorMessage;
     llvm::raw_string_ostream stream(errorMessage);
-    bool parseFailed = WinLinkDriver::parse(argc, argv, *targetInfo, stream);
+    bool parseFailed = WinLinkDriver::parse(
+        argc, argv, _PECOFFLinkingContext, stream);
     stream.flush();
 
     // Print error message if error.
@@ -741,13 +738,14 @@ private:
   }
 
   ReaderArchive _readerArchive;
+  PECOFFLinkingContext &_PECOFFLinkingContext;
   mutable BumpPtrStringSaver _stringSaver;
 };
 
 } // end namespace anonymous
 
 namespace lld {
-std::unique_ptr<Reader> createReaderPECOFF(const LinkingContext &context) {
+std::unique_ptr<Reader> createReaderPECOFF(PECOFFLinkingContext &context) {
   return std::unique_ptr<Reader>(new ReaderCOFF(context));
 }
 }





More information about the llvm-commits mailing list