summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-14 19:33:47 +0000
committerChris Lattner <sabre@nondot.org>2004-07-14 19:33:47 +0000
commit91393ee84f8e61887b277f7d878105191d59f3c0 (patch)
treeb1dc1b3578c41b93c5aed72a6f184cdb20455086
parent2661c50173d4dbbb07610c48a96b0e5503af5f19 (diff)
downloadbcm5719-llvm-91393ee84f8e61887b277f7d878105191d59f3c0.tar.gz
bcm5719-llvm-91393ee84f8e61887b277f7d878105191d59f3c0.zip
Fix a regression from last night. Apparently the CFE is broken and outputs
functions multiple times, expecting them to be merged. This should be fixed in the CFE, then here. llvm-svn: 14823
-rw-r--r--llvm/lib/AsmParser/llvmAsmParser.y22
1 files changed, 16 insertions, 6 deletions
diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y
index 4dece6e21ca..72c5b014adb 100644
--- a/llvm/lib/AsmParser/llvmAsmParser.y
+++ b/llvm/lib/AsmParser/llvmAsmParser.y
@@ -1551,14 +1551,24 @@ FunctionHeaderH : TypesV Name '(' ArgList ')' {
const PointerType *PFT = PointerType::get(FT);
delete $1;
+ Function *Fn = 0;
// Is the function already in symtab?
- if (CurModule.CurrentModule->getFunction(FunctionName, FT))
- ThrowException("Redefinition of function '" + FunctionName + "'!");
+ if ((Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
+ // Yes it is. If this is the case, either we need to be a forward decl,
+ // or it needs to be.
+ if (!CurFun.isDeclare && !Fn->isExternal())
+ ThrowException("Redefinition of function '" + FunctionName + "'!");
+
+ // Make sure to strip off any argument names so we can't get conflicts...
+ for (Function::aiterator AI = Fn->abegin(), AE = Fn->aend(); AI != AE; ++AI)
+ AI->setName("");
- Function *Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
- CurModule.CurrentModule);
- InsertValue(Fn, CurModule.Values);
- CurModule.DeclareNewGlobalValue(Fn, ValID::create($2));
+ } else { // Not already defined?
+ Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
+ CurModule.CurrentModule);
+ InsertValue(Fn, CurModule.Values);
+ CurModule.DeclareNewGlobalValue(Fn, ValID::create($2));
+ }
free($2); // Free strdup'd memory!
CurFun.FunctionStart(Fn);
OpenPOWER on IntegriCloud