From d038bb196c51dcf80cbe771f4229b4e227c6c5b6 Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Fri, 5 Aug 2022 10:56:56 -0700 Subject: [clang] Fix redirection behaviour for cached FileEntryRef In 6a79e2ff1989b we changed Filemanager::getEntryRef() to return the redirecting FileEntryRef instead of looking through the redirection. This commit fixes the case when looking up a cached file path to also return the redirecting FileEntryRef. This mainly affects the behaviour of calling getNameAsRequested() on the resulting entry ref. Differential Revision: https://reviews.llvm.org/D131273 --- clang/unittests/Basic/FileManagerTest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang/unittests/Basic/FileManagerTest.cpp') diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index 419c497..6fe4a3d 100644 --- a/clang/unittests/Basic/FileManagerTest.cpp +++ b/clang/unittests/Basic/FileManagerTest.cpp @@ -340,6 +340,7 @@ TEST_F(FileManagerTest, getFileRefEquality) { auto F1Again = manager.getFileRef("dir/f1.cpp"); auto F1Also = manager.getFileRef("dir/f1-also.cpp"); auto F1Redirect = manager.getFileRef("dir/f1-redirect.cpp"); + auto F1RedirectAgain = manager.getFileRef("dir/f1-redirect.cpp"); auto F2 = manager.getFileRef("dir/f2.cpp"); // Check Expected for error. @@ -347,6 +348,7 @@ TEST_F(FileManagerTest, getFileRefEquality) { ASSERT_FALSE(!F1Also); ASSERT_FALSE(!F1Again); ASSERT_FALSE(!F1Redirect); + ASSERT_FALSE(!F1RedirectAgain); ASSERT_FALSE(!F2); // Check names. @@ -354,6 +356,7 @@ TEST_F(FileManagerTest, getFileRefEquality) { EXPECT_EQ("dir/f1.cpp", F1Again->getName()); EXPECT_EQ("dir/f1-also.cpp", F1Also->getName()); EXPECT_EQ("dir/f1.cpp", F1Redirect->getName()); + EXPECT_EQ("dir/f1.cpp", F1RedirectAgain->getName()); EXPECT_EQ("dir/f2.cpp", F2->getName()); EXPECT_EQ("dir/f1.cpp", F1->getNameAsRequested()); @@ -363,6 +366,7 @@ TEST_F(FileManagerTest, getFileRefEquality) { EXPECT_EQ(&F1->getFileEntry(), *F1); EXPECT_EQ(*F1, &F1->getFileEntry()); EXPECT_EQ(&F1->getFileEntry(), &F1Redirect->getFileEntry()); + EXPECT_EQ(&F1->getFileEntry(), &F1RedirectAgain->getFileEntry()); EXPECT_NE(&F2->getFileEntry(), *F1); EXPECT_NE(*F1, &F2->getFileEntry()); @@ -371,6 +375,7 @@ TEST_F(FileManagerTest, getFileRefEquality) { EXPECT_EQ(*F1, *F1Again); EXPECT_EQ(*F1, *F1Redirect); EXPECT_EQ(*F1Also, *F1Redirect); + EXPECT_EQ(*F1, *F1RedirectAgain); EXPECT_NE(*F2, *F1); EXPECT_NE(*F2, *F1Also); EXPECT_NE(*F2, *F1Again); @@ -381,6 +386,7 @@ TEST_F(FileManagerTest, getFileRefEquality) { EXPECT_FALSE(F1->isSameRef(*F1Redirect)); EXPECT_FALSE(F1->isSameRef(*F1Also)); EXPECT_FALSE(F1->isSameRef(*F2)); + EXPECT_TRUE(F1Redirect->isSameRef(*F1RedirectAgain)); } // getFile() Should return the same entry as getVirtualFile if the file actually -- cgit v1.1