diff options
author | Hans Wennborg <hans@hanshq.net> | 2014-11-03 14:24:45 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2014-11-03 14:24:45 +0000 |
commit | 956edcd5d506674e57a2051a31ad6c9853fc6769 (patch) | |
tree | 4e8d5a9cfc7abfe5b62b4da09c736616e866cfe3 /lib/Sema/SemaDeclCXX.cpp | |
parent | d1bd62a32b74f3e6eda2d437a92b6244ebc56600 (diff) |
Don't dllimport inline functions when targeting MinGW (PR21366)
It turns out that MinGW never dllimports of exports inline functions.
This means that code compiled with Clang would fail to link with
MinGW-compiled libraries since we might try to import functions that
are not imported.
To fix this, make Clang never dllimport inline functions when targeting
MinGW.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221154 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index e7171831f6..031edf1515 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -4655,7 +4655,9 @@ static void checkDLLAttribute(Sema &S, CXXRecordDecl *Class) { // Don't inherit dll attribute until the template is instantiated. return; - bool ClassExported = ClassAttr->getKind() == attr::DLLExport; + // The class is either imported or exported. + const bool ClassExported = ClassAttr->getKind() == attr::DLLExport; + const bool ClassImported = !ClassExported; // Force declaration of implicit members so they can inherit the attribute. S.ForceDeclarationOfImplicitMembers(Class); @@ -4674,15 +4676,22 @@ static void checkDLLAttribute(Sema &S, CXXRecordDecl *Class) { if (!VD && !MD) continue; - // Don't process deleted methods. - if (MD && MD->isDeleted()) - continue; + if (MD) { + // Don't process deleted methods. + if (MD->isDeleted()) + continue; - if (MD && MD->isMoveAssignmentOperator() && !ClassExported && - MD->isInlined()) { - // Current MSVC versions don't export the move assignment operators, so - // don't attempt to import them if we have a definition. - continue; + if (MD->isMoveAssignmentOperator() && ClassImported && MD->isInlined()) { + // Current MSVC versions don't export the move assignment operators, so + // don't attempt to import them if we have a definition. + continue; + } + + if (MD->isInlined() && ClassImported && + !S.Context.getTargetInfo().getCXXABI().isMicrosoft()) { + // MinGW does not import inline functions. + continue; + } } if (!getDLLAttr(Member)) { |