From 15b697214e01cd532e085105c2a2474b9b09c572 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 12 Nov 2003 04:40:30 +0000 Subject: [PATCH] Fix bug PR107, patch contributed by Reid Spencer! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9911 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AsmParser/llvmAsmParser.y | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index a55e735ca49..e930bc55eb8 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -147,6 +147,7 @@ static struct PerFunctionInfo { std::vector LateResolveValues; std::vector Types; std::map LateResolveTypes; + SymbolTable LocalSymtab; bool isDeclare; // Is this function a forward declararation? inline PerFunctionInfo() { @@ -183,7 +184,8 @@ static struct PerFunctionInfo { CurModule.DeclareNewGlobalValue(CurrentFunction, FID); Values.clear(); // Clear out function local definitions - Types.clear(); + Types.clear(); // Clear out function local types + LocalSymtab.clear(); // Clear out function local symbol table CurrentFunction = 0; isDeclare = false; } @@ -555,7 +557,30 @@ static bool setValueName(Value *V, char *NameStr) { V->getType()->getDescription() + "' type plane!"); } + // Set the name V->setName(Name, &ST); + + // If we're in function scope + if (inFunctionScope()) { + // Look up the symbol in the function's local symboltable + Existing = CurFun.LocalSymtab.lookup(V->getType(),Name); + + // If it already exists + if (Existing) { + // Clear the symbol table so it doesn't complain when it + // gets destructed + CurFun.LocalSymtab.clear(); + + // Bail + ThrowException("Redefinition of value named '" + Name + "' in the '" + + V->getType()->getDescription() + "' type plane!"); + + // otherwise, since it doesn't exist + } else { + // Insert it. + CurFun.LocalSymtab.insert(V); + } + } return false; }