Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Regression where default template type parameters no longer reported #31512

Open Quuxplusone opened 7 years ago

Quuxplusone commented 7 years ago
Bugzilla Link PR32539
Status NEW
Importance P enhancement
Reported by Nick Fitzgerald (fitzgen@gmail.com)
Reported on 2017-04-05 11:40:46 -0700
Last modified on 2017-04-26 14:30:13 -0700
Version unspecified
Hardware PC Linux
CC emilio@crisal.io, fitzgen@gmail.com, froydnj@gmail.com, klimek@google.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

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@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@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](https://reviews.llvm.org/rG1cd3d77b9a8e18878a1654eb14053732b616b073)
Author: Argyrios Kyrtzidis <akyrtzi@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
Quuxplusone commented 7 years ago

I think I have a potential fix for this, building right now...

Quuxplusone commented 7 years ago

Patch at https://reviews.llvm.org/D31732

Quuxplusone commented 7 years ago

To whomever it concerns: Is it possible for this regression fix (assuming the patch is accepted) to be included in a 4.X point release?

Thanks!

Quuxplusone commented 7 years ago
(In reply to Nick Fitzgerald from comment #3)
> To whomever it concerns: Is it possible for this regression fix (assuming
> the patch is accepted) to be included in a 4.X point release?

Follow instructions in http://lists.llvm.org/pipermail/llvm-dev/2017-
March/111530.html
Quuxplusone commented 7 years ago

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