diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2016-07-11 04:28:21 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2016-07-11 04:28:21 +0000 |
| commit | 60e5bdc4704f46bad75b4a27fcb8820e1c0e6560 (patch) | |
| tree | c0fc2bfdfa85c98852394ddd4b3ce1b186bb476c | |
| parent | 2cac58f6045ef3d5e8407d10dc2ccb30bc470caf (diff) | |
| download | bcm5719-llvm-60e5bdc4704f46bad75b4a27fcb8820e1c0e6560.tar.gz bcm5719-llvm-60e5bdc4704f46bad75b4a27fcb8820e1c0e6560.zip | |
[CodeGen] Treat imported static local variables as declarations
Imported variables cannot really be definitions for the purposes of
IR generation.
llvm-svn: 275040
| -rw-r--r-- | clang/lib/CodeGen/CGDeclCXX.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/dllimport.cpp | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 8f8ffe66b6a..89d142e44b4 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -323,10 +323,6 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, D->hasAttr<CUDASharedAttr>())) return; - // DLL imported variables will be initialized by the export side. - if (D->hasAttr<DLLImportAttr>()) - return; - // Check if we've already initialized this decl. auto I = DelayedCXXInitPosition.find(D); if (I != DelayedCXXInitPosition.end() && I->second == ~0U) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 55b13b4b21b..0161cfb611c 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2851,6 +2851,10 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old, } void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) { + auto DK = VD->isThisDeclarationADefinition(); + if (DK == VarDecl::Definition && VD->hasAttr<DLLImportAttr>()) + return; + TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind(); // If we have a definition, this might be a deferred decl. If the // instantiation is explicit, make sure we emit it at the end. diff --git a/clang/test/CodeGenCXX/dllimport.cpp b/clang/test/CodeGenCXX/dllimport.cpp index 629c2b6c8ba..aff240f2876 100644 --- a/clang/test/CodeGenCXX/dllimport.cpp +++ b/clang/test/CodeGenCXX/dllimport.cpp @@ -676,7 +676,7 @@ namespace ClassTemplateStaticDef { static int x; }; template <typename T> int S<T>::x; - // MSC-DAG: @"\01?x@?$S@H@ClassTemplateStaticDef@@2HA" = available_externally dllimport global i32 0 + // MSC-DAG: @"\01?x@?$S@H@ClassTemplateStaticDef@@2HA" = external dllimport global i32 int f() { return S<int>::x; } // Partial class template specialization static field: @@ -685,7 +685,7 @@ namespace ClassTemplateStaticDef { static int x; }; template <typename A> int T<A*>::x; - // GNU-DAG: @_ZN22ClassTemplateStaticDef1TIPvE1xE = available_externally dllimport global i32 0 + // GNU-DAG: @_ZN22ClassTemplateStaticDef1TIPvE1xE = external dllimport global i32 int g() { return T<void*>::x; } } |

