De-duplicate comments and declaration locations in reduce function.
When two files include the same header file, this file's content is mapped twice causing comments and locations to be duplicated after the reduce stage.
Details
Diff Detail
Event Timeline
Please add a test case to unittests/clang-doc/MergeTest.cpp.
clang-tools-extra/clang-doc/Representation.cpp | ||
---|---|---|
125–128 | if (std::find(Description.begin(), Description.end(), Comment) == Description.end()) Description.emplace_back(std::move(Comment)); | |
clang-tools-extra/clang-doc/Representation.h | ||
90–98 | Use std::tie here (see Reference::operator== below as an example). |
Actually if we can make Description a hash set that would be best. I think using std::set would require an awkward < operator to be defined. There should be standard ways of getting hashes out of all the string and vector types and you can use hash_combine to combine all of these into a single hash.
This SGTM -- this would actually make it a bit more deterministic in the ordering, since we'd no longer depend on the order of file load, even.
clang-tools-extra/clang-doc/Representation.cpp | ||
---|---|---|
138–142 | While you're here, could you actually do the same for Location? That is, make it a hash set on SymbolInfo and dedup here? |
Change how the vectors are de-duplicated.
Add de-duplication of declaration locations.
Add tests.
clang-tools-extra/clang-doc/Representation.cpp | ||
---|---|---|
125 | The YAML generator uses an llvm method that doesn't support sets, so changing Description to a set would break that. |
LGTM
clang-tools-extra/clang-doc/Representation.h | ||
---|---|---|
66 | We should be explicit about what we intend to happen here. Do we just want a total ordering of any kind? Do we want some things to be "more important" than others? For instance because the ordering is lexicographical here Kind is more important than Text which is more important than Name etc... If the intent is just to have any total order state so at the top and why we need a total ordering (for instance to have an std::set/std::map of these things or we need to sort them, etc...) | |
190 | Same comment here. |
We should be explicit about what we intend to happen here. Do we just want a total ordering of any kind? Do we want some things to be "more important" than others? For instance because the ordering is lexicographical here Kind is more important than Text which is more important than Name etc...
If the intent is just to have any total order state so at the top and why we need a total ordering (for instance to have an std::set/std::map of these things or we need to sort them, etc...)