r359075 - [clang][HeaderSearch] Make sure there are no backslashes in suggestedPath
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 24 01:45:03 PDT 2019
Author: kadircet
Date: Wed Apr 24 01:45:03 2019
New Revision: 359075
URL: http://llvm.org/viewvc/llvm-project?rev=359075&view=rev
Log:
[clang][HeaderSearch] Make sure there are no backslashes in suggestedPath
Reviewers: sammccall
Differential Revision: https://reviews.llvm.org/D60995
Modified:
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/unittests/Lex/HeaderSearchTest.cpp
Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=359075&r1=359074&r2=359075&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed Apr 24 01:45:03 2019
@@ -706,16 +706,18 @@ public:
/// Retrieve a uniqued framework name.
StringRef getUniqueFrameworkName(StringRef Framework);
- /// Suggest a path by which the specified file could be found, for
- /// use in diagnostics to suggest a #include.
+ /// Suggest a path by which the specified file could be found, for use in
+ /// diagnostics to suggest a #include. Returned path will only contain forward
+ /// slashes as separators.
///
/// \param IsSystem If non-null, filled in to indicate whether the suggested
/// path is relative to a system header directory.
std::string suggestPathToFileForDiagnostics(const FileEntry *File,
bool *IsSystem = nullptr);
- /// Suggest a path by which the specified file could be found, for
- /// use in diagnostics to suggest a #include.
+ /// Suggest a path by which the specified file could be found, for use in
+ /// diagnostics to suggest a #include. Returned path will only contain forward
+ /// slashes as separators.
///
/// \param WorkingDir If non-empty, this will be prepended to search directory
/// paths that are relative.
Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=359075&r1=359074&r2=359075&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Apr 24 01:45:03 2019
@@ -1720,5 +1720,5 @@ std::string HeaderSearch::suggestPathToF
if (IsSystem)
*IsSystem = BestPrefixLength ? BestSearchDir >= SystemDirIdx : false;
- return File.drop_front(BestPrefixLength);
+ return path::convert_to_slash(File.drop_front(BestPrefixLength));
}
Modified: cfe/trunk/unittests/Lex/HeaderSearchTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/HeaderSearchTest.cpp?rev=359075&r1=359074&r2=359075&view=diff
==============================================================================
--- cfe/trunk/unittests/Lex/HeaderSearchTest.cpp (original)
+++ cfe/trunk/unittests/Lex/HeaderSearchTest.cpp Wed Apr 24 01:45:03 2019
@@ -91,5 +91,14 @@ TEST_F(HeaderSearchTest, Dots) {
"z");
}
+#ifdef _WIN32
+TEST_F(HeaderSearchTest, BackSlash) {
+ addSearchDir("C:\\x\\y\\");
+ EXPECT_EQ(Search.suggestPathToFileForDiagnostics("C:\\x\\y\\z\\t",
+ /*WorkingDir=*/""),
+ "z/t");
+}
+#endif
+
} // namespace
} // namespace clang
More information about the cfe-commits
mailing list