summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-12-26 00:52:02 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-12-26 00:52:02 +0000
commitd72f47aa058c10248c27ea70074a1bdd91468a1b (patch)
treef902ea37a85333ff29f0dd91d7f43a1950308f58 /clang/lib/CodeGen/CodeGenModule.cpp
parent3112c877c150d2aea6427098ed6f0d805eb28079 (diff)
downloadbcm5719-llvm-d72f47aa058c10248c27ea70074a1bdd91468a1b.tar.gz
bcm5719-llvm-d72f47aa058c10248c27ea70074a1bdd91468a1b.zip
Add full dllimport / dllexport support: both sema checks and codegen.
Patch by Ilya Okonsky llvm-svn: 61437
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index e83d2cd2930..fc1b108b0d6 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -218,17 +218,30 @@ static void SetGlobalValueAttributes(const Decl *D,
// approximation of what we really want.
if (!ForDefinition) {
// Only a few attributes are set on declarations.
- if (D->getAttr<DLLImportAttr>())
- GV->setLinkage(llvm::Function::DLLImportLinkage);
+ if (D->getAttr<DLLImportAttr>()) {
+ // The dllimport attribute is overridden by a subsequent declaration as
+ // dllexport.
+ if (!D->getAttr<DLLExportAttr>())
+ // dllimport attribute can be applied only to function decls, not to
+ // definitions.
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ if (!FD->getBody())
+ GV->setLinkage(llvm::Function::DLLImportLinkage);
+ } else
+ GV->setLinkage(llvm::Function::DLLImportLinkage);
+ }
} else {
if (IsInternal) {
GV->setLinkage(llvm::Function::InternalLinkage);
} else {
- if (D->getAttr<DLLImportAttr>())
- GV->setLinkage(llvm::Function::DLLImportLinkage);
- else if (D->getAttr<DLLExportAttr>())
- GV->setLinkage(llvm::Function::DLLExportLinkage);
- else if (D->getAttr<WeakAttr>() || IsInline)
+ if (D->getAttr<DLLExportAttr>()) {
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ // The dllexport attribute is ignored for undefined symbols.
+ if (FD->getBody())
+ GV->setLinkage(llvm::Function::DLLExportLinkage);
+ } else
+ GV->setLinkage(llvm::Function::DLLExportLinkage);
+ } else if (D->getAttr<WeakAttr>() || IsInline)
GV->setLinkage(llvm::Function::WeakLinkage);
}
}
OpenPOWER on IntegriCloud