summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-06-18 15:55:13 +0000
committerHans Wennborg <hans@hanshq.net>2014-06-18 15:55:13 +0000
commitef2272c49e1da9ef22b142ea4a8dca86a9cf80e5 (patch)
tree0e5d398de6a617ade8213438b547087ac3e1ab5e /clang/lib/Sema/SemaDecl.cpp
parentdbb3e3e64f40098a74e1d337cfbc1212959fe832 (diff)
downloadbcm5719-llvm-ef2272c49e1da9ef22b142ea4a8dca86a9cf80e5.tar.gz
bcm5719-llvm-ef2272c49e1da9ef22b142ea4a8dca86a9cf80e5.zip
Inherit dll attributes to static locals
This makes us handle static locals in exported/imported functions correctly. Differential Revision: http://reviews.llvm.org/D4136 llvm-svn: 211173
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 733fdddd165..304fd46cf97 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9097,6 +9097,18 @@ Sema::FinalizeDeclaration(Decl *ThisDecl) {
checkAttributesAfterMerging(*this, *VD);
+ // Static locals inherit dll attributes from their function.
+ if (VD->isStaticLocal()) {
+ if (FunctionDecl *FD =
+ dyn_cast<FunctionDecl>(VD->getParentFunctionOrMethod())) {
+ if (Attr *A = getDLLAttr(FD)) {
+ auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
+ NewAttr->setInherited(true);
+ VD->addAttr(NewAttr);
+ }
+ }
+ }
+
// Imported static data members cannot be defined out-of-line.
if (const DLLImportAttr *IA = VD->getAttr<DLLImportAttr>()) {
if (VD->isStaticDataMember() && VD->isOutOfLine() &&
OpenPOWER on IntegriCloud