[PATCH] D110386: [clangd] Refactor IncludeStructure: use File (unsigned) for most computations
Kirill Bobyrev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 27 06:11:33 PDT 2021
kbobyrev added inline comments.
================
Comment at: clang-tools-extra/clangd/Headers.cpp:205
CurrentLevel.push_back(Child);
- const auto &Name = RealPathNames[Child];
// Can't include files if we don't have their real path.
+ if (!RealPathNames[static_cast<unsigned>(Child)].empty())
----------------
sammccall wrote:
> This is no longer true, we don't need the check.
Wait, why not? We still have unresolved includes, e.g. preamble patches are like that, their `RealPathName`s stay empty.
================
Comment at: clang-tools-extra/clangd/unittests/HeadersTests.cpp:234
+ auto Includes = collectIncludes();
+ EXPECT_THAT(Includes.IncludeChildren[getID(MainFile)],
+ UnorderedElementsAreArray({getID(FooHeader), getID(BarHeader)}));
----------------
sammccall wrote:
> Why are we asserting on every element of the map one at a time, instead of the whole map at once? Seems like it would be more regular and easier to read.
>
> I'd probably just write:
> ```
> DenseMap<HeaderID, SmallVector<HeaderID>> Expected = { ... };
> EXPECT_EQ(Expected, Includes.IncludeChildren);
> ```
This would expect the elements in the map to be in a particular order, isn't this something we don't want?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110386/new/
https://reviews.llvm.org/D110386
More information about the cfe-commits
mailing list