Summary: | Wrong declaration is caught when class name as template parameter | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Afief Halumi <afief.h> |
Component: | Language Support: CPP (old) | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 5.0.0 | ||
Target Milestone: | --- | ||
Platform: | Appimage | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kdevelop/a453eec244cd056aa9dc55162eb0b5c8a69d0d12 | Version Fixed In: |
Description
Afief Halumi
2016-08-31 18:28:53 UTC
Confirmed. We put the declarations of the template type parameters into the parent context, which confuses our lookup. The solution would be to wrap those into their own context, and then import that one into the ClassTemplate context. Or maybe put them directly into the class template. clang gives us: AST tree successfully generated ClassDecl (4) | type: "Foo" (105) | display: "Foo" | loc: tests/files/bug367893.cpp@[(1,1),(1,10)] | sp-name-range: [(1,7),(1,10)] | isDecl ClassTemplate (31) | display: "Bar<Foo>" | loc: tests/files/bug367893.cpp@[(2,1),(2,33)] | sp-name-range: [(2,30),(2,33)] | isDecl TemplateTypeParameter (27) | type: "Foo" (1) | canonical type: "type-parameter-0-0" (1) | display: "Foo" | loc: tests/files/bug367893.cpp@[(2,10),(2,22)] | sp-name-range: [(2,19),(2,22)] | isDecl ClassDecl (4) | type: "Foo" (105) | display: "Foo" | loc: tests/files/bug367893.cpp@[(4,1),(4,26)] | sp-name-range: [(4,7),(4,10)] | isDecl CXXMethod (21) | type: "void ()" (111) | display: "foo()" | loc: tests/files/bug367893.cpp@[(4,13),(4,23)] | sp-name-range: [(4,18),(4,21)] | isDecl CXXMethod (21) | type: "void ()" (111) | display: "foo()" | loc: tests/files/bug367893.cpp@[(6,1),(6,21)] | sp-name-range: [(6,11),(6,14)] | isDecl TypeRef (43) | type: "Foo" (105) | display: "class Foo" | loc: tests/files/bug367893.cpp@[(6,6),(6,9)] | sp-name-range: [(6,6),(6,9)] | isUse CompoundStmt (202) | loc: tests/files/bug367893.cpp@[(6,17),(6,21)] | sp-name-range: [(0,0),(0,0)] no problems encountered during parsing we build: Top-Context "Global" (owner: 0x0 ) 0x7f3fcc004460 "" [ "" ] [ (0, 0) -> (2147483647, 2147483647) ] "/tmp/testfile_Bh5300.cpp" Declaration: "Foo" [ "Foo" ] 0x7f3fcc04a400 (internal ctx: 0x0 ) [ (1, 14) -> (1, 17) ] , no definition, 1 use(s). File: "/tmp/testfile_Bh5300.cpp" Use: [ (6, 13) -> (6, 16) ] Declaration: "Foo Foo" [ "Foo" ] 0x7f3fcc086f60 (internal ctx: 0x0 ) [ (2, 26) -> (2, 29) ] , no definition, 1 use(s). File: "/tmp/testfile_Bh5300.cpp" Use: [ (6, 13) -> (6, 16) ] Declaration: "Bar" [ "Bar" ] 0x7f3fcc086e40 (internal ctx: 0x0 ) [ (2, 37) -> (2, 40) ] , no definition, 0 use(s). Declaration: "class Foo" [ "Foo" ] 0x7f3fcc0873a0 (internal ctx: 0x7f3fcc072cb0 ) [ (4, 14) -> (4, 17) ] , defined, 1 use(s). File: "/tmp/testfile_Bh5300.cpp" Use: [ (6, 13) -> (6, 16) ] Context "Class" (owner: 0x7f3fcc0873a0 ) 0x7f3fcc072cb0 "Foo" [ "Foo" ] [ (4, 8) -> (4, 33) ] "" 1 Declarations, 1 child-contexts Context "Function" (owner: 0x7f3fcc087e90 ) 0x7f3fcc086e10 "foo" [ "Foo::foo" ] [ (4, 20) -> (4, 30) ] "" 0 Declarations, 0 child-contexts Context "Helper" (owner: 0x0 ) 0x7f3fcc087010 "Foo" [ "Foo" ] [ (6, 8) -> (6, 28) ] "" 1 Declarations, 1 child-contexts Context "Function" (owner: 0x7f3fcc0879c0 ) 0x7f3fcc087a00 "foo" [ "Foo::foo" ] [ (6, 8) -> (6, 28) ] "" 0 Declarations, 1 child-contexts Context "Other" (owner: 0x0 ) 0x7f3fcc0a2170 "" [ "Foo::foo" ] [ (6, 24) -> (6, 28) ] "" 0 Declarations, 0 child-contexts Git commit a453eec244cd056aa9dc55162eb0b5c8a69d0d12 by Milian Wolff. Committed on 07/09/2016 at 12:59. Pushed by mwolff into branch '5.0'. Always open a context for class templates, i.e. also for declarations. Forward declarations of class templates leaked their template paramter declarations into the surrounding context, leading to potentially wrong associations when looking for declarations based on their identifier. M +5 -1 languages/clang/duchain/builder.cpp M +23 -0 languages/clang/tests/test_duchain.cpp M +1 -0 languages/clang/tests/test_duchain.h http://commits.kde.org/kdevelop/a453eec244cd056aa9dc55162eb0b5c8a69d0d12 |