[PATCH] D60873: [clang][HeaderSuggestion] Handle the case of dotdot with an absolute path
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 18 13:57:54 PDT 2019
sammccall added inline comments.
Comment at: clang-tools-extra/unittests/clangd/HeadersTests.cpp:220
+ BarHeader = testPath("sub/bar.h");
+ EXPECT_EQ(calculate(BarHeader), "\"sub/bar.h\"");
> sammccall wrote:
> > ormris wrote:
> > > Quick nit: This test won't work on Windows as it only tests for POSIX-style path separators. You could easily add a Windows ifdef, though.
> > testPath() returns an appropriate native path, and calculate() returns an #include string (which always uses /).
> > The "../" on line 217 looks a little more suspicious, but I think the clang driver might silently Do What I Mean here.
> > Are you seeing test failures?
> Yes, here's the output.
> [ RUN ] HeadersTest.ShortenedInclude
> C:\llvm\tools\clang\tools\extra\unittests\clangd\HeadersTests.cpp(220): error: Expected: calculate(BarHeader)
> Which is: "\"sub\\bar.h\""
> To be equal to: "\"sub/bar.h\""
Hmm, that suggests the test is catching a real bug in the code: we should be inserting paths with forward slashes even on Windows.
Looking at the test cases, i have the sinking feeling we've always been doing this and never noticed as no test case has a slash in the final #include. (And none of the main clangd devs are primarily using Windows)
Thank you for pointing this out!
@kadircet: we should either fix this before this patch lands, or ifdef it until we can fix.
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the cfe-commits