Skip to content

Commit

Permalink
Simplify ArchSpec::IsFullySpecifiedTriple() (NFC)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
adrian-prantl committed Apr 1, 2022
1 parent 7c158e3 commit 942c21e
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions lldb/source/Utility/ArchSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 942c21e

Please sign in to comment.