[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
Tomas Matheson via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 5 08:01:35 PDT 2024
================
@@ -22,13 +22,13 @@ using namespace llvm;
int main(int argc, char **argv) {
#if defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64__) || defined(_M_X64)
- if (std::optional<StringMap<bool>> features =
+ if (const std::optional<StringMap<bool>> features =
sys::getHostCPUFeatures(features)) {
- if ((*features)["sse"])
+ if (features->contains("sse"))
----------------
tmatheson-arm wrote:
`contains` will only check if the key exists in the map, but you want to actually get the `bool` if it exists and default to `false` if it doesn't. I think `lookup` fits better.
https://github.com/llvm/llvm-project/pull/97824
More information about the cfe-commits
mailing list