aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2020-10-15 18:32:34 -0400
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2020-10-22 21:32:28 -0400
commit168db92465c504974274302a6a1a5d4a1580ccfe (patch)
tree5350768359d06854b577e0d3f74bdd8a5346e011 /clang/lib/Basic/SourceManager.cpp
parentb6c6daa95d3aa2206d5a42b46793226f181c3e44 (diff)
downloadllvm-168db92465c504974274302a6a1a5d4a1580ccfe.zip
llvm-168db92465c504974274302a6a1a5d4a1580ccfe.tar.gz
llvm-168db92465c504974274302a6a1a5d4a1580ccfe.tar.bz2
SourceManager: Change SourceManager::isMainFile to take a FileEntry, NFC
`SourceManager::isMainFile` does not use the filename, so it doesn't need the full `FileEntryRef`; in fact, it's misleading to take the name because that makes it look relevant. Simplify the API, and in the process remove some calls to `FileEntryRef::FileEntryRef` in the unit tests (which were blocking making that private to `SourceManager`). Differential Revision: https://reviews.llvm.org/D89507
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r--clang/lib/Basic/SourceManager.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index a3e4e02..c91ef41 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -345,12 +345,11 @@ void SourceManager::clearIDTables() {
createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
}
-bool SourceManager::isMainFile(FileEntryRef SourceFile) {
+bool SourceManager::isMainFile(const FileEntry &SourceFile) {
assert(MainFileID.isValid() && "expected initialized SourceManager");
- auto FE = getFileEntryRefForID(MainFileID);
- if (!FE)
- return false;
- return FE->getUID() == SourceFile.getUID();
+ if (auto *FE = getFileEntryForID(MainFileID))
+ return FE->getUID() == SourceFile.getUID();
+ return false;
}
void SourceManager::initializeForReplay(const SourceManager &Old) {