mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
use new llvm::Optional API
`getValue` -> `value` `getValueOr` -> `value_or` `hasValue` -> `has_value` `map` -> `transform` The old API will be deprecated in the rebranch. To avoid merge conflicts, use the new API already in the main branch. rdar://102362022
This commit is contained in:
@@ -158,9 +158,9 @@ bool Deserializer::readGraph(GlobalModuleDependenciesCache &cache) {
|
||||
assert(currentTripleID &&
|
||||
"Expected target triple ID for a MODULE_DETAILS_NODE record");
|
||||
auto triple = getIdentifier(currentTripleID);
|
||||
if (!triple.hasValue())
|
||||
if (!triple.has_value())
|
||||
llvm::report_fatal_error("Unexpected MODULE_DETAILS_NODE record");
|
||||
return triple.getValue();
|
||||
return triple.value();
|
||||
};
|
||||
|
||||
while (!Cursor.AtEndOfStream()) {
|
||||
@@ -270,8 +270,8 @@ bool Deserializer::readGraph(GlobalModuleDependenciesCache &cache) {
|
||||
|
||||
// Form the dependencies storage object
|
||||
auto moduleDep = ModuleDependencies::forSwiftInterfaceModule(
|
||||
outputModulePath.getValue(),
|
||||
optionalSwiftInterfaceFile.getValue(), *compiledModuleCandidates,
|
||||
outputModulePath.value(),
|
||||
optionalSwiftInterfaceFile.value(), *compiledModuleCandidates,
|
||||
buildCommandRefs, extraPCMRefs, *contextHash, isFramework);
|
||||
|
||||
// Add dependencies of this module
|
||||
@@ -774,7 +774,7 @@ void Serializer::writeModuleInfo(ModuleDependencyID moduleID,
|
||||
Optional<std::string> triple,
|
||||
const ModuleDependencies &dependencyInfo) {
|
||||
using namespace graph_block;
|
||||
auto tripleStrID = triple.hasValue() ? getIdentifier(triple.getValue()) : 0;
|
||||
auto tripleStrID = triple.has_value() ? getIdentifier(triple.value()) : 0;
|
||||
|
||||
ModuleInfoLayout::emitRecord(
|
||||
Out, ScratchRecord, AbbrCodes[ModuleInfoLayout::Code],
|
||||
@@ -783,7 +783,7 @@ void Serializer::writeModuleInfo(ModuleDependencyID moduleID,
|
||||
|
||||
switch (dependencyInfo.getKind()) {
|
||||
case swift::ModuleDependenciesKind::SwiftInterface: {
|
||||
assert(triple.hasValue() && "Expected triple for serializing MODULE_NODE");
|
||||
assert(triple.has_value() && "Expected triple for serializing MODULE_NODE");
|
||||
auto swiftTextDeps = dependencyInfo.getAsSwiftInterfaceModule();
|
||||
assert(swiftTextDeps);
|
||||
unsigned outputModulePathFileId =
|
||||
@@ -793,7 +793,7 @@ void Serializer::writeModuleInfo(ModuleDependencyID moduleID,
|
||||
unsigned bridgingHeaderFileId =
|
||||
swiftTextDeps->textualModuleDetails.bridgingHeaderFile
|
||||
? getIdentifier(swiftTextDeps->textualModuleDetails
|
||||
.bridgingHeaderFile.getValue())
|
||||
.bridgingHeaderFile.value())
|
||||
: 0;
|
||||
SwiftInterfaceModuleDetailsLayout::emitRecord(
|
||||
Out, ScratchRecord, AbbrCodes[SwiftInterfaceModuleDetailsLayout::Code],
|
||||
@@ -811,14 +811,14 @@ void Serializer::writeModuleInfo(ModuleDependencyID moduleID,
|
||||
break;
|
||||
}
|
||||
case swift::ModuleDependenciesKind::SwiftSource: {
|
||||
assert(!triple.hasValue() &&
|
||||
assert(!triple.has_value() &&
|
||||
"Did not expect triple for serializing MODULE_NODE");
|
||||
auto swiftSourceDeps = dependencyInfo.getAsSwiftSourceModule();
|
||||
assert(swiftSourceDeps);
|
||||
unsigned bridgingHeaderFileId =
|
||||
swiftSourceDeps->textualModuleDetails.bridgingHeaderFile
|
||||
? getIdentifier(swiftSourceDeps->textualModuleDetails
|
||||
.bridgingHeaderFile.getValue())
|
||||
.bridgingHeaderFile.value())
|
||||
: 0;
|
||||
SwiftSourceModuleDetailsLayout::emitRecord(
|
||||
Out, ScratchRecord, AbbrCodes[SwiftSourceModuleDetailsLayout::Code],
|
||||
@@ -831,7 +831,7 @@ void Serializer::writeModuleInfo(ModuleDependencyID moduleID,
|
||||
break;
|
||||
}
|
||||
case swift::ModuleDependenciesKind::SwiftBinary: {
|
||||
assert(triple.hasValue() && "Expected triple for serializing MODULE_NODE");
|
||||
assert(triple.has_value() && "Expected triple for serializing MODULE_NODE");
|
||||
auto swiftBinDeps = dependencyInfo.getAsSwiftBinaryModule();
|
||||
assert(swiftBinDeps);
|
||||
SwiftBinaryModuleDetailsLayout::emitRecord(
|
||||
@@ -843,7 +843,7 @@ void Serializer::writeModuleInfo(ModuleDependencyID moduleID,
|
||||
break;
|
||||
}
|
||||
case swift::ModuleDependenciesKind::SwiftPlaceholder: {
|
||||
assert(triple.hasValue() && "Expected triple for serializing MODULE_NODE");
|
||||
assert(triple.has_value() && "Expected triple for serializing MODULE_NODE");
|
||||
auto swiftPHDeps = dependencyInfo.getAsPlaceholderDependencyModule();
|
||||
assert(swiftPHDeps);
|
||||
SwiftPlaceholderModuleDetailsLayout::emitRecord(
|
||||
@@ -855,7 +855,7 @@ void Serializer::writeModuleInfo(ModuleDependencyID moduleID,
|
||||
break;
|
||||
}
|
||||
case swift::ModuleDependenciesKind::Clang: {
|
||||
assert(triple.hasValue() && "Expected triple for serializing MODULE_NODE");
|
||||
assert(triple.has_value() && "Expected triple for serializing MODULE_NODE");
|
||||
auto clangDeps = dependencyInfo.getAsClangModule();
|
||||
assert(clangDeps);
|
||||
ClangModuleDetailsLayout::emitRecord(
|
||||
@@ -948,8 +948,8 @@ void Serializer::collectStringsAndArrays(
|
||||
"Expected source-based dependency");
|
||||
auto optionalDependencyInfo =
|
||||
cache.findSourceModuleDependency(moduleID.first);
|
||||
assert(optionalDependencyInfo.hasValue() && "Expected dependency info.");
|
||||
auto dependencyInfo = optionalDependencyInfo.getValue();
|
||||
assert(optionalDependencyInfo.has_value() && "Expected dependency info.");
|
||||
auto dependencyInfo = optionalDependencyInfo.value();
|
||||
// Add the module's name
|
||||
addIdentifier(moduleID.first);
|
||||
// Add the module's dependencies
|
||||
@@ -959,9 +959,9 @@ void Serializer::collectStringsAndArrays(
|
||||
assert(swiftSourceDeps);
|
||||
addArray(moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs,
|
||||
swiftSourceDeps->textualModuleDetails.extraPCMArgs);
|
||||
if (swiftSourceDeps->textualModuleDetails.bridgingHeaderFile.hasValue())
|
||||
if (swiftSourceDeps->textualModuleDetails.bridgingHeaderFile.has_value())
|
||||
addIdentifier(
|
||||
swiftSourceDeps->textualModuleDetails.bridgingHeaderFile.getValue());
|
||||
swiftSourceDeps->textualModuleDetails.bridgingHeaderFile.value());
|
||||
addArray(moduleID, ModuleIdentifierArrayKind::SourceFiles,
|
||||
swiftSourceDeps->sourceFiles);
|
||||
addArray(moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles,
|
||||
@@ -975,7 +975,7 @@ void Serializer::collectStringsAndArrays(
|
||||
for (auto &moduleID : cache.getAllNonSourceModules(triple)) {
|
||||
auto dependencyInfos = cache.findAllDependenciesIrrespectiveOfSearchPaths(
|
||||
moduleID.first, moduleID.second);
|
||||
assert(dependencyInfos.hasValue() && "Expected dependency info.");
|
||||
assert(dependencyInfos.has_value() && "Expected dependency info.");
|
||||
for (auto &dependencyInfo : *dependencyInfos) {
|
||||
// Add the module's name
|
||||
addIdentifier(moduleID.first);
|
||||
@@ -998,9 +998,9 @@ void Serializer::collectStringsAndArrays(
|
||||
addArray(moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs,
|
||||
swiftTextDeps->textualModuleDetails.extraPCMArgs);
|
||||
addIdentifier(swiftTextDeps->contextHash);
|
||||
if (swiftTextDeps->textualModuleDetails.bridgingHeaderFile.hasValue())
|
||||
if (swiftTextDeps->textualModuleDetails.bridgingHeaderFile.has_value())
|
||||
addIdentifier(swiftTextDeps->textualModuleDetails.bridgingHeaderFile
|
||||
.getValue());
|
||||
.value());
|
||||
addArray(moduleID, ModuleIdentifierArrayKind::SourceFiles,
|
||||
std::vector<std::string>());
|
||||
addArray(moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles,
|
||||
@@ -1087,9 +1087,9 @@ void Serializer::writeInterModuleDependenciesCache(
|
||||
// First, write the source modules we've encountered
|
||||
for (auto &moduleID : cache.getAllSourceModules()) {
|
||||
auto dependencyInfo = cache.findSourceModuleDependency(moduleID.first);
|
||||
assert(dependencyInfo.hasValue() && "Expected dependency info.");
|
||||
assert(dependencyInfo.has_value() && "Expected dependency info.");
|
||||
writeModuleInfo(moduleID, llvm::Optional<std::string>(),
|
||||
dependencyInfo.getValue());
|
||||
dependencyInfo.value());
|
||||
}
|
||||
|
||||
// Write all non-source modules, for each of the target triples this scanner
|
||||
@@ -1098,7 +1098,7 @@ void Serializer::writeInterModuleDependenciesCache(
|
||||
for (auto &moduleID : cache.getAllNonSourceModules(triple)) {
|
||||
auto dependencyInfos = cache.findAllDependenciesIrrespectiveOfSearchPaths(
|
||||
moduleID.first, moduleID.second);
|
||||
assert(dependencyInfos.hasValue() && "Expected dependency info.");
|
||||
assert(dependencyInfos.has_value() && "Expected dependency info.");
|
||||
for (auto &dependencyInfo : *dependencyInfos) {
|
||||
writeModuleInfo(moduleID, triple, dependencyInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user