Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
149–151 | nit: this can be const | |
158–159 | I think using TokenBuffer to translate expanded -> spelled isn't actually an improvement here as the API exposes several possibilities that can't actually happen in our case. The specialized translation from expanded to spelled location is *policy*, and it's pretty easy to implement I think: // For a macro usage `DUMP(foo)`, we want: // - DUMP --> "macro" // - foo --> "variable". SourceLocation getHighlightableSpellingToken(SourceLocation L) { if (L.isFileID()) return SM.isWrittenInMainFile(L) ? L : {}; // Tokens expanded from the macro body contribute no highlightings. if (!SM.isMacroArgExpansion(L)) return {}; // Tokens expanded from macro args are potentially highlightable. return getHighlightableSpellingToken(SM.getImmediateSpellingLocation(L)); } once you have the spelling location, getting the range from tokenbuffer is easy :-) | |
164 | only if this is a macro! |
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
165 | && Tok->location() == Loc, right? (I think this would make a nice method TokenBuffer::spelledTokenAt(SourceLocation) -> const Token*) |
nit: this can be const