Repository: apple/swift
File: lib/Serialization/SerializedModuleLoader.cpp (C++)

Code before:
    M->setBypassResilience();

  return M;
}

bool MemoryBufferSerializedModuleLoader::registerMemoryBuffer(
    StringRef importPath, std::unique_ptr<llvm::MemoryBuffer> input,
    llvm::VersionTuple version) {
  return MemoryBuffers
      .insert({importPath, MemoryBufferInfo(std::move(input), version)})
      .second;
}

bool MemoryBufferSerializedModuleLoader::unregisterMemoryBuffer(
    StringRef importPath) {
  return MemoryBuffers.erase(importPath);
}

void SerializedModuleLoaderBase::loadExtensions(NominalTypeDecl *nominal,
                                                unsigned previousGeneration) {
  // Nominals in parsed SourceFiles can't have extensions provided by imported
  // serialized modules. This is necessary to avoid triggering semantic requests
  // from extension binding since looking up extensions may need to compute the
  // mangled name.
  auto *SF = nominal->getParentSourceFile();
  if (SF && SF->Kind != SourceFileKind::Interface)
    return;

  for (auto &modulePair : LoadedModuleFiles) {
    if (modulePair.second <= previousGeneration)
      continue;
    modulePair.first->loadExtensions(nominal);
  }
}

void SerializedModuleLoaderBase::loadObjCMethods(
       NominalTypeDecl *typeDecl,
       ObjCSelector selector,
       bool isInstanceMethod,
       unsigned previousGeneration,
       llvm::TinyPtrVector<AbstractFunctionDecl *> &methods) {
  for (auto &modulePair : LoadedModuleFiles) {
    if (modulePair.second <= previousGeneration)
      continue;
    modulePair.first->loadObjCMethods(typeDecl, selector, isInstanceMethod,
                                      methods);
  }
}

void SerializedModuleLoaderBase::loadDerivativeFunctionConfigurations(
    AbstractFunctionDecl *originalAFD, unsigned int previousGeneration,

Review comment (suggestion):
Actually I don't think this should be conditional on `Interface`

Code after:
    M->setBypassResilience();

  return M;
}

bool MemoryBufferSerializedModuleLoader::registerMemoryBuffer(
    StringRef importPath, std::unique_ptr<llvm::MemoryBuffer> input,
    llvm::VersionTuple version) {
  return MemoryBuffers
      .insert({importPath, MemoryBufferInfo(std::move(input), version)})
      .second;
}

bool MemoryBufferSerializedModuleLoader::unregisterMemoryBuffer(
    StringRef importPath) {
  return MemoryBuffers.erase(importPath);
}

void SerializedModuleLoaderBase::loadExtensions(NominalTypeDecl *nominal,
                                                unsigned previousGeneration) {
  // Nominals in parsed SourceFiles can't have extensions provided by imported
  // serialized modules. This is necessary to avoid triggering semantic requests
  // from extension binding since looking up extensions may need to compute the
  // mangled name.
  if (nominal->getParentSourceFile())
    return;

  for (auto &modulePair : LoadedModuleFiles) {
    if (modulePair.second <= previousGeneration)
      continue;
    modulePair.first->loadExtensions(nominal);
  }
}

void SerializedModuleLoaderBase::loadObjCMethods(
       NominalTypeDecl *typeDecl,
       ObjCSelector selector,
       bool isInstanceMethod,
       unsigned previousGeneration,
       llvm::TinyPtrVector<AbstractFunctionDecl *> &methods) {
  for (auto &modulePair : LoadedModuleFiles) {
    if (modulePair.second <= previousGeneration)
      continue;
    modulePair.first->loadObjCMethods(typeDecl, selector, isInstanceMethod,
                                      methods);
  }
}

void SerializedModuleLoaderBase::loadDerivativeFunctionConfigurations(
    AbstractFunctionDecl *originalAFD, unsigned int previousGeneration,
    llvm::SetVector<AutoDiffConfig> &results) {