summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core/Resolver.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-03-04 04:36:46 +0000
committerRui Ueyama <ruiu@google.com>2015-03-04 04:36:46 +0000
commit394d10e34d01415897b6af28f7fceaeb5a9088f2 (patch)
tree350d1297c7b263fba845af6a4621be8de04d883a /lld/lib/Core/Resolver.cpp
parentb480296e6cb4a2cc5d5f588e35d4148f8770fea9 (diff)
downloadbcm5719-llvm-394d10e34d01415897b6af28f7fceaeb5a9088f2.tar.gz
bcm5719-llvm-394d10e34d01415897b6af28f7fceaeb5a9088f2.zip
Make File non-const in the resolver.
File objects are not really const in the resolver. We set ordinals to them and call beforeLink hooks. Also, File's member functions marked as const are not really const. ArchiveFile never returns the same member file twice, so it remembers files returned before. find() has side effects. In order to deal with the inconsistencies, we sprinkled const_casts and marked member varaibles as mutable. This patch removes const from there to reflect the reality. llvm-svn: 231212
Diffstat (limited to 'lld/lib/Core/Resolver.cpp')
-rw-r--r--lld/lib/Core/Resolver.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index 4e5ea0134d6..13b48c7e42e 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -27,7 +27,7 @@
namespace lld {
-bool Resolver::handleFile(const File &file) {
+bool Resolver::handleFile(File &file) {
bool undefAdded = false;
for (const DefinedAtom *atom : file.defined())
doDefinedAtom(*atom);
@@ -73,25 +73,25 @@ void Resolver::forEachUndefines(bool searchForOverrides,
} while (undefineGenCount != _symbolTable.size());
}
-bool Resolver::handleArchiveFile(const File &file) {
- const ArchiveLibraryFile *archiveFile = cast<ArchiveLibraryFile>(&file);
+bool Resolver::handleArchiveFile(File &file) {
+ ArchiveLibraryFile *archiveFile = cast<ArchiveLibraryFile>(&file);
bool searchForOverrides =
_ctx.searchArchivesToOverrideTentativeDefinitions();
bool undefAdded = false;
forEachUndefines(searchForOverrides,
[&](StringRef undefName, bool dataSymbolOnly) {
- if (const File *member = archiveFile->find(undefName, dataSymbolOnly)) {
+ if (File *member = archiveFile->find(undefName, dataSymbolOnly)) {
member->setOrdinal(_ctx.getNextOrdinalAndIncrement());
- const_cast<File *>(member)->beforeLink();
+ member->beforeLink();
undefAdded = handleFile(*member) || undefAdded;
}
});
return undefAdded;
}
-void Resolver::handleSharedLibrary(const File &file) {
+void Resolver::handleSharedLibrary(File &file) {
// Add all the atoms from the shared library
- const SharedLibraryFile *sharedLibrary = cast<SharedLibraryFile>(&file);
+ SharedLibraryFile *sharedLibrary = cast<SharedLibraryFile>(&file);
handleFile(*sharedLibrary);
bool searchForOverrides =
_ctx.searchSharedLibrariesToOverrideTentativeDefinitions();
OpenPOWER on IntegriCloud