sberg created this revision. sberg added a reviewer: rnk. sberg added a subscriber: cfe-commits.
...in cases where a member function is redeclared as a friend of a nested class. (LibreOffice happens to get tripped up by this.) http://reviews.llvm.org/D16632 Files: lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/dllexport.cpp Index: test/CodeGenCXX/dllexport.cpp =================================================================== --- test/CodeGenCXX/dllexport.cpp +++ test/CodeGenCXX/dllexport.cpp @@ -264,6 +264,16 @@ __declspec(dllexport) void friend1() {} void friend2() {} +// MSC-DAG: define dllexport void @"\01?func@Befriended@@SAXXZ"() +// GNU-DAG: define dllexport void @_ZN10Befriended4funcEv() +struct __declspec(dllexport) Befriended { + static void func(); + struct Befriending { + friend void Befriended::func(); + }; +}; +void Befriended::func() {} + // Implicit declarations can be redeclared with dllexport. // MSC-DAG: define dllexport noalias i8* @"\01??2@{{YAPAXI|YAPEAX_K}}@Z"( // GNU-DAG: define dllexport noalias i8* @_Znw{{[yj]}}( Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -765,7 +765,8 @@ if (FD->hasAttr<DLLImportAttr>()) F->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass); - else if (FD->hasAttr<DLLExportAttr>()) + else if (FD->hasAttr<DLLExportAttr>() || + FD->getCanonicalDecl()->hasAttr<DLLExportAttr>()) F->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass); else F->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass);
Index: test/CodeGenCXX/dllexport.cpp =================================================================== --- test/CodeGenCXX/dllexport.cpp +++ test/CodeGenCXX/dllexport.cpp @@ -264,6 +264,16 @@ __declspec(dllexport) void friend1() {} void friend2() {} +// MSC-DAG: define dllexport void @"\01?func@Befriended@@SAXXZ"() +// GNU-DAG: define dllexport void @_ZN10Befriended4funcEv() +struct __declspec(dllexport) Befriended { + static void func(); + struct Befriending { + friend void Befriended::func(); + }; +}; +void Befriended::func() {} + // Implicit declarations can be redeclared with dllexport. // MSC-DAG: define dllexport noalias i8* @"\01??2@{{YAPAXI|YAPEAX_K}}@Z"( // GNU-DAG: define dllexport noalias i8* @_Znw{{[yj]}}( Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -765,7 +765,8 @@ if (FD->hasAttr<DLLImportAttr>()) F->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass); - else if (FD->hasAttr<DLLExportAttr>()) + else if (FD->hasAttr<DLLExportAttr>() || + FD->getCanonicalDecl()->hasAttr<DLLExportAttr>()) F->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass); else F->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits