[PATCH] D16632: clang-cl: Take dllexport from original function decl into account

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 27 09:43:17 PST 2016


hans added a comment.

Hi Stephan,

I would rather see that we could get this right in the AST.

The problem is that the Befriended::func() definition doesn't have dllexport attached:

  `-CXXMethodDecl 0x5ba1cf0 parent 0x5b4f288 prev 0x5b4f750 <line:7:1, col:26> col:18 used func 'void (void)'
    `-CompoundStmt 0x5ba1de0 <col:25, col:26>

If I drop the friend declaration, it looks like this:

  `-CXXMethodDecl 0x6af2a08 parent 0x6aa0288 prev 0x6aa04c0 <line:7:1, col:26> col:18 used func 'void (void)'
    |-CompoundStmt 0x6af2b30 <col:25, col:26>
    `-DLLExportAttr 0x6af2b20 <line:1:19> Inherited

It's a tricky situation though. I suspect what's happening is that when we build the AST for the friend decl, we haven't yet propagated the dllexport attribute from the 'Befriended' class to 'func'.

If the attribute was put directly on 'func', the friend declaration would pick it up:

  struct  Befriended {
    static void __declspec(dllexport) func();
    struct Befriending {
      friend void Befriended::func();
    };
  };
  void Befriended::func() {}
  
  |-CXXRecordDecl 0x6fe4288 </tmp/a.cc:1:1, line:6:1> line:1:9 struct Befriended definition
  | |-CXXRecordDecl 0x6fe43a0 <col:1, col:9> col:9 implicit struct Befriended
  | |-CXXMethodDecl 0x6fe4480 <line:2:3, col:42> col:37 func 'void (void)' static
  | | `-DLLExportAttr 0x6fe4528 <col:26>
  | `-CXXRecordDecl 0x6fe4560 <line:3:3, line:5:3> line:3:10 struct Befriending definition
  |   |-CXXRecordDecl 0x6fe4670 <col:3, col:10> col:10 implicit struct Befriending
  |   `-FriendDecl 0x6fe4868 <line:4:5, col:34> col:29
  |     `-CXXMethodDecl 0x6fe4740 parent 0x6fe4288 prev 0x6fe4480 <col:5, col:34> col:29 func 'void (void)'
  |       `-DLLExportAttr 0x6fe4858 <line:2:26> Inherited
  `-CXXMethodDecl 0x6fe48c8 parent 0x6fe4288 prev 0x6fe4740 <line:7:1, col:26> col:18 func 'void (void)'
    |-CompoundStmt 0x7036710 <col:25, col:26>
    `-DLLExportAttr 0x6fe49e0 <line:2:26> Inherited

We need to figure out the ordering of applying the dllexport class attribute vs. parsing inner classes.


http://reviews.llvm.org/D16632





More information about the cfe-commits mailing list