[clang] 67ddafa - [clang] Use llvm::transformOptional (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 14 18:19:30 PST 2022
Author: Kazu Hirata
Date: 2022-12-14T18:19:25-08:00
New Revision: 67ddafab30ccd3d8f87fd8b8d06198c426c6756e
URL: https://github.com/llvm/llvm-project/commit/67ddafab30ccd3d8f87fd8b8d06198c426c6756e
DIFF: https://github.com/llvm/llvm-project/commit/67ddafab30ccd3d8f87fd8b8d06198c426c6756e.diff
LOG: [clang] Use llvm::transformOptional (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Added:
Modified:
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
Removed:
################################################################################
diff --git a/clang/include/clang/AST/PropertiesBase.td b/clang/include/clang/AST/PropertiesBase.td
index 8a26aace90a14..474b49b0cd006 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -799,13 +799,14 @@ let Class = PropertyTypeCase<TemplateArgument, "TemplateExpansion"> in {
def : Property<"numExpansions", Optional<UInt32>> {
let Read = [{
// Translate unsigned -> uint32_t just in case.
- node.getNumTemplateExpansions().transform(
- [](unsigned i) { return uint32_t(i); })
+ llvm::transformOptional(node.getNumTemplateExpansions(),
+ [](unsigned i) { return uint32_t(i); })
}];
}
def : Creator<[{
- auto numExpansionsUnsigned =
- numExpansions.transform([](uint32_t i) { return unsigned(i); });
+ auto numExpansionsUnsigned = llvm::transformOptional(
+ numExpansions, [](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 ad5ba1d2468ab..23bb6d66cc471 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -218,15 +218,16 @@ runDataflowAnalysis(
BlockStates;
BlockStates.reserve(TypeErasedBlockStates->size());
- llvm::transform(std::move(*TypeErasedBlockStates),
- std::back_inserter(BlockStates), [](auto &OptState) {
- return std::move(OptState).transform([](auto &&State) {
- return DataflowAnalysisState<typename AnalysisT::Lattice>{
- llvm::any_cast<typename AnalysisT::Lattice>(
- std::move(State.Lattice.Value)),
- std::move(State.Env)};
- });
- });
+ llvm::transform(
+ std::move(*TypeErasedBlockStates), std::back_inserter(BlockStates),
+ [](auto &OptState) {
+ return llvm::transformOptional(std::move(OptState), [](auto &&State) {
+ return DataflowAnalysisState<typename AnalysisT::Lattice>{
+ llvm::any_cast<typename AnalysisT::Lattice>(
+ std::move(State.Lattice.Value)),
+ std::move(State.Env)};
+ });
+ });
return BlockStates;
}
More information about the cfe-commits
mailing list