https://bugs.llvm.org/show_bug.cgi?id=38155

            Bug ID: 38155
           Summary: Missing includes inhibits getting correct inheritance
                    information.
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libclang
          Assignee: unassignedclangb...@nondot.org
          Reporter: 6year...@gmail.com
                CC: kli...@google.com, llvm-bugs@lists.llvm.org

When running

# c-index-test -index-file test.cpp

on this file:

#include "missing1.h"

template<class T>
class A
{
    T a;
};

//#include "missing2.h"

class B : public A<int>
{
};

I get the following output:

[startedTranslationUnit]
[enteredMainFile]: /home/arr/test.cpp
[ppIncludedFile]: (null) | name: "missing1.h" | hash loc: 1:1 | isImport: 0 |
isAngled: 0 | isModule: 0
[indexDeclaration]: kind: c++-class-template | name: A | USR: c:@ST>1#T@A |
lang: C++ | cursor: ClassDecl=A:4:7 (Definition) | loc: 4:7 |
semantic-container: [TU] | lexical-container: [TU] | isRedecl: 0 | isDef: 1 |
isContainer: 1 | isImplicit: 0
[indexDeclaration]: kind: field | name: a | USR: c:@ST>1#T@A@FI@a | lang: C++ |
cursor: FieldDecl=a:6:7 (Definition) | loc: 6:7 | semantic-container: [A:4:7] |
lexical-container: [A:4:7] | isRedecl: 0 | isDef: 1 | isContainer: 0 |
isImplicit: 0
[indexDeclaration]: kind: c++-class | name: B | USR: c:@S@B | lang: C++ |
cursor: ClassDecl=B:11:7 (Definition) | loc: 11:7 | semantic-container: [TU] |
lexical-container: [TU] | isRedecl: 0 | isDef: 1 | isContainer: 1 | isImplicit:
0
     <base>: kind: c++-class-template | name: A | USR: c:@ST>1#T@A | lang: C++
| cursor: C++ base class specifier=A<int>:4:7 [access=public isVirtual=false] |
loc: 11:11
[indexEntityReference]: kind: c++-class-template | name: A | USR: c:@ST>1#T@A |
lang: C++ | cursor: TemplateRef=A:4:7 | loc: 11:18 | <parent>:: kind: c++-class
| name: B | USR: c:@S@B | lang: C++ | container: [B:11:7] | refkind: direct
[diagnostic]: /home/arr/test.cpp:1:10: fatal error: 'missing1.h' file not found

However, if I uncomment #include "missing2.h" line, the output changes to

[startedTranslationUnit]
[enteredMainFile]: /home/arr/test.cpp
[ppIncludedFile]: (null) | name: "missing1.h" | hash loc: 1:1 | isImport: 0 |
isAngled: 0 | isModule: 0
[ppIncludedFile]: (null) | name: "missing2.h" | hash loc: 9:1 | isImport: 0 |
isAngled: 0 | isModule: 0
[indexDeclaration]: kind: c++-class-template | name: A | USR: c:@ST>1#T@A |
lang: C++ | cursor: ClassDecl=A:4:7 (Definition) | loc: 4:7 |
semantic-container: [TU] | lexical-container: [TU] | isRedecl: 0 | isDef: 1 |
isContainer: 1 | isImplicit: 0
[indexDeclaration]: kind: field | name: a | USR: c:@ST>1#T@A@FI@a | lang: C++ |
cursor: FieldDecl=a:6:7 (Definition) | loc: 6:7 | semantic-container: [A:4:7] |
lexical-container: [A:4:7] | isRedecl: 0 | isDef: 1 | isContainer: 0 |
isImplicit: 0
[indexDeclaration]: kind: c++-class | name: B | USR: c:@S@B | lang: C++ |
cursor: ClassDecl=B:11:7 (Definition) | loc: 11:7 | semantic-container: [TU] |
lexical-container: [TU] | isRedecl: 0 | isDef: 1 | isContainer: 1 | isImplicit:
0
[diagnostic]: /home/arr/test.cpp:1:10: fatal error: 'missing1.h' file not found

The difference between outputs is
-     <base>: kind: c++-class-template | name: A | USR: c:@ST>1#T@A | lang: C++
| cursor: C++ base class specifier=A<int>:4:7 [access=public isVirtual=false] |
loc: 11:11
-[indexEntityReference]: kind: c++-class-template | name: A | USR: c:@ST>1#T@A
| lang: C++ | cursor: TemplateRef=A:4:7 | loc: 11:18 | <parent>:: kind:
c++-class | name: B | USR: c:@S@B | lang: C++ | container: [B:11:7] | refkind:
direct


This prevents getting correct information about class B when using libclang
from KDevelop.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to