Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:56

0001 //===- InstallAPI/Context.h -------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_INSTALLAPI_CONTEXT_H
0010 #define LLVM_CLANG_INSTALLAPI_CONTEXT_H
0011 
0012 #include "clang/Basic/Diagnostic.h"
0013 #include "clang/Basic/FileManager.h"
0014 #include "clang/InstallAPI/DylibVerifier.h"
0015 #include "clang/InstallAPI/HeaderFile.h"
0016 #include "clang/InstallAPI/MachO.h"
0017 #include "llvm/ADT/DenseMap.h"
0018 
0019 namespace clang {
0020 namespace installapi {
0021 class FrontendRecordsSlice;
0022 
0023 /// Struct used for generating validating InstallAPI.
0024 /// The attributes captured represent all necessary information
0025 /// to generate TextAPI output.
0026 struct InstallAPIContext {
0027 
0028   /// Library attributes that are typically passed as linker inputs.
0029   BinaryAttrs BA;
0030 
0031   /// Install names of reexported libraries of a library.
0032   LibAttrs Reexports;
0033 
0034   /// All headers that represent a library.
0035   HeaderSeq InputHeaders;
0036 
0037   /// Active language mode to parse in.
0038   Language LangMode = Language::ObjC;
0039 
0040   /// Active header access type.
0041   HeaderType Type = HeaderType::Unknown;
0042 
0043   /// Active TargetSlice for symbol record collection.
0044   std::shared_ptr<FrontendRecordsSlice> Slice;
0045 
0046   /// FileManager for all I/O operations.
0047   FileManager *FM = nullptr;
0048 
0049   /// DiagnosticsEngine for all error reporting.
0050   DiagnosticsEngine *Diags = nullptr;
0051 
0052   /// Verifier when binary dylib is passed as input.
0053   std::unique_ptr<DylibVerifier> Verifier = nullptr;
0054 
0055   /// File Path of output location.
0056   llvm::StringRef OutputLoc{};
0057 
0058   /// What encoding to write output as.
0059   FileType FT = FileType::TBD_V5;
0060 
0061   /// Populate entries of headers that should be included for TextAPI
0062   /// generation.
0063   void addKnownHeader(const HeaderFile &H);
0064 
0065   /// Record visited files during frontend actions to determine whether to
0066   /// include their declarations for TextAPI generation.
0067   ///
0068   /// \param FE Header that is being parsed.
0069   /// \param PP Preprocesser used for querying how header was imported.
0070   /// \return Access level of header if it should be included for TextAPI
0071   /// generation.
0072   std::optional<HeaderType> findAndRecordFile(const FileEntry *FE,
0073                                               const Preprocessor &PP);
0074 
0075 private:
0076   using HeaderMap = llvm::DenseMap<const FileEntry *, HeaderType>;
0077 
0078   // Collection of parsed header files and their access level. If set to
0079   // HeaderType::Unknown, they are not used for TextAPI generation.
0080   HeaderMap KnownFiles;
0081 
0082   // Collection of expected header includes and the access level for them.
0083   llvm::DenseMap<StringRef, HeaderType> KnownIncludes;
0084 };
0085 
0086 /// Lookup the dylib or TextAPI file location for a system library or framework.
0087 /// The search paths provided are searched in order.
0088 /// @rpath based libraries are not supported.
0089 ///
0090 /// \param InstallName The install name for the library.
0091 /// \param FrameworkSearchPaths Search paths to look up frameworks with.
0092 /// \param LibrarySearchPaths Search paths to look up dylibs with.
0093 /// \param SearchPaths Fallback search paths if library was not found in earlier
0094 /// paths.
0095 /// \return The full path of the library.
0096 std::string findLibrary(StringRef InstallName, FileManager &FM,
0097                         ArrayRef<std::string> FrameworkSearchPaths,
0098                         ArrayRef<std::string> LibrarySearchPaths,
0099                         ArrayRef<std::string> SearchPaths);
0100 } // namespace installapi
0101 } // namespace clang
0102 
0103 #endif // LLVM_CLANG_INSTALLAPI_CONTEXT_H