[llvm] r284129 - Do not delete leading ../ in remove_dots.
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 14 08:14:58 PDT 2016
This breaks the clang-hexagon-elf bot:
You may need to build clang with Hexagon as the default target
(hexagon-unknown-elf).
c-index-test -index-file
/path/to/llvm/tools/clang/test/VFS/real-path-found-first.m -fmodules
-fimplicit-module-maps -ivfsoverlay x.yaml -fsyntax-only
c-index-test: tools/clang/lib/Basic/VirtualFileSystem.cpp:1485:
ErrorOr<(anonymous namespace)::Entry *> (anonymous
namespace)::RedirectingFileSystem::lookupPath(sys::path::const_iterator,
sys::path::const_iterator, (anonymous namespace)::Entry *): Assertion
`!isTraversalComponent(*Start) && !isTraversalComponent(From->getName())
&& "Paths should not contain traversal components"' failed.
libclang: crash detected during indexing source file: {
'source_filename' : '(null)'
'command_line_args' : ['clang',
'/path/to/llvm/tools/clang/test/VFS/real-path-found-first.m',
'-fmodules', '-fimplicit-module-maps', '-ivfsoverlay', 'x.yaml',
'-fsyntax-only'],
'unsaved_files' : [],
'options' : 1,
}
Failure (no details available)
--- x.yaml ---
{
'version': 0,
'roots': [
{ 'name': '/tmp', 'type': 'directory',
'contents': [
{ 'name': 'not_real.h', 'type': 'file',
'external-contents': 'header.h'
}
]
}
]
}
--------------
-Krzysztof
On 10/13/2016 10:07 AM, Eric Liu via llvm-commits wrote:
> Author: ioeric
> Date: Thu Oct 13 10:07:14 2016
> New Revision: 284129
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284129&view=rev
> Log:
> Do not delete leading ../ in remove_dots.
>
> Reviewers: bkramer
>
> Subscribers: llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D25561
>
> Modified:
> llvm/trunk/include/llvm/Support/Path.h
> llvm/trunk/lib/Support/Path.cpp
> llvm/trunk/unittests/Support/Path.cpp
>
> Modified: llvm/trunk/include/llvm/Support/Path.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Path.h?rev=284129&r1=284128&r2=284129&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/Path.h (original)
> +++ llvm/trunk/include/llvm/Support/Path.h Thu Oct 13 10:07:14 2016
> @@ -445,7 +445,8 @@ StringRef remove_leading_dotslash(String
> /// @brief In-place remove any './' and optionally '../' components from a path.
> ///
> /// @param path processed path
> -/// @param remove_dot_dot specify if '../' should be removed
> +/// @param remove_dot_dot specify if '../' (except for leading "../") should be
> +/// removed
> /// @result True if path was changed
> bool remove_dots(SmallVectorImpl<char> &path, bool remove_dot_dot = false);
>
>
> Modified: llvm/trunk/lib/Support/Path.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=284129&r1=284128&r2=284129&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/Path.cpp (original)
> +++ llvm/trunk/lib/Support/Path.cpp Thu Oct 13 10:07:14 2016
> @@ -707,12 +707,11 @@ static SmallString<256> remove_dots(Stri
> for (StringRef C : llvm::make_range(path::begin(rel), path::end(rel))) {
> if (C == ".")
> continue;
> - if (remove_dot_dot) {
> - if (C == "..") {
> - if (!components.empty())
> - components.pop_back();
> - continue;
> - }
> + // Leading ".." will remain in the path.
> + if (remove_dot_dot && C == ".." && !components.empty() &&
> + components.back() != "..") {
> + components.pop_back();
> + continue;
> }
> components.push_back(C);
> }
>
> Modified: llvm/trunk/unittests/Support/Path.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=284129&r1=284128&r2=284129&view=diff
> ==============================================================================
> --- llvm/trunk/unittests/Support/Path.cpp (original)
> +++ llvm/trunk/unittests/Support/Path.cpp Thu Oct 13 10:07:14 2016
> @@ -965,6 +965,8 @@ TEST(Support, RemoveDots) {
> EXPECT_EQ("a\\..\\b\\c", remove_dots(".\\a\\..\\b\\c", false));
> EXPECT_EQ("b\\c", remove_dots(".\\a\\..\\b\\c", true));
> EXPECT_EQ("c", remove_dots(".\\.\\c", true));
> + EXPECT_EQ("..\\a\\c", remove_dots("..\\a\\b\\..\\c", true));
> + EXPECT_EQ("..\\..\\a\\c", remove_dots("..\\..\\a\\b\\..\\c", true));
>
> SmallString<64> Path1(".\\.\\c");
> EXPECT_TRUE(path::remove_dots(Path1, true));
> @@ -976,6 +978,8 @@ TEST(Support, RemoveDots) {
> EXPECT_EQ("a/../b/c", remove_dots("./a/../b/c", false));
> EXPECT_EQ("b/c", remove_dots("./a/../b/c", true));
> EXPECT_EQ("c", remove_dots("././c", true));
> + EXPECT_EQ("../a/c", remove_dots("../a/b/../c", true));
> + EXPECT_EQ("../../a/c", remove_dots("../../a/b/../c", true));
>
> SmallString<64> Path1("././c");
> EXPECT_TRUE(path::remove_dots(Path1, true));
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the llvm-commits
mailing list