LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 11192 - Invocation of operator ++ does not get a location
Summary: Invocation of operator ++ does not get a location
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-20 10:09 PDT by hans.walheim
Modified: 2012-02-07 20:35 PST (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hans.walheim 2011-10-20 10:09:19 PDT
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
}
=====
Comment 1 Argyrios Kyrtzidis 2011-10-20 14:16:35 PDT
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)))
Comment 2 Argyrios Kyrtzidis 2011-10-21 12:10:10 PDT
Cloned to <rdar://problem/10324915> [PR11192] Invocation of operator ++ does not get a location
Comment 3 Argyrios Kyrtzidis 2012-02-07 20:35:08 PST
Fixed in r150033