[clang] 2117fcb - Use Optional::transform instead of Optional::map (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 13 11:48:38 PDT 2022
Author: Kazu Hirata
Date: 2022-08-13T11:48:26-07:00
New Revision: 2117fcb1c06207b5eea09b66fb8e0ff58314afa8
URL: https://github.com/llvm/llvm-project/commit/2117fcb1c06207b5eea09b66fb8e0ff58314afa8
DIFF: https://github.com/llvm/llvm-project/commit/2117fcb1c06207b5eea09b66fb8e0ff58314afa8.diff
LOG: Use Optional::transform instead of Optional::map (NFC)
I'm planning to deprecate map in favor of transform for consistency
with std::optional::transform in C++23.
Added:
Modified:
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index cced230300db0..75326e0ab1d19 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -131,7 +131,8 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace,
};
auto InProgressFixup = [&] {
return Info
- .map([](const FailureInfo &Info) { return StringRef(Info.Fixup); })
+ .transform(
+ [](const FailureInfo &Info) { return StringRef(Info.Fixup); })
.value_or(Name);
};
if (auto Fixup = getDoubleUnderscoreFixup(InProgressFixup(), LangOpts))
diff --git a/clang/include/clang/AST/PropertiesBase.td b/clang/include/clang/AST/PropertiesBase.td
index ec310a459927d..0dc27b67beb86 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -786,13 +786,13 @@ let Class = PropertyTypeCase<TemplateArgument, "TemplateExpansion"> in {
def : Property<"numExpansions", Optional<UInt32>> {
let Read = [{
// Translate unsigned -> uint32_t just in case.
- node.getNumTemplateExpansions().map(
+ node.getNumTemplateExpansions().transform(
[](unsigned i) { return uint32_t(i); })
}];
}
def : Creator<[{
auto numExpansionsUnsigned =
- numExpansions.map([](uint32_t i) { return unsigned(i); });
+ numExpansions.transform([](uint32_t i) { return unsigned(i); });
return TemplateArgument(name, numExpansionsUnsigned);
}]>;
}
diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
index 4c785b21526da..4d1f5248f2115 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -153,7 +153,7 @@ runDataflowAnalysis(
llvm::transform(std::move(*TypeErasedBlockStates),
std::back_inserter(BlockStates), [](auto &OptState) {
- return std::move(OptState).map([](auto &&State) {
+ return std::move(OptState).transform([](auto &&State) {
return DataflowAnalysisState<typename AnalysisT::Lattice>{
llvm::any_cast<typename AnalysisT::Lattice>(
std::move(State.Lattice.Value)),
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 3f0dad7ee7694..c1e3e6031ec98 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1967,7 +1967,7 @@ static bool eliminateDeadStores(Function &F, AliasAnalysis &AA, MemorySSA &MSSA,
Optional<MemoryLocation> MaybeKillingLoc;
if (State.isMemTerminatorInst(KillingI))
- MaybeKillingLoc = State.getLocForTerminator(KillingI).map(
+ MaybeKillingLoc = State.getLocForTerminator(KillingI).transform(
[](const std::pair<MemoryLocation, bool> &P) { return P.first; });
else
MaybeKillingLoc = State.getLocForWrite(KillingI);
More information about the cfe-commits
mailing list