This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Put additional qualifiers to enum constants not declared as "enum class"
AbandonedPublic

Authored by kbobyrev on Nov 16 2021, 2:06 AM.

Details

Reviewers
kadircet
Summary

This if a fix of a problem related to
https://github.com/clangd/clangd/issues/39. Currently, for this code:

c++
namespace ns {
enum Color { Green };
enum class Vehicle { Car };
}

The following is true:

  • Vehicle::Car scope is ns::Vehicle:: - it can't be accessed without spelling full enum class name
  • Color::Green scope is ns:: because it can be accessed as ns::Car

However, this causes index FuzzyFind to show empty results when querying
ns::Color:: - Color::Green will only show up for ns::.

This patch changes the behavior and makes SymbolCollector treat plain enum
the same way it does handle enum class. Ideally, the index would point to the
same symbol for both ns::Green and ns::Color::Green but that increases
coupling since the enum information has to be propagated to the index builder
which is logically quite far from the SymbolCollector.

Diff Detail

Event Timeline

kbobyrev created this revision.Nov 16 2021, 2:06 AM
kbobyrev requested review of this revision.Nov 16 2021, 2:06 AM
kbobyrev edited the summary of this revision. (Show Details)Nov 16 2021, 2:08 AM
kbobyrev planned changes to this revision.Nov 16 2021, 2:11 AM

Actually, I'm not sure this change is worth it. Maybe the intent of not having enum class is actually making the constants discoverable from the outer scope.

kbobyrev abandoned this revision.Nov 17 2021, 7:58 AM
nridge added a subscriber: nridge.Nov 21 2021, 9:14 PM