This is an archive of the discontinued LLVM Phabricator instance.

[llvm] Allow SMLoc to be used in constexpr context
ClosedPublic

Authored by wrengr on Jul 7 2023, 12:49 PM.

Details

Summary

Since StringRef::empty can be used in constexpr context, it seems reasonable that SMLoc::isValid should be too. The default-ctor and operator== are made constexpr for consistency.

In particular, the constexpr keyword is needed for silencing warnings on Windows (whereas Linux allows constexpr usage without the keyword).

Diff Detail

Event Timeline

wrengr created this revision.Jul 7 2023, 12:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 12:49 PM
wrengr requested review of this revision.Jul 7 2023, 12:49 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
wrengr edited the summary of this revision. (Show Details)Jul 7 2023, 12:53 PM

LGTM for the sparse change, but leaving the core LOC stuff to the experts ;-)

jpienaar accepted this revision.Jul 10 2023, 9:29 AM

This seems reasonable to me SMLoc side.

This revision is now accepted and ready to land.Jul 10 2023, 9:29 AM
This revision was automatically updated to reflect the committed changes.