SourceManager: Factor out helpers for common SLocEntry lookup pattern, NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 15 Oct 2020 22:17:17 +0000 (18:17 -0400)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 23 Oct 2020 01:30:31 +0000 (21:30 -0400)
commitb6c6daa95d3aa2206d5a42b46793226f181c3e44
tree26ee736f7a23442e6a963619623692c8496f7e8f
parent3091ed099f2f6a3d16dbdae7d0406f54dfc3031f
SourceManager: Factor out helpers for common SLocEntry lookup pattern, NFC

Add helpers `getSLocEntryOrNull`, which handles the `Invalid` logic
around `getSLocEntry`, and `getSLocEntryForFile`, which also checks for
`SLocEntry::isFile`, and use them to reduce repeated code.

Differential Revision: https://reviews.llvm.org/D89503
clang/include/clang/Basic/SourceManager.h
clang/lib/Basic/SourceManager.cpp