-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
c++23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Description
In the following code:
struct S
{
int bar(this S&);
};
int main()
{
S waldo;
int x = waldo.bar();
}The AST dump of main(), taken with a recent trunk, is:
`-FunctionDecl 0x55ac3a911f78 <line:6:1, line:10:1> line:6:5 main 'int ()'
`-CompoundStmt 0x55ac3a912988 <line:7:1, line:10:1>
|-DeclStmt 0x55ac3a9127c8 <line:8:5, col:12>
| `-VarDecl 0x55ac3a9120a8 <col:5, col:7> col:7 used waldo 'S' callinit
| `-CXXConstructExpr 0x55ac3a9127a0 <col:7> 'S' 'void () noexcept'
`-DeclStmt 0x55ac3a912970 <line:9:5, col:24>
`-VarDecl 0x55ac3a9127f8 <col:5, col:23> col:9 x 'int' cinit
`-CallExpr 0x55ac3a912948 <col:19, col:23> 'int'
|-ImplicitCastExpr 0x55ac3a912930 <col:19> 'int (*)(S &)' <FunctionToPointerDecay>
| `-DeclRefExpr 0x55ac3a9128b0 <col:19> 'int (S &)' lvalue CXXMethod 0x55ac3a911e58 'bar' 'int (S &)'
`-DeclRefExpr 0x55ac3a912860 <col:13> 'S' lvalue Var 0x55ac3a9120a8 'waldo' 'S'
The CallExpr for waldo.bar() is reporting col:19 as its begin location, even though the descendant DeclRefExpr for waldo is at col:13.
This is misleading, and causes problems for tooling like clangd whose hit-testing algorithm (used for go-to-definition) skips the CallExpr node when hit-testing the waldo token because it falls outside of the CallExpr's reported source range (#116335).
Metadata
Metadata
Assignees
Labels
c++23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"