[PATCH] D72594: [clangd] Include expression in DecltypeTypeLoc sourcerange while building SelectionTree
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 13 10:16:35 PST 2020
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.
Thanks!
================
Comment at: clang-tools-extra/clangd/Selection.cpp:530
SourceRange S = N.getSourceRange();
+ if (auto *TL = N.get<TypeLoc>()) {
+ // DecltypeTypeLoc only contains the SourceRange for `decltype` keyword.
----------------
Alternately, we could just always return false if it's a DecltypeTypeLoc.
================
Comment at: clang-tools-extra/clangd/Selection.cpp:531
+ if (auto *TL = N.get<TypeLoc>()) {
+ // DecltypeTypeLoc only contains the SourceRange for `decltype` keyword.
+ // We are extending the SourceRange up until the end of the expression
----------------
I think this comment could be a little clearer on the three ranges, and that the AST one is just incorrect.
e.g.
```
// DeclTypeTypeLoc::getSourceRange() is incomplete, which would lead to failing
// to descend into the child expression.
// decltype(2+2);
// XXXXXXXXXXXXX <-- correct range
// XXXXXXXX <-- range reported by getSourceRange()
// XXXXXXXXXXXX <-- range with this hack
```
================
Comment at: clang-tools-extra/clangd/Selection.cpp:534
+ // inside decltype. Note that this will not include the closing
+ // parenthese.
+ // FIXME: Alter DecltypeTypeLoc to contain parentheses locations and get
----------------
nit: parenthesis
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72594/new/
https://reviews.llvm.org/D72594
More information about the cfe-commits
mailing list