ArchiveLibraryFile.h revision 353358
1258945Sroberto//===- Core/ArchiveLibraryFile.h - Models static library ------------------===//
2280849Scy//
3258945Sroberto// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4258945Sroberto// See https://llvm.org/LICENSE.txt for license information.
5258945Sroberto// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6258945Sroberto//
7258945Sroberto//===----------------------------------------------------------------------===//
8258945Sroberto
9258945Sroberto#ifndef LLD_CORE_ARCHIVE_LIBRARY_FILE_H
10258945Sroberto#define LLD_CORE_ARCHIVE_LIBRARY_FILE_H
11258945Sroberto
12258945Sroberto#include "lld/Core/File.h"
13258945Sroberto#include <set>
14258945Sroberto
15258945Srobertonamespace lld {
16258945Sroberto
17258945Sroberto///
18280849Scy/// The ArchiveLibraryFile subclass of File is used to represent unix
19258945Sroberto/// static library archives.  These libraries provide no atoms to the
20258945Sroberto/// initial set of atoms linked.  Instead, when the Resolver will query
21258945Sroberto/// ArchiveLibraryFile instances for specific symbols names using the
22258945Sroberto/// find() method.  If the archive contains an object file which has a
23258945Sroberto/// DefinedAtom whose scope is not translationUnit, then that entire
24258945Sroberto/// object file File is returned.
25258945Sroberto///
26258945Srobertoclass ArchiveLibraryFile : public File {
27258945Srobertopublic:
28258945Sroberto  static bool classof(const File *f) {
29258945Sroberto    return f->kind() == kindArchiveLibrary;
30258945Sroberto  }
31258945Sroberto
32258945Sroberto  /// Check if any member of the archive contains an Atom with the
33258945Sroberto  /// specified name and return the File object for that member, or nullptr.
34258945Sroberto  virtual File *find(StringRef name) = 0;
35258945Sroberto
36258945Sroberto  virtual std::error_code
37258945Sroberto  parseAllMembers(std::vector<std::unique_ptr<File>> &result) = 0;
38258945Sroberto
39258945Srobertoprotected:
40258945Sroberto  /// only subclasses of ArchiveLibraryFile can be instantiated
41258945Sroberto  ArchiveLibraryFile(StringRef path) : File(path, kindArchiveLibrary) {}
42258945Sroberto};
43258945Sroberto
44258945Sroberto} // namespace lld
45258945Sroberto
46258945Sroberto#endif // LLD_CORE_ARCHIVE_LIBRARY_FILE_H
47258945Sroberto