Looks like the only reason we use a unique_ptr here is so that we can
conditionally construct a LogicalErrorHandler. It's a small type, and
Optional can do the same thing with 100% fewer heap allocations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338962
91177308-0d34-0410-b5e6-
96231b3b80d8
}
// Install the logical handler for -Wtautological-overlap-compare
- std::unique_ptr<LogicalErrorHandler> LEH;
+ llvm::Optional<LogicalErrorHandler> LEH;
if (!Diags.isIgnored(diag::warn_tautological_overlap_comparison,
D->getLocStart())) {
- LEH.reset(new LogicalErrorHandler(S));
- AC.getCFGBuildOptions().Observer = LEH.get();
+ LEH.emplace(S);
+ AC.getCFGBuildOptions().Observer = &*LEH;
}
// Emit delayed diagnostics.