diff options
author | Chris Lattner <sabre@nondot.org> | 2007-09-10 23:23:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-09-10 23:23:53 +0000 |
commit | 9d99b31b1833269ea3eef906d6034079fa7ed869 (patch) | |
tree | 5e0d8964645533bf9b5d67ecf2728e4e6774c422 /lib/AsmParser/llvmAsmParser.y | |
parent | 029e1c4e1140d0daf5fb5791e000eda4ae91335a (diff) | |
download | external_llvm-9d99b31b1833269ea3eef906d6034079fa7ed869.zip external_llvm-9d99b31b1833269ea3eef906d6034079fa7ed869.tar.gz external_llvm-9d99b31b1833269ea3eef906d6034079fa7ed869.tar.bz2 |
Fix PR1645 by resolving forward alias references.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41815 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/llvmAsmParser.y')
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index cf9e5a7..6364b29 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -2129,6 +2129,27 @@ Definition CurModule.CurrentModule); GA->setVisibility($2); InsertValue(GA, CurModule.Values); + + + // If there was a forward reference of this alias, resolve it now. + + ValID ID; + if (!Name.empty()) + ID = ValID::createGlobalName(Name); + else + ID = ValID::createGlobalID(CurModule.Values.size()-1); + + if (GlobalValue *FWGV = + CurModule.GetForwardRefForGlobal(GA->getType(), ID)) { + // Replace uses of the fwdref with the actual alias. + FWGV->replaceAllUsesWith(GA); + if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV)) + GV->eraseFromParent(); + else + cast<Function>(FWGV)->eraseFromParent(); + } + ID.destroy(); + CHECK_FOR_ERROR } | TARGET TargetDefinition { |