From 6a79e2ff1989b48f4a8ebf3ac51092eb8ad29e37 Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Mon, 1 Aug 2022 18:08:24 -0700 Subject: [clang] Add FileEntryRef::getNameAsRequested() As progress towards having FileManager::getFileRef() return the path as-requested by default, return a FileEntryRef that can use getNameAsRequested() to retrieve this path, with the ultimate goal that this should be the behaviour of getName() and clients should explicitly request the "external" name if they need to (see comment in FileManager::getFileRef). For now, getName() continues to return the external path by looking through the redirects. For now, the new function is only used in unit tests. Differential Revision: https://reviews.llvm.org/D131004 --- clang/unittests/Basic/FileManagerTest.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'clang/unittests/Basic/FileManagerTest.cpp') diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index 6e60bba..419c497 100644 --- a/clang/unittests/Basic/FileManagerTest.cpp +++ b/clang/unittests/Basic/FileManagerTest.cpp @@ -356,9 +356,13 @@ TEST_F(FileManagerTest, getFileRefEquality) { EXPECT_EQ("dir/f1.cpp", F1Redirect->getName()); EXPECT_EQ("dir/f2.cpp", F2->getName()); + EXPECT_EQ("dir/f1.cpp", F1->getNameAsRequested()); + EXPECT_EQ("dir/f1-redirect.cpp", F1Redirect->getNameAsRequested()); + // Compare against FileEntry*. EXPECT_EQ(&F1->getFileEntry(), *F1); EXPECT_EQ(*F1, &F1->getFileEntry()); + EXPECT_EQ(&F1->getFileEntry(), &F1Redirect->getFileEntry()); EXPECT_NE(&F2->getFileEntry(), *F1); EXPECT_NE(*F1, &F2->getFileEntry()); @@ -374,7 +378,7 @@ TEST_F(FileManagerTest, getFileRefEquality) { // Compare using isSameRef. EXPECT_TRUE(F1->isSameRef(*F1Again)); - EXPECT_TRUE(F1->isSameRef(*F1Redirect)); + EXPECT_FALSE(F1->isSameRef(*F1Redirect)); EXPECT_FALSE(F1->isSameRef(*F1Also)); EXPECT_FALSE(F1->isSameRef(*F2)); } -- cgit v1.1