If you run this you can see that the invocations of operator ++ gets <invalid loc> while operator << has a valid location ===== // Command line: c-index-test -test-load-source all file.cpp struct A { int value; A & operator ++ () // preincrement { value += 1; return (*this); } A & operator ++ (int) // postincrement { value += 2; return (*this); } A & operator << (int rhs) { value = 23; return (*this); } }; A a; void func (void) { ++a; // CHECK: <invalid loc>:0:0: DeclRefExpr=operator++:6:7 a++; // CHECK: <invalid loc>:0:0: DeclRefExpr=operator++:11:7 a << 23; // CHECK: file.cpp:29:5: DeclRefExpr=operator<<:16:7 } =====
The underlying issue is that the ast nodes don't have locations: void func() (CompoundStmt 0x7f918403dde0 <t.cpp:24:1, line:28:1> (CXXOperatorCallExpr 0x7f918403d100 <line:25:3, col:5> 'struct A' lvalue (ImplicitCastExpr 0x7f918403d0e8 <<invalid sloc>> 'struct A &(*)(void)' <FunctionToPointerDecay> (DeclRefExpr 0x7f918403d090 <<invalid sloc>> 'struct A &(void)' lvalue CXXMethod 0x7f918403c430 'operator++' 'struct A &(void)')) (DeclRefExpr 0x7f918403d068 <col:5> 'struct A' lvalue Var 0x7f918403cbc0 'a' 'struct A')) (CXXOperatorCallExpr 0x7f918403dcd0 <line:26:3, col:4> 'struct A' lvalue (ImplicitCastExpr 0x7f918403dcb8 <<invalid sloc>> 'struct A &(*)(int)' <FunctionToPointerDecay> (DeclRefExpr 0x7f918403dc68 <<invalid sloc>> 'struct A &(int)' lvalue CXXMethod 0x7f918403c5a0 'operator++' 'struct A &(int)')) (DeclRefExpr 0x7f918403d138 <col:3> 'struct A' lvalue Var 0x7f918403cbc0 'a' 'struct A') (IntegerLiteral 0x7f918403d160 <<invalid sloc>> 'int' 0)) (CXXOperatorCallExpr 0x7f918403dda0 <line:27:3, col:8> 'struct A' lvalue (ImplicitCastExpr 0x7f918403dd88 <col:5, <invalid sloc>> 'struct A &(*)(int)' <FunctionToPointerDecay> (DeclRefExpr 0x7f918403dd60 <col:5, <invalid sloc>> 'struct A &(int)' lvalue CXXMethod 0x7f918403c6e0 'operator<<' 'struct A &(int)')) (DeclRefExpr 0x7f918403dd10 <col:3> 'struct A' lvalue Var 0x7f918403cbc0 'a' 'struct A') (IntegerLiteral 0x7f918403dd38 <col:8> 'int' 23)))
Cloned to <rdar://problem/10324915> [PR11192] Invocation of operator ++ does not get a location
Fixed in r150033