Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions clang-tools-extra/clangd/Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,14 +1042,20 @@ pointBounds(unsigned Offset, const syntax::TokenBuffer &Tokens) {
const auto &SM = Tokens.sourceManager();
SourceLocation Loc = SM.getComposedLoc(SM.getMainFileID(), Offset);
llvm::SmallVector<std::pair<unsigned, unsigned>, 2> Result;
// Prefer right token over left.
llvm::SmallVector<std::pair<unsigned, unsigned>, 2> ResultLowPrio;
// Prefer right token over left, also non comma over comma.
for (const syntax::Token &Tok :
llvm::reverse(spelledTokensTouching(Loc, Tokens))) {
if (shouldIgnore(Tok))
continue;
unsigned Offset = Tokens.sourceManager().getFileOffset(Tok.location());
Result.emplace_back(Offset, Offset + Tok.length());
if (Tok.kind() == tok::comma) {
ResultLowPrio.emplace_back(Offset, Offset + Tok.length());
} else {
Result.emplace_back(Offset, Offset + Tok.length());
}
}
Result.append(ResultLowPrio);
if (Result.empty())
Result.emplace_back(Offset, Offset);
return Result;
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ TEST(CallHierarchy, HierarchyOnVar) {
TEST(CallHierarchy, HierarchyOnEnumConstant) {
// Tests that the call hierarchy works on enum constants.
Annotations Source(R"cpp(
enum class Coin { heads$Heads^ , tai$Tails^ls };
enum class Coin { heads$Heads^, tai$Tails^ls };
void caller() {
Coin::$CallerH[[heads]];
Coin::$CallerT[[tails]];
Expand Down