[Lldb-commits] [PATCH] D122912: Simplify ArchSpec::IsFullySpecifiedTriple() (NFC)

Adrian Prantl via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 1 08:41:32 PDT 2022


aprantl created this revision.
aprantl added reviewers: jasonmolenda, JDevlieghere.
Herald added a project: All.
aprantl requested review of this revision.

I found this function somewhat hard to read and removed a few entirely redundant checks and converted it to early exits.


https://reviews.llvm.org/D122912

Files:
  lldb/source/Utility/ArchSpec.cpp


Index: lldb/source/Utility/ArchSpec.cpp
===================================================================
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -1396,23 +1396,18 @@
 }
 
 bool ArchSpec::IsFullySpecifiedTriple() const {
-  const auto &user_specified_triple = GetTriple();
-
-  bool user_triple_fully_specified = false;
-
-  if ((user_specified_triple.getOS() != llvm::Triple::UnknownOS) ||
-      TripleOSWasSpecified()) {
-    if ((user_specified_triple.getVendor() != llvm::Triple::UnknownVendor) ||
-        TripleVendorWasSpecified()) {
-      const unsigned unspecified = 0;
-      if (!user_specified_triple.isOSDarwin() ||
-          user_specified_triple.getOSMajorVersion() != unspecified) {
-        user_triple_fully_specified = true;
-      }
-    }
-  }
+  if (!TripleOSWasSpecified())
+    return false;
+
+  if (!TripleVendorWasSpecified())
+    return false;
 
-  return user_triple_fully_specified;
+  const unsigned unspecified = 0;
+  const llvm::Triple &triple = GetTriple();
+  if (triple.isOSDarwin() && triple.getOSMajorVersion() == unspecified)
+    return false;
+
+  return true;
 }
 
 void ArchSpec::PiecewiseTripleCompare(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122912.419772.patch
Type: text/x-patch
Size: 1191 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220401/113b34e4/attachment.bin>


More information about the lldb-commits mailing list