Bug 360357

Summary: "Find Uses" should find call to ctor in member initializer list
Product: [Applications] kdevelop Reporter: Alexander Potashev <aspotashev>
Component: Language Support: CPP (Clang-based)Assignee: kdevelop-bugs-null
Status: CONFIRMED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: git master   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Alexander Potashev 2016-03-10 12:48:43 UTC
In the following code sample, "Find Uses" on A::A() should find "m_a(x)" which essentially is a call to A::A(). This currently does not work: "Find Uses" finds only the declaration of A's ctor.

=====
class A
{
public:
    explicit A(int x)
        : m_x(x)
    {
    }

private:
    int m_x;
};

class B
{
public:
    explicit B(int x)
        : m_a(x)
    {
    }
};


Reproducible: Always
Comment 1 Kevin Funk 2016-03-10 12:56:30 UTC
Looks unexposed in libclang.

% cat ~/test5.cpp 
struct A
{
    explicit A(int x)
        : m_x(x) {}

    int m_x;
};

% clang-3.8 -cc1 -ast-dump ~/test5.cpp 
TranslationUnitDecl 0x2ab68c0 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0x2ab6df8 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0x2ab6b10 '__int128'
|-TypedefDecl 0x2ab6e58 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0x2ab6b30 'unsigned __int128'
|-TypedefDecl 0x2ab6ee8 <<invalid sloc>> <invalid sloc> implicit __builtin_ms_va_list 'char *'
| `-PointerType 0x2ab6eb0 'char *'
|   `-BuiltinType 0x2ab6950 'char'
|-TypedefDecl 0x2ab7208 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list 'struct __va_list_tag [1]'
| `-ConstantArrayType 0x2ab71b0 'struct __va_list_tag [1]' 1 
|   `-RecordType 0x2ab6fd0 'struct __va_list_tag'
|     `-CXXRecord 0x2ab6f38 '__va_list_tag'
`-CXXRecordDecl 0x2ab7258 </home/kfunk/test5.cpp:1:1, line:7:1> line:1:8 struct A definition
  |-CXXRecordDecl 0x2ab7370 <col:1, col:8> col:8 implicit referenced struct A
  |-CXXConstructorDecl 0x2ab74f0 <line:3:5, line:4:19> line:3:14 A 'void (int)'
  | |-ParmVarDecl 0x2ab7410 <col:16, col:20> col:20 used x 'int'
  | |-CXXCtorInitializer Field 0x2b06c80 'm_x' 'int'
  | | `-ImplicitCastExpr 0x2b06d50 <line:4:15> 'int' <LValueToRValue>
  | |   `-DeclRefExpr 0x2b06cf8 <col:15> 'int' lvalue ParmVar 0x2ab7410 'x' 'int'
  | `-CompoundStmt 0x2b06d98 <col:18, col:19>
  `-FieldDecl 0x2b06c80 <line:6:5, col:9> col:9 m_x 'int'

% ../kdevelop-stable/languages/clang/tests/clang-parser ~/test5.cpp  -a
StructDecl (2) | type: "A" (105) | display: "A" | loc: /home/kfunk/test5.cpp@[(1,1),(7,2)] | isDecl
  CXXConstructor (24) | type: "void (int)" (111) | display: "A(int)" | loc: /home/kfunk/test5.cpp@[(3,5),(4,20)] | isDecl
    ParmDecl (10) | type: "int" (17) | display: "x" | loc: /home/kfunk/test5.cpp@[(3,16),(3,21)] | isDecl
    MemberRef (47) | type: "int" (17) | display: "m_x" | loc: /home/kfunk/test5.cpp@[(4,11),(4,14)] | isUse
    UnexposedExpr (100) | type: "int" (17) | display: "x" | loc: /home/kfunk/test5.cpp@[(4,15),(4,16)] 
      DeclRefExpr (101) | type: "int" (17) | display: "x" | loc: /home/kfunk/test5.cpp@[(4,15),(4,16)] | isUse
    CompoundStmt (202) | loc: /home/kfunk/test5.cpp@[(4,18),(4,20)] 
  FieldDecl (6) | type: "int" (17) | display: "m_x" | loc: /home/kfunk/test5.cpp@[(6,5),(6,12)] | isDecl

=> CXXCtorInitializer (C++) -> UnexposedExpr (libclang)