aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-03 19:35:04 +0000
committerChris Lattner <sabre@nondot.org>2001-10-03 19:35:04 +0000
commit8921983734eeb69ffb936d08def7395ac982387b (patch)
treef2d40eaf192fef2799cfc5b1fcca0ec8a25cebe9 /lib
parent4387370c1c6dd64ad01be0fc91836616d908e917 (diff)
downloadexternal_llvm-8921983734eeb69ffb936d08def7395ac982387b.zip
external_llvm-8921983734eeb69ffb936d08def7395ac982387b.tar.gz
external_llvm-8921983734eeb69ffb936d08def7395ac982387b.tar.bz2
Support multiple global's definitions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@711 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AsmParser/llvmAsmParser.y36
1 files changed, 13 insertions, 23 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index f2ae016..6edd279 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -103,7 +103,6 @@ static struct PerMethodInfo {
} CurMeth; // Info for the current method...
static bool inMethodScope() { return CurMeth.CurrentMethod != 0; }
-static bool inModuleScope() { return CurMeth.CurrentMethod == 0; }
//===----------------------------------------------------------------------===//
@@ -457,25 +456,18 @@ static bool setValueName(Value *V, char *NameStr) {
// cerr << "Type: " << Ty->getDescription() << " != "
// << cast<const Type>(V)->getDescription() << "!\n";
} else if (GlobalVariable *EGV = dyn_cast<GlobalVariable>(Existing)) {
- GlobalVariable *GV = cast<GlobalVariable>(V);
-
- // We are allowed to redefine a global variable in two circumstances:
- // 1. If at least one of the globals is uninitialized or
- // 2. If both initializers have the same value.
- //
- // This can only be done if the const'ness of the vars is the same.
- //
- if (EGV->isConstant() == GV->isConstant() &&
- (!EGV->hasInitializer() || !GV->hasInitializer() ||
- EGV->getInitializer() == GV->getInitializer())) {
-
- // Make sure the existing global version gets the initializer!
- if (GV->hasInitializer() && !EGV->hasInitializer())
- EGV->setInitializer(GV->getInitializer());
-
- return true; // They are equivalent!
+ if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
+ if (EGV->isConstant() == GV->isConstant() &&
+ (!EGV->hasInitializer() || !GV->hasInitializer() ||
+ EGV->getInitializer() == GV->getInitializer())) {
+
+ // Make sure the existing global version gets the initializer!
+ if (GV->hasInitializer() && !EGV->hasInitializer())
+ EGV->setInitializer(GV->getInitializer());
+
+ return true; // They are equivalent!
+ }
}
-
}
ThrowException("Redefinition of value name '" + Name + "' in the '" +
V->getType()->getDescription() + "' type plane!");
@@ -1167,12 +1159,10 @@ ResolvedVal : Types ValueRef {
BasicBlockList : BasicBlockList BasicBlock {
- $1->getBasicBlocks().push_back($2);
- $$ = $1;
+ ($$ = $1)->getBasicBlocks().push_back($2);
}
| MethodHeader BasicBlock { // Do not allow methods with 0 basic blocks
- $$ = $1; // in them...
- $1->getBasicBlocks().push_back($2);
+ ($$ = $1)->getBasicBlocks().push_back($2);
}