[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 06:37:16 PDT 2024
================
@@ -15,22 +15,23 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
+#include <optional>
+
using namespace llvm;
int main(int argc, char **argv) {
#if defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64__) || defined(_M_X64)
- StringMap<bool> features;
-
- if (!sys::getHostCPUFeatures(features))
+ if (std::optional<StringMap<bool>> features =
+ sys::getHostCPUFeatures(features)) {
+ if ((*features)["sse"])
----------------
tmatheson-arm wrote:
Maybe
```suggestion
if (features->lookup("sse"))
```
which does the same, but doesn't insert the default entry into the map.
https://github.com/llvm/llvm-project/pull/97824
More information about the cfe-commits
mailing list