summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2017-10-10 16:53:25 +0000
committerHans Wennborg <hans@hanshq.net>2017-10-10 16:53:25 +0000
commit90ccab6855820cfaec54ec278cfb220bea9c4f5b (patch)
tree275896a5d464b802003e560d4949be6de3a3271b /clang/lib/Sema/SemaDecl.cpp
parent57304923ca62d6b2eaf30797498d055f977eae87 (diff)
downloadbcm5719-llvm-90ccab6855820cfaec54ec278cfb220bea9c4f5b.tar.gz
bcm5719-llvm-90ccab6855820cfaec54ec278cfb220bea9c4f5b.zip
For dllexport class templates, export specializations of member functions (PR34849) (take 2)
This is a re-commit of r315025, but making sure to only apply this to specializations of class template member functions; i.e. not when the function itself is a template. llvm-svn: 315330
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 78ceeedc3ac..541cf693b63 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6041,6 +6041,22 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
diag::warn_dllimport_dropped_from_inline_function)
<< NewDecl << OldImportAttr;
}
+
+ // A specialization of a class template member function is processed here
+ // since it's a redeclaration. If the parent class is dllexport, the
+ // specialization inherits that attribute. This doesn't happen automatically
+ // since the parent class isn't instantiated until later.
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
+ if (MD->getTemplatedKind() == FunctionDecl::TK_MemberSpecialization &&
+ !NewImportAttr && !NewExportAttr) {
+ if (const DLLExportAttr *ParentExportAttr =
+ MD->getParent()->getAttr<DLLExportAttr>()) {
+ DLLExportAttr *NewAttr = ParentExportAttr->clone(S.Context);
+ NewAttr->setInherited(true);
+ NewDecl->addAttr(NewAttr);
+ }
+ }
+ }
}
/// Given that we are within the definition of the given function,
OpenPOWER on IntegriCloud