[LinkingContext] make LinkingContext non-const
llvm-svn: 192183
diff --git a/lld/include/lld/Core/LinkingContext.h b/lld/include/lld/Core/LinkingContext.h
index 47805f4..525e1fe 100644
--- a/lld/include/lld/Core/LinkingContext.h
+++ b/lld/include/lld/Core/LinkingContext.h
@@ -305,14 +305,14 @@
/// the resolver operates. This uses the currentInputElement. When there are
/// no more files to be processed an appropriate input_graph_error is
/// returned.
- virtual ErrorOr<File &> nextFile() const;
+ virtual ErrorOr<File &> nextFile();
/// Set the resolver state for the current Input element This is used by the
/// InputGraph to decide the next file that needs to be processed for various
/// types of nodes in the InputGraph. The resolver state is nothing but a
/// bitmask of various types of states that the resolver handles when adding
/// atoms.
- virtual void setResolverState(uint32_t resolverState) const;
+ virtual void setResolverState(uint32_t resolverState);
/// @}
@@ -362,7 +362,7 @@
StringRefVector _initialUndefinedSymbols;
std::unique_ptr<InputGraph> _inputGraph;
mutable llvm::BumpPtrAllocator _allocator;
- mutable InputElement *_currentInputElement;
+ InputElement *_currentInputElement;
private:
/// Validate the subclass bits. Only called by validate.
diff --git a/lld/include/lld/Core/Resolver.h b/lld/include/lld/Core/Resolver.h
index b94486f..b0dc268 100644
--- a/lld/include/lld/Core/Resolver.h
+++ b/lld/include/lld/Core/Resolver.h
@@ -36,7 +36,7 @@
StateNewAbsoluteAtoms = 8 // New absolute atoms were added
};
- Resolver(const LinkingContext &context)
+ Resolver(LinkingContext &context)
: _context(context), _symbolTable(context), _result(context),
_haveLLVMObjs(false), _addToFinalSection(false) {}
@@ -111,7 +111,7 @@
atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
};
- const LinkingContext &_context;
+ LinkingContext &_context;
SymbolTable _symbolTable;
std::vector<const Atom *> _atoms;
std::set<const Atom *> _deadStripRoots;
diff --git a/lld/include/lld/Driver/Driver.h b/lld/include/lld/Driver/Driver.h
index 72d4fcc..a2773d6 100644
--- a/lld/include/lld/Driver/Driver.h
+++ b/lld/include/lld/Driver/Driver.h
@@ -38,7 +38,7 @@
protected:
/// Performs link using specified options
- static bool link(const LinkingContext &context,
+ static bool link(LinkingContext &context,
raw_ostream &diagnostics = llvm::errs());
private:
diff --git a/lld/include/lld/ReaderWriter/CoreLinkingContext.h b/lld/include/lld/ReaderWriter/CoreLinkingContext.h
index d7200a6..9f6fcdd 100644
--- a/lld/include/lld/ReaderWriter/CoreLinkingContext.h
+++ b/lld/include/lld/ReaderWriter/CoreLinkingContext.h
@@ -35,8 +35,8 @@
virtual Writer &writer() const;
private:
- mutable std::unique_ptr<Reader> _reader;
- mutable std::unique_ptr<Writer> _writer;
+ std::unique_ptr<Reader> _reader;
+ std::unique_ptr<Writer> _writer;
std::vector<StringRef> _passNames;
};
diff --git a/lld/include/lld/ReaderWriter/ELFLinkingContext.h b/lld/include/lld/ReaderWriter/ELFLinkingContext.h
index ec93370..9a24430 100644
--- a/lld/include/lld/ReaderWriter/ELFLinkingContext.h
+++ b/lld/include/lld/ReaderWriter/ELFLinkingContext.h
@@ -230,7 +230,6 @@
bool _noAllowDynamicLibraries;
OutputMagic _outputMagic;
StringRefVector _inputSearchPaths;
- mutable llvm::BumpPtrAllocator _alloc;
std::unique_ptr<Reader> _elfReader;
std::unique_ptr<Writer> _writer;
std::unique_ptr<Reader> _linkerScriptReader;
diff --git a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h
index f626c7c..4f09d14 100644
--- a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h
+++ b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h
@@ -162,7 +162,7 @@
virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind kind) const;
StringRef allocateString(StringRef ref) const {
- char *x = _alloc.Allocate<char>(ref.size() + 1);
+ char *x = _allocator.Allocate<char>(ref.size() + 1);
memcpy(x, ref.data(), ref.size());
x[ref.size()] = '\0';
return x;
@@ -211,9 +211,8 @@
std::set<std::string> _noDefaultLibs;
std::vector<StringRef> _inputSearchPaths;
- mutable std::unique_ptr<Reader> _reader;
- mutable std::unique_ptr<Writer> _writer;
- mutable llvm::BumpPtrAllocator _alloc;
+ std::unique_ptr<Reader> _reader;
+ std::unique_ptr<Writer> _writer;
};
} // end namespace lld
diff --git a/lld/lib/Core/LinkingContext.cpp b/lld/lib/Core/LinkingContext.cpp
index 5d5d34f..22a9ccf 100644
--- a/lld/lib/Core/LinkingContext.cpp
+++ b/lld/lib/Core/LinkingContext.cpp
@@ -76,11 +76,11 @@
return true;
}
-void LinkingContext::setResolverState(uint32_t state) const {
+void LinkingContext::setResolverState(uint32_t state) {
_currentInputElement->setResolverState(state);
}
-ErrorOr<File &> LinkingContext::nextFile() const {
+ErrorOr<File &> LinkingContext::nextFile() {
// When nextFile() is called for the first time, _currentInputElement is not
// initialized. Initialize it with the first element of the input graph.
if (_currentInputElement == nullptr) {
diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp
index 077afda..e0b81ea 100644
--- a/lld/lib/Driver/Driver.cpp
+++ b/lld/lib/Driver/Driver.cpp
@@ -28,7 +28,7 @@
namespace lld {
/// This is where the link is actually performed.
-bool Driver::link(const LinkingContext &context, raw_ostream &diagnostics) {
+bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
// Honor -mllvm
if (!context.llvmOptions().empty()) {
unsigned numArgs = context.llvmOptions().size();
diff --git a/lld/lib/ReaderWriter/CoreLinkingContext.cpp b/lld/lib/ReaderWriter/CoreLinkingContext.cpp
index bc9a009..db17d57 100644
--- a/lld/lib/ReaderWriter/CoreLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/CoreLinkingContext.cpp
@@ -271,8 +271,9 @@
CoreLinkingContext::CoreLinkingContext() {}
-bool CoreLinkingContext::validateImpl(raw_ostream &diagnostics) {
+bool CoreLinkingContext::validateImpl(raw_ostream &) {
_reader = createReaderYAML(*this);
+ _writer = createWriterYAML(*this);
return true;
}
@@ -289,11 +290,7 @@
}
}
-Writer &CoreLinkingContext::writer() const {
- if (!_writer)
- _writer = createWriterYAML(*this);
- return *_writer;
-}
+Writer &CoreLinkingContext::writer() const { return *_writer; }
ErrorOr<Reference::Kind>
CoreLinkingContext::relocKindFromString(StringRef str) const {
diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
index 6d7f786..bf1a4a7 100644
--- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
@@ -167,7 +167,7 @@
}
}
if (foundFile)
- return StringRef(*new (_alloc) std::string(pathref));
+ return StringRef(*new (_allocator) std::string(pathref));
}
if (!llvm::sys::fs::exists(libName))
return llvm::make_error_code(llvm::errc::no_such_file_or_directory);