[llvm-bugs] [Bug 32539] New: Regression where default template type parameters no longer reported

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 5 11:40:46 PDT 2017


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

            Bug ID: 32539
           Summary: Regression where default template type parameters no
                    longer reported
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nfitzgerald at mozilla.com
                CC: klimek at google.com, llvm-bugs at lists.llvm.org

Given this test case with a template definition using a default template type
parameter:

```
template <typename T, typename U = int>
struct Foo {
    T t;
    U u;
};

static Foo<bool> bar;
```

In libclang 3.9, I get a cursor for `bar`'s template instantiation like this:

```
(
 kind = StructDecl
 spelling = "Foo"
 location = ./tests/headers/default-template-parameter.hpp:2:8
 is-definition? true
 is-declaration? true
 is-inlined-function? false
 usr = "c:@S at Foo>#b#I"
 number-of-template-args = 2

 specialized.kind = ClassTemplate
 specialized.spelling = "Foo"
 specialized.location = ./tests/headers/default-template-parameter.hpp:2:8
 specialized.is-definition? true
 specialized.is-declaration? true
 specialized.is-inlined-function? false
 specialized.template-kind = StructDecl
 specialized.usr = "c:@ST>2#T#T at Foo"

 type.kind = Record
 type.cconv = 100
 type.spelling = "Foo<bool, int>"
 type.number-of-template-args = 2
 type.is-variadic? false
)
```

Then, using `clang_Type_getNumTemplateArguments` and
`clang_Type_getTemplateArgumentAsType`, I get these template arguments:

```
Type(spelling: bool, kind: Bool)
Type(spelling: int, kind: Int)
```

In contrast, with libclang >= 4.0, I get only the explicit template argument,
not the default type:

```
Type(spelling: bool, kind: Bool)
```

Here is the result of bisection on the git monorepo:

```
1cd3d77b9a8e18878a1654eb14053732b616b073 is the first bad commit
commit 1cd3d77b9a8e18878a1654eb14053732b616b073
Author: Argyrios Kyrtzidis <akyrtzi at gmail.com>
Date:   Tue Nov 15 20:51:46 2016 +0000

    [libclang] Generalize clang_getNumTemplateArguments and
clang_getTemplateArgumentAsType to other kind of specializations.

    Patch by Emilio Cobos Álvarez!
    https://reviews.llvm.org/D26663
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170405/2ed162c4/attachment-0001.html>


More information about the llvm-bugs mailing list