forked from OSchip/llvm-project
[LinkingContext] make LinkingContext non-const
llvm-svn: 192183
This commit is contained in:
parent
3f359430b3
commit
7f1146c494
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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(PassManager &pm) const {
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -167,7 +167,7 @@ llvm::ErrorOr<StringRef> ELFLinkingContext::searchLibrary(
|
|||
}
|
||||
}
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue