[Lldb-commits] [lldb] 942c21e - Simplify ArchSpec::IsFullySpecifiedTriple() (NFC)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 1 14:16:50 PDT 2022


Author: Adrian Prantl
Date: 2022-04-01T14:16:36-07:00
New Revision: 942c21ed23dcba11a156cbaad4a74348dc6fdcff

URL: https://github.com/llvm/llvm-project/commit/942c21ed23dcba11a156cbaad4a74348dc6fdcff
DIFF: https://github.com/llvm/llvm-project/commit/942c21ed23dcba11a156cbaad4a74348dc6fdcff.diff

LOG: Simplify ArchSpec::IsFullySpecifiedTriple() (NFC)

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

Differential Revision: https://reviews.llvm.org/D122912

Added: 
    

Modified: 
    lldb/source/Utility/ArchSpec.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 41bcc1a90ba50..963005b5cdfa7 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -1396,23 +1396,18 @@ bool lldb_private::operator==(const ArchSpec &lhs, const ArchSpec &rhs) {
 }
 
 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(


        


More information about the lldb-commits mailing list