diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-19 08:27:24 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-19 08:27:24 +0000 |
commit | 5e1e1f95c98b1add70c238093bbd5dc8d4f9c4e9 (patch) | |
tree | 09de4f3ef1fb1b3fcfdc1a98335dc0514e7667ec /lib/CodeGen/CodeGenModule.cpp | |
parent | 56b10ab938f230dba1378830522850cb15dd4699 (diff) |
IRgen support for alias of global variable.
- PR3818.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index aed067617e..cc460c5959 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -369,7 +369,7 @@ void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD, void CodeGenModule::EmitAliases() { for (unsigned i = 0, e = Aliases.size(); i != e; ++i) { - const FunctionDecl *D = Aliases[i]; + const ValueDecl *D = Aliases[i]; const AliasAttr *AA = D->getAttr<AliasAttr>(); // This is something of a hack, if the FunctionDecl got overridden @@ -380,7 +380,7 @@ void CodeGenModule::EmitAliases() { continue; const std::string& aliaseeName = AA->getAliasee(); - llvm::Function *aliasee = getModule().getFunction(aliaseeName); + llvm::GlobalValue *aliasee = getModule().getNamedValue(aliaseeName); if (!aliasee) { // FIXME: This isn't unsupported, this is just an error, which // sema should catch, but... @@ -539,16 +539,14 @@ bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) { } void CodeGenModule::EmitGlobal(const ValueDecl *Global) { - if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Global)) { - // Aliases are deferred until code for everything else has been - // emitted. - if (FD->getAttr<AliasAttr>()) { - assert(!FD->isThisDeclarationADefinition() && - "Function alias cannot have a definition!"); - Aliases.push_back(FD); - return; - } + // Aliases are deferred until code for everything else has been + // emitted. + if (Global->getAttr<AliasAttr>()) { + Aliases.push_back(Global); + return; + } + if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Global)) { // Forward declarations are emitted lazily on first use. if (!FD->isThisDeclarationADefinition()) return; |