Repository: apple/swift
File: include/swift/ClangImporter/ClangImporter.h (C/C++)

Code before:

  std::vector<std::string>
  getClangDriverArguments(ASTContext &ctx, bool ignoreClangTarget = false);

  std::optional<std::vector<std::string>>
  getClangCC1Arguments(ASTContext &ctx,
                       llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
                       bool ignoreClangTarget = false);

  std::vector<std::string>
  getClangDepScanningInvocationArguments(ASTContext &ctx);

  static std::unique_ptr<clang::CompilerInvocation>
  createClangInvocation(ClangImporter *importer,
                        const ClangImporterOptions &importerOpts,
                        llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
                        const std::vector<std::string> &CC1Args);

  /// Creates a Clang Driver based on the Swift compiler options.
  ///
  /// \return a pair of the Clang Driver and the diagnostic engine, which needs
  /// to be alive during the use of the Driver.
  static std::tuple<clang::driver::Driver,
                    llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>,
                    std::unique_ptr<clang::DiagnosticOptions>>
  createClangDriver(
      const LangOptions &LangOpts,
      const ClangImporterOptions &ClangImporterOpts,
      llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs = nullptr);

  static llvm::opt::InputArgList
  createClangArgs(const ClangImporterOptions &ClangImporterOpts,
                  const SearchPathOptions &SearchPathOpts,
                  clang::driver::Driver &clangDriver);

  ClangImporter(const ClangImporter &) = delete;
  ClangImporter(ClangImporter &&) = delete;
  ClangImporter &operator=(const ClangImporter &) = delete;
  ClangImporter &operator=(ClangImporter &&) = delete;

  ~ClangImporter();

  /// Only to be used by lldb-moduleimport-test.
  void setDWARFImporterDelegate(DWARFImporterDelegate &delegate);

  /// Create a new clang::DependencyCollector customized to
  /// ClangImporter's specific uses.
  static std::shared_ptr<clang::DependencyCollector> createDependencyCollector(
      IntermoduleDepTrackingMode Mode,
      std::shared_ptr<llvm::FileCollectorBase> FileCollector);


Review comment (suggestion):
I do wonder if this is better done as a TU local free-standing set of functions (i.e. non-member functions in an anonymous namespace).

Code after:
  /// \param tracker The object tracking files this compilation depends on.
  ///
  /// \param dwarfImporterDelegate A helper object that can synthesize
  /// Clang Decls from debug info. Used by LLDB.
  ///
  /// \returns a new Clang module importer, or null (with a diagnostic) if
  /// an error occurred.
  static std::unique_ptr<ClangImporter>
  create(ASTContext &ctx, std::string swiftPCHHash = "",
         DependencyTracker *tracker = nullptr,
         DWARFImporterDelegate *dwarfImporterDelegate = nullptr,
         bool ignoreFileMapping = false);

  static std::string getClangSystemOverlayFile(const SearchPathOptions &Opts);

  /// Compute the file system used by the ClangImporter from
  /// ClangInvocationFileMapping. If optional StringSaver is passed, the virtual
  /// files are allocated inside the StringSaver to extend lifetime for
  /// dependency scanning.
  static llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
  computeClangImporterFileSystem(
      const ASTContext &ctx, const ClangInvocationFileMapping &fileMapping,
      llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> baseFS,
      bool suppressDiagnostics = false,
      llvm::StringSaver *Saver = nullptr);

  std::vector<std::string>
  getClangDriverArguments(ASTContext &ctx, bool ignoreClangTarget = false);

  std::optional<std::vector<std::string>>
  getClangCC1Arguments(ASTContext &ctx,
                       llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
                       bool ignoreClangTarget = false);

  std::vector<std::string>
  getClangDepScanningInvocationArguments(ASTContext &ctx);

  static std::unique_ptr<clang::CompilerInvocation>
  createClangInvocation(ClangImporter *importer,
                        const ClangImporterOptions &importerOpts,
                        llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
                        const std::vector<std::string> &CC1Args);

  /// Creates a Clang Driver based on the Swift compiler options.
  ///
  /// \return a pair of the Clang Driver and the diagnostic engine, which needs
  /// to be alive during the use of the Driver.
  static std::tuple<clang::driver::Driver,
                    llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>,
                    std::unique_ptr<clang::DiagnosticOptions>>
  createClangDriver(