[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Chris Lattner
lattner at cs.uiuc.edu
Wed Jul 14 12:33:57 PDT 2004
Changes in directory llvm/lib/AsmParser:
llvmAsmParser.y updated: 1.184 -> 1.185
---
Log message:
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.
---
Diffs of the changes: (+17 -7)
Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.184 llvm/lib/AsmParser/llvmAsmParser.y:1.185
--- llvm/lib/AsmParser/llvmAsmParser.y:1.184 Wed Jul 14 03:23:52 2004
+++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 14:33:47 2004
@@ -1551,14 +1551,24 @@
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 + "'!");
-
- Function *Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
- CurModule.CurrentModule);
- InsertValue(Fn, CurModule.Values);
- CurModule.DeclareNewGlobalValue(Fn, ValID::create($2));
+ 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("");
+
+ } 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);
More information about the llvm-commits
mailing list