This is an archive of the discontinued LLVM Phabricator instance.

Simplify ArchSpec::IsFullySpecifiedTriple() (NFC)
ClosedPublic

Authored by aprantl on Apr 1 2022, 8:41 AM.

Details

Summary

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

Diff Detail

Event Timeline

aprantl created this revision.Apr 1 2022, 8:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 8:41 AM
aprantl requested review of this revision.Apr 1 2022, 8:41 AM

LGTM if the answer to both my questions is "yes".

lldb/source/Utility/ArchSpec.cpp
1399–1403

Are you sure that TripleOSWasSpecified() == user_specified_triple.getOS() != llvm::Triple::UnknownOS. Was the check in the original code redundant? Looking at the implementation

bool TripleOSWasSpecified() const { return !m_triple.getOSName().empty(); }

I guess this is identical? But when dealing with triples it's probably worth double checking.

1402

Same for the vendor.

aprantl added inline comments.Apr 1 2022, 9:46 AM
lldb/source/Utility/ArchSpec.cpp
1399–1403

Great question, yes I checked that. The code for both

https://llvm.org/doxygen/Triple_8cpp_source.html#l00524

is a StringSwitch that uses Unknown as the Default case.

This revision was not accepted when it landed; it landed in state Needs Review.Apr 1 2022, 2:16 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 2:16 PM
JDevlieghere added inline comments.Apr 1 2022, 2:35 PM
lldb/source/Utility/ArchSpec.cpp
1399–1403

Thanks for checking!