• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- Core/ArchiveLibraryFile.h - Models static library ------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLD_CORE_ARCHIVE_LIBRARY_FILE_H
10 #define LLD_CORE_ARCHIVE_LIBRARY_FILE_H
11 
12 #include "lld/Core/File.h"
13 #include <set>
14 
15 namespace lld {
16 
17 ///
18 /// The ArchiveLibraryFile subclass of File is used to represent unix
19 /// static library archives.  These libraries provide no atoms to the
20 /// initial set of atoms linked.  Instead, when the Resolver will query
21 /// ArchiveLibraryFile instances for specific symbols names using the
22 /// find() method.  If the archive contains an object file which has a
23 /// DefinedAtom whose scope is not translationUnit, then that entire
24 /// object file File is returned.
25 ///
26 class ArchiveLibraryFile : public File {
27 public:
classof(const File * f)28   static bool classof(const File *f) {
29     return f->kind() == kindArchiveLibrary;
30   }
31 
32   /// Check if any member of the archive contains an Atom with the
33   /// specified name and return the File object for that member, or nullptr.
34   virtual File *find(StringRef name) = 0;
35 
36   virtual std::error_code
37   parseAllMembers(std::vector<std::unique_ptr<File>> &result) = 0;
38 
39 protected:
40   /// only subclasses of ArchiveLibraryFile can be instantiated
ArchiveLibraryFile(StringRef path)41   ArchiveLibraryFile(StringRef path) : File(path, kindArchiveLibrary) {}
42 };
43 
44 } // namespace lld
45 
46 #endif // LLD_CORE_ARCHIVE_LIBRARY_FILE_H
47