zyounan added a comment. Oops, an inline comment disappears accidentally.
> #define PLUS_TWO + 2 > int x = 40 PLUS_TW^O; // huh, the value of "+ 2" is "42"? The reason is we're getting a `SelectionNode` with a wider range. Here is the layout of the tree: txt Built selection tree TranslationUnitDecl FunctionDecl void check() CompoundStmt { … .BinaryOperator 40 + 2 *IntegerLiteral 2 The dot prior to AST node kind indicates partial selection and the asterisk indicates complete selection according to SelectionTree::print <https://searchfox.org/llvm/rev/be9c91843bab5bb46574c27836bfcd9ad6fc9ef5/clang-tools-extra/clangd/Selection.cpp#1009>. By invoking `Tree.commonAncestor()` it would stop at `BinaryOperator` despite the fact that we're expecting `IntegerLiteral`, that represents the number being accordance with the macro expansion. In order to address such case, I think we could go down the `SelectionTree` a little further and start evaluating at the node with complete selection. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148457/new/ https://reviews.llvm.org/D148457 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits