baloghadamsoftware added a comment.

Hi,

Thank you for the patch.

It seems that the new approach still does not solve a problem with anonymous 
structures in typedefs.In C++ a copy constructor is automatically generated, 
and its parameter is the anonymous structure itself. This triggers caching 
`NoLinkage` for it during the import of the constructor, but later fails with 
an assert because at the end the computed linkage is `ExternalLinkage`. It 
seems that anonymous structures are somewhat tricky in the original AST. For 
this struct:

  typedef struct {
    int n;
  } T;

the original AST is:

  CXXRecordDecl 0x1abcb38 </tmp/first.cpp:1:9, line:3:1> line:1:9 imported 
struct definition
  |-FieldDecl 0x1abce68 <line:2:3, col:7> col:7 imported n 'int'
  |-CXXConstructorDecl 0x1abced0 <line:1:9> col:9 imported implicit used  'void 
(void) throw()' inline default trivial
  | `-CompoundStmt 0x1abd2e0 <col:9>
  `-CXXConstructorDecl 0x1abcfd8 <col:9> col:9 imported implicit  'void (const 
T &)' inline default trivial noexcept-unevaluated 0x1abcfd8
    `-ParmVarDecl 0x1abd138 <col:9> col:9 imported 'const T &'
  TypedefDecl 0x1abcc78 </tmp/first.cpp:1:1, line:3:3> col:3 imported 
referenced T 'struct T':'T'
  `-ElaboratedType 0x1abccd0 'struct T' sugar imported
    `-RecordType 0x1abcc50 'T' imported
      `-CXXRecord 0x1abcb38 ''

But the imported one is:

  CXXRecordDecl 0x1a51400 </tmp/first.cpp:1:9> col:9 struct definition
  |-FieldDecl 0x1a51540 <line:2:3, col:7> col:7 n 'int'
  |-CXXConstructorDecl 0x1a515e0 <line:1:9> col:9 implicit used  'void (void) 
throw()' inline trivial
  | `-CompoundStmt 0x1a51688 <col:9>
  `-CXXConstructorDecl 0x1a51768 <col:9> col:9 implicit  'void (const struct 
(anonymous at /tmp/first.cpp:1:9) &)' inline trivial noexcept-unevaluated 
0x1a51768
    `-ParmVarDecl 0x1a51708 <col:9> col:9 'const struct (anonymous at 
/tmp/first.cpp:1:9) &'
  TypedefDecl 0x1a518b0 </tmp/first.cpp:1:1, line:3:3> col:3 T 'struct 
(anonymous struct at /tmp/first.cpp:1:9)':'struct (anonymous at 
/tmp/first.cpp:1:9)'
  `-ElaboratedType 0x1a51860 'struct (anonymous struct at /tmp/first.cpp:1:9)' 
sugar
    `-RecordType 0x1a514a0 'struct (anonymous at /tmp/first.cpp:1:9)'
      `-CXXRecord 0x1a51400 ''


Repository:
  rC Clang

https://reviews.llvm.org/D44079



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to