summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-12 04:40:30 +0000
committerChris Lattner <sabre@nondot.org>2003-11-12 04:40:30 +0000
commitebcf5a5dba1add8db0d45941fbe939e108091533 (patch)
tree9366a53a286e01a43076b931347596bb3bc31486
parentb0aa83ee0ac2ad9365cd3dde12e3631389ed49cf (diff)
downloadbcm5719-llvm-ebcf5a5dba1add8db0d45941fbe939e108091533.tar.gz
bcm5719-llvm-ebcf5a5dba1add8db0d45941fbe939e108091533.zip
Fix bug PR107, patch contributed by Reid Spencer!
llvm-svn: 9911
-rw-r--r--llvm/lib/AsmParser/llvmAsmParser.y27
1 files changed, 26 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y
index a55e735ca49..e930bc55eb8 100644
--- a/llvm/lib/AsmParser/llvmAsmParser.y
+++ b/llvm/lib/AsmParser/llvmAsmParser.y
@@ -147,6 +147,7 @@ static struct PerFunctionInfo {
std::vector<ValueList> LateResolveValues;
std::vector<PATypeHolder> Types;
std::map<ValID, PATypeHolder> 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;
}
OpenPOWER on IntegriCloud