diff options
author | John McCall <rjmccall@apple.com> | 2010-02-24 20:32:01 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-02-24 20:32:01 +0000 |
commit | aea181de04d8be743db1629e0c054abff68500c6 (patch) | |
tree | b9f02c8376509450226cae76f5ed2be2cac40bf1 /clang/lib/CodeGen/CGCXX.cpp | |
parent | 05d9124625b9900f25d2425ab0914675f582c511 (diff) | |
download | bcm5719-llvm-aea181de04d8be743db1629e0c054abff68500c6.tar.gz bcm5719-llvm-aea181de04d8be743db1629e0c054abff68500c6.zip |
Fix an iterator-invalidation bug that was causing selfhost errors
on non-darwin platforms. Fixes PR6411. Test case doesn't reduce,
unfortunately.
llvm-svn: 97055
Diffstat (limited to 'clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCXX.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index 01648ae0747..cb8489d2024 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/lib/CodeGen/CGCXX.cpp @@ -140,15 +140,6 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, const llvm::PointerType *AliasType = getTypes().GetFunctionType(AliasDecl)->getPointerTo(); - // Look for an existing entry. - const char *MangledName = getMangledName(AliasDecl); - llvm::GlobalValue *&Entry = GlobalDeclMap[MangledName]; - if (Entry) { - assert(Entry->isDeclaration() && "definition already exists for alias"); - assert(Entry->getType() == AliasType && - "declaration exists with different type"); - } - // Find the referrent. Some aliases might require a bitcast, in // which case the caller is responsible for ensuring the soundness // of these semantics. @@ -161,8 +152,13 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, llvm::GlobalAlias *Alias = new llvm::GlobalAlias(AliasType, Linkage, "", Aliasee, &getModule()); - // Switch any previous uses to the alias and kill the previous decl. + // Switch any previous uses to the alias. + const char *MangledName = getMangledName(AliasDecl); + llvm::GlobalValue *&Entry = GlobalDeclMap[MangledName]; if (Entry) { + assert(Entry->isDeclaration() && "definition already exists for alias"); + assert(Entry->getType() == AliasType && + "declaration exists with different type"); Entry->replaceAllUsesWith(Alias); Entry->eraseFromParent(); } |