Files
clang-p2996/lld/lib/Core/InputFiles.cpp
Nick Kledzik 3011259a85 Rework how YAMLReader is layered on top of YAMLParser. Turn hand written
recursive descent functions into one table driven parser.  Add proper
error recovery and reporting.  Add lots of test cases with semantics errors
and verify error messages.

llvm-svn: 156136
2012-05-03 23:55:34 +00:00

85 lines
2.3 KiB
C++

//===- Core/InputFiles.cpp - Manages list of Files ------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lld/Core/InputFiles.h"
#include "lld/Core/SharedLibraryFile.h"
#include "lld/Core/ArchiveLibraryFile.h"
#include "lld/Core/LLVM.h"
namespace lld {
InputFiles::InputFiles() {
}
InputFiles::~InputFiles() {
}
void InputFiles::forEachInitialAtom(InputFiles::Handler &handler) const {
for ( const File *file : _files ) {
this->handleFile(file, handler);
}
}
void InputFiles::prependFile(const File &file) {
_files.insert(_files.begin(), &file);
}
void InputFiles::appendFile(const File &file) {
_files.push_back(&file);
}
bool InputFiles::searchLibraries(StringRef name, bool searchSharedLibs,
bool searchArchives, bool dataSymbolOnly,
InputFiles::Handler &handler) const {
for ( const File *file : _files ) {
if ( searchSharedLibs ) {
if (const SharedLibraryFile *shlib = dyn_cast<SharedLibraryFile>(file)) {
if ( const SharedLibraryAtom* shAtom = shlib->exports(name,
dataSymbolOnly) ) {
handler.doSharedLibraryAtom(*shAtom);
return true;
}
}
}
if ( searchArchives ) {
if (const ArchiveLibraryFile *lib = dyn_cast<ArchiveLibraryFile>(file)) {
if ( const File *member = lib->find(name, dataSymbolOnly) ) {
this->handleFile(member, handler);
return true;
}
}
}
}
return false;
}
void InputFiles::handleFile(const File *file,
InputFiles::Handler &handler) const {
handler.doFile(*file);
for( const DefinedAtom *atom : file->defined() ) {
handler.doDefinedAtom(*atom);
}
for( const UndefinedAtom *undefAtom : file->undefined() ) {
handler.doUndefinedAtom(*undefAtom);
}
for( const SharedLibraryAtom *shlibAtom : file->sharedLibrary() ) {
handler.doSharedLibraryAtom(*shlibAtom);
}
for( const AbsoluteAtom *absAtom : file->absolute() ) {
handler.doAbsoluteAtom(*absAtom);
}
}
} // namespace lld