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

Code before:
public:
  virtual ~DWARFImporterDelegate() = default;
  /// Perform a qualified lookup of a Clang type with this name.
  /// \param kind  Only return results with this type kind.
  /// \param inModule only return results from this module.
  virtual void lookupValue(StringRef name, std::optional<ClangTypeKind> kind,
                           StringRef inModule,
                           SmallVectorImpl<clang::Decl *> &results) {}
  /// vtable anchor.
  virtual void anchor();
};

// ⚠️ DANGER ⚠️
// Putting more than four types in this `PointerUnion` will break the build for
// 32-bit hosts. If we need five or more types in the future, we'll need to
// design a proper larger-than-word-sized type.
typedef llvm::PointerUnion<const clang::Decl *, const clang::MacroInfo *,
                           const clang::Type *, const clang::Token *>
    ImportDiagnosticTarget;

/// Addition file mapping information for ClangImporter.
struct ClangInvocationFileMapping {
  /// Mapping from a file name to an existing file path.
  SmallVector<std::pair<std::string, std::string>, 2> redirectedFiles;

  /// MemoryBuffer that represents the file name and content to overload.
  SmallVector<std::pair<std::string, std::string>, 2> overridenFiles;

  bool requiresBuiltinHeadersInSystemModules = false;
};

/// Class that imports Clang modules into Swift, mapping directly
/// from Clang ASTs over to Swift ASTs.
class ClangImporter final : public ClangModuleLoader {
  friend class ClangModuleUnit;
  friend class SwiftDeclSynthesizer;

  // Make requests in the ClangImporter zone friends so they can access `Impl`.
#define SWIFT_REQUEST(Zone, Name, Sig, Caching, LocOptions)                    \
  friend class Name;
#include "swift/ClangImporter/ClangImporterTypeIDZone.def"
#undef SWIFT_REQUEST

public:
  class Implementation;

private:
  Implementation &Impl;

  ClangInvocationFileMapping clangFileMapping;


Review comment (suggestion):
`MemoryBuffer` is an actual type so I think this comment is slightly misleading. 

Code after:
class DWARFImporterDelegate {
public:
  virtual ~DWARFImporterDelegate() = default;
  /// Perform a qualified lookup of a Clang type with this name.
  /// \param kind  Only return results with this type kind.
  /// \param inModule only return results from this module.
  virtual void lookupValue(StringRef name, std::optional<ClangTypeKind> kind,
                           StringRef inModule,
                           SmallVectorImpl<clang::Decl *> &results) {}
  /// vtable anchor.
  virtual void anchor();
};

// ⚠️ DANGER ⚠️
// Putting more than four types in this `PointerUnion` will break the build for
// 32-bit hosts. If we need five or more types in the future, we'll need to
// design a proper larger-than-word-sized type.
typedef llvm::PointerUnion<const clang::Decl *, const clang::MacroInfo *,
                           const clang::Type *, const clang::Token *>
    ImportDiagnosticTarget;

/// Addition file mapping information for ClangImporter.
struct ClangInvocationFileMapping {
  /// Mapping from a file name to an existing file path.
  SmallVector<std::pair<std::string, std::string>, 2> redirectedFiles;

  /// MemoryBuffer for files to be overriden.
  SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 2> overridenFiles;

  bool requiresBuiltinHeadersInSystemModules = false;
};

/// Class that imports Clang modules into Swift, mapping directly
/// from Clang ASTs over to Swift ASTs.
class ClangImporter final : public ClangModuleLoader {
  friend class ClangModuleUnit;
  friend class SwiftDeclSynthesizer;

  // Make requests in the ClangImporter zone friends so they can access `Impl`.
#define SWIFT_REQUEST(Zone, Name, Sig, Caching, LocOptions)                    \
  friend class Name;
#include "swift/ClangImporter/ClangImporterTypeIDZone.def"
#undef SWIFT_REQUEST

public:
  class Implementation;

private:
  Implementation &Impl;

  ClangInvocationFileMapping clangFileMapping;