aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests
diff options
context:
space:
mode:
authorkadir çetinkaya <kadircet@google.com>2024-06-14 16:07:42 +0200
committerGitHub <noreply@github.com>2024-06-14 16:07:42 +0200
commit8e0ba08448d5935281e5afd007664d528dd672c4 (patch)
treef6ada8e53ecb7f4d567e0a4a3973d7c9b53d75eb /clang/unittests
parent094572701dce4aaf36f4521d6cf750420d39f206 (diff)
downloadllvm-8e0ba08448d5935281e5afd007664d528dd672c4.zip
llvm-8e0ba08448d5935281e5afd007664d528dd672c4.tar.gz
llvm-8e0ba08448d5935281e5afd007664d528dd672c4.tar.bz2
[clang][HeaderSearch] Fix handling of relative file-paths in suggestPathToFileForDiagnostics (#95121)
Normalize header-to-be-spelled using WorkingDir, similar to search paths themselves. Addresses https://github.com/llvm/llvm-project/issues/81215.
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/Lex/HeaderSearchTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp
index c578fa7..a5f193e 100644
--- a/clang/unittests/Lex/HeaderSearchTest.cpp
+++ b/clang/unittests/Lex/HeaderSearchTest.cpp
@@ -131,6 +131,21 @@ TEST_F(HeaderSearchTest, Dots) {
"z");
}
+TEST_F(HeaderSearchTest, RelativeDirs) {
+ ASSERT_FALSE(VFS->setCurrentWorkingDirectory("/root/some/dir"));
+ addSearchDir("..");
+ EXPECT_EQ(
+ Search.suggestPathToFileForDiagnostics("/root/some/foo.h",
+ /*WorkingDir=*/"/root/some/dir",
+ /*MainFile=*/""),
+ "foo.h");
+ EXPECT_EQ(
+ Search.suggestPathToFileForDiagnostics("../foo.h",
+ /*WorkingDir=*/"/root/some/dir",
+ /*MainFile=*/""),
+ "foo.h");
+}
+
#ifdef _WIN32
TEST_F(HeaderSearchTest, BackSlash) {
addSearchDir("C:\\x\\y\\");