diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-22 21:21:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-22 21:21:57 +0000 |
commit | a5ae54acc4608c6b479720a77610c3f2a60c7372 (patch) | |
tree | a4e9ebe0ea79756957ad3a4ae69f917d37690c56 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | d4808924450e86391475b7c6e6c119cd642ae971 (diff) | |
download | bcm5719-llvm-a5ae54acc4608c6b479720a77610c3f2a60c7372.tar.gz bcm5719-llvm-a5ae54acc4608c6b479720a77610c3f2a60c7372.zip |
fix PR3200 by making alias emission use the new infrastructure. Fold
some tests into the alias.c file.
llvm-svn: 67479
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 50743149cc9..f5ce056046d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -57,8 +57,8 @@ CodeGenModule::~CodeGenModule() { } void CodeGenModule::Release() { - EmitDeferred(); EmitAliases(); + EmitDeferred(); if (Runtime) if (llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction()) AddGlobalCtor(ObjCInitFunction); @@ -337,20 +337,26 @@ void CodeGenModule::EmitAliases() { if (!AA) continue; - const std::string& aliaseeName = AA->getAliasee(); - llvm::GlobalValue *aliasee = getModule().getNamedValue(aliaseeName); - if (!aliasee) { - // FIXME: This isn't unsupported, this is just an error, which - // sema should catch, but... - ErrorUnsupported(D, "alias referencing a missing function"); - continue; - } + const llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType()); + + // Unique the name through the identifier table. + const char *AliaseeName = AA->getAliasee().c_str(); + AliaseeName = getContext().Idents.get(AliaseeName).getName(); + + + + llvm::Constant *Aliasee; + if (isa<llvm::FunctionType>(DeclTy)) + Aliasee = GetOrCreateLLVMFunction(AliaseeName, DeclTy, 0); + else + Aliasee = GetOrCreateLLVMGlobal(AliaseeName, + llvm::PointerType::getUnqual(DeclTy), 0); const char *MangledName = getMangledName(D); llvm::GlobalValue *GA = - new llvm::GlobalAlias(aliasee->getType(), + new llvm::GlobalAlias(Aliasee->getType(), llvm::Function::ExternalLinkage, - MangledName, aliasee, &getModule()); + MangledName, Aliasee, &getModule()); llvm::GlobalValue *&Entry = GlobalDeclMap[MangledName]; if (Entry) { |