[llvm-bugs] [Bug 36415] New: missing AnnotateAttr for member of templated class

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 16 16:48:06 PST 2018


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

            Bug ID: 36415
           Summary: missing AnnotateAttr for member of templated class
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chris.briend at gmail.com
                CC: llvm-bugs at lists.llvm.org

The AST information generated for a member of an instanciated templated class
only supports one AnnotateAttr in 5.0+. it was supporting multiple attribute
before (clang 3.8 and 4.0).
Given :
//test.h
struct Test
{
    int aMember __attribute__((annotate("testAnnotation1"))) \
        __attribute__((annotate("testAnnotation2")));
};

template <typename Trait>
struct TemplatedTest 
{
    int anotherMember __attribute__((annotate("templTestAnnotation1"))) \
        __attribute__((annotate("templTestAnnotation2")));
};

struct Dummy
{
        TemplatedTest<int> a;
        TemplatedTest<bool> b;
};
//EOF

the command :
clang++.exe -Xclang -ast-dump -fsyntax-only test.h

will generate correct attributes for Test::aMember but not for
TemplatedTest<int>::anotherMember.
More precisely it will generate the correct annotation for the FieldDecl inside
a ClassTemplateDecl, but not inside  a ClassTemplateSpecializationDecl.

partial output :
...
|-CXXRecordDecl 0x1edbd5fabb8 <D:\projects\RefTest\test.h:2:1, line:6:1>
line:2:8 struct Test definition
| |-CXXRecordDecl 0x1edbd653468 <col:1, col:8> col:8 implicit struct Test
| `-FieldDecl 0x1edbd653600 <line:4:5, col:9> col:9 aMember 'int'
|   |-AnnotateAttr 0x1edbd653650 <line:5:24, col:50> "testAnnotation2"
|   `-AnnotateAttr 0x1edbd6536b0 <line:4:32, col:58> "testAnnotation1"
|-ClassTemplateDecl 0x1edbd653848 <line:8:1, line:13:1> line:9:8 TemplatedTest
| |-TemplateTypeParmDecl 0x1edbd6536f8 <line:8:11, col:20> col:20 typename
depth 0 index 0 Trait
| |-CXXRecordDecl 0x1edbd6537b0 <line:9:1, line:13:1> line:9:8 struct
TemplatedTest definition
| | |-CXXRecordDecl 0x1edbd653ac0 <col:1, col:8> col:8 implicit struct
TemplatedTest
| | `-FieldDecl 0x1edbd653c70 <line:11:5, col:9> col:9 anotherMember 'int'
| |   |-AnnotateAttr 0x1edbd653cc0 <line:12:24, col:55> "templTestAnnotation2"
| |   `-AnnotateAttr 0x1edbd653d28 <line:11:38, col:69> "templTestAnnotation1"
| |-ClassTemplateSpecializationDecl 0x1edbd653f48 <line:8:1, line:13:1>
line:9:8 struct TemplatedTest definition
| | |-TemplateArgument type 'int'
| | |-CXXRecordDecl 0x1edbd654160 prev 0x1edbd653f48 <col:1, col:8> col:8
implicit struct TemplatedTest
| | `-FieldDecl 0x1edbd6541f8 <line:11:5, col:9> col:9 anotherMember 'int'
| |   `-AnnotateAttr 0x1edbd654278 <line:12:24> "templTestAnnotation2"
| `-ClassTemplateSpecializationDecl 0x1edbd6503d0 <line:8:1, line:13:1>
line:9:8 struct TemplatedTest definition
|   |-TemplateArgument type '_Bool'
|   |-CXXRecordDecl 0x1edbd6505f0 prev 0x1edbd6503d0 <col:1, col:8> col:8
implicit struct TemplatedTest
|   `-FieldDecl 0x1edbd650688 <line:11:5, col:9> col:9 anotherMember 'int'
|     `-AnnotateAttr 0x1edbd650708 <line:12:24> "templTestAnnotation2"

-- 
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/20180217/509f478a/attachment-0001.html>


More information about the llvm-bugs mailing list