[lld] r192183 - [LinkingContext] make LinkingContext non-const
Shankar Easwaran
shankare at codeaurora.org
Tue Oct 8 08:43:48 PDT 2013
Author: shankare
Date: Tue Oct 8 10:43:48 2013
New Revision: 192183
URL: http://llvm.org/viewvc/llvm-project?rev=192183&view=rev
Log:
[LinkingContext] make LinkingContext non-const
Modified:
lld/trunk/include/lld/Core/LinkingContext.h
lld/trunk/include/lld/Core/Resolver.h
lld/trunk/include/lld/Driver/Driver.h
lld/trunk/include/lld/ReaderWriter/CoreLinkingContext.h
lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
lld/trunk/lib/Core/LinkingContext.cpp
lld/trunk/lib/Driver/Driver.cpp
lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
Modified: lld/trunk/include/lld/Core/LinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LinkingContext.h (original)
+++ lld/trunk/include/lld/Core/LinkingContext.h Tue Oct 8 10:43:48 2013
@@ -305,14 +305,14 @@ public:
/// 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 @@ protected:
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.
Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Tue Oct 8 10:43:48 2013
@@ -36,7 +36,7 @@ public:
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 @@ private:
atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
};
- const LinkingContext &_context;
+ LinkingContext &_context;
SymbolTable _symbolTable;
std::vector<const Atom *> _atoms;
std::set<const Atom *> _deadStripRoots;
Modified: lld/trunk/include/lld/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/Driver.h?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/Driver.h (original)
+++ lld/trunk/include/lld/Driver/Driver.h Tue Oct 8 10:43:48 2013
@@ -38,7 +38,7 @@ class Driver {
protected:
/// Performs link using specified options
- static bool link(const LinkingContext &context,
+ static bool link(LinkingContext &context,
raw_ostream &diagnostics = llvm::errs());
private:
Modified: lld/trunk/include/lld/ReaderWriter/CoreLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/CoreLinkingContext.h?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/CoreLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/CoreLinkingContext.h Tue Oct 8 10:43:48 2013
@@ -35,8 +35,8 @@ protected:
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;
};
Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Tue Oct 8 10:43:48 2013
@@ -230,7 +230,6 @@ protected:
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;
Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Tue Oct 8 10:43:48 2013
@@ -162,7 +162,7 @@ public:
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 @@ private:
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
Modified: lld/trunk/lib/Core/LinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/LinkingContext.cpp?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/lib/Core/LinkingContext.cpp (original)
+++ lld/trunk/lib/Core/LinkingContext.cpp Tue Oct 8 10:43:48 2013
@@ -76,11 +76,11 @@ bool LinkingContext::createInternalFiles
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) {
Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Tue Oct 8 10:43:48 2013
@@ -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();
Modified: lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp Tue Oct 8 10:43:48 2013
@@ -271,8 +271,9 @@ private:
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 @@ void CoreLinkingContext::addPasses(PassM
}
}
-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 {
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=192183&r1=192182&r2=192183&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Tue Oct 8 10:43:48 2013
@@ -167,7 +167,7 @@ llvm::ErrorOr<StringRef> ELFLinkingConte
}
}
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);
More information about the llvm-commits
mailing list