[llvm] Compare std::optional<T> to values directly (NFC) (#146222)

This patch transforms:

  X && *X == Y

to:

  X == Y

where X is of std::optional<T>, and Y is of T or similar.
This commit is contained in:
Kazu Hirata
2025-06-28 13:04:16 -07:00
committed by GitHub
parent bad5a740e1
commit f90025ebd9
2 changed files with 2 additions and 2 deletions

View File

@@ -50,7 +50,7 @@ std::optional<AArch64::ArchInfo> AArch64::ArchInfo::findBySubArch(StringRef SubA
std::optional<AArch64::FMVInfo> lookupFMVByID(AArch64::ArchExtKind ExtID) {
for (const AArch64::FMVInfo &Info : AArch64::getFMVInfo())
if (Info.ID && *Info.ID == ExtID)
if (Info.ID == ExtID)
return Info;
return {};
}

View File

@@ -45,7 +45,7 @@ static bool testAttribute(unsigned Tag, unsigned Value, unsigned ExpectedTag,
cantFail(Parser.parse(Bytes, llvm::endianness::little));
std::optional<unsigned> Attr = Parser.getAttributeValue("", ExpectedTag);
return Attr && *Attr == ExpectedValue;
return Attr == ExpectedValue;
}
static bool testTagString(unsigned Tag, const char *name) {