Skip to content

[clangd] Initialize HighlightingsBuilder::Resolver #74971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

HighCommander4
Copy link
Collaborator

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Dec 10, 2023

@llvm/pr-subscribers-clangd

Author: Nathan Ridge (HighCommander4)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/74971.diff

1 Files Affected:

  • (modified) clang-tools-extra/clangd/SemanticHighlighting.cpp (+2-1)
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 49e479abf45621..abc3d1f58a776e 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -418,7 +418,8 @@ class HighlightingsBuilder {
 public:
   HighlightingsBuilder(const ParsedAST &AST, const HighlightingFilter &Filter)
       : TB(AST.getTokens()), SourceMgr(AST.getSourceManager()),
-        LangOpts(AST.getLangOpts()), Filter(Filter) {}
+        LangOpts(AST.getLangOpts()), Filter(Filter),
+        Resolver(AST.getHeuristicResolver()) {}
 
   HighlightingToken &addToken(SourceLocation Loc, HighlightingKind Kind) {
     auto Range = getRangeForSourceLocation(Loc);

@HighCommander4
Copy link
Collaborator Author

Fixing issue spotted in #71279 (comment).

I tried to construct a testcase that the previous code would fail but couldn't: kindForDecl only does something interesting with the resolver for UnresolvedUsingValueDecl, but the call sites in HighlightingsBuilder only use kindForType, which only calls into kindForDecl in the case of a TemplateTypeParmType or TagType, and I don't think those can ever have an UnresolvedUsingValueDecl as their associated decl.

Copy link
Contributor

@zyn0217 zyn0217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! LGTM modulo one nit: could you please remove the nullptr member initializer for Resolver? That looks unnecessary now.

@HighCommander4 HighCommander4 force-pushed the semantic-tokens-heuristic-fixup branch from ed2ccba to 86d99f7 Compare December 11, 2023 03:05
@HighCommander4 HighCommander4 merged commit 9d3ea5a into llvm:main Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants