aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-02-08 00:21:06 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-02-08 00:21:06 +0000
commit0ec82008117706190cf99c396479c8b2bb42519b (patch)
tree37c580f0bca3adb9053148d543597c8be4aef6ce
parent49b8b55c29e2733f9b15872509319f22de72415e (diff)
For PR1187:
When a naming conflict arises, allow internal linkage functions to be renamed without warning or error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34024 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/llvm-upgrade/UpgradeParser.y34
1 files changed, 29 insertions, 5 deletions
diff --git a/tools/llvm-upgrade/UpgradeParser.y b/tools/llvm-upgrade/UpgradeParser.y
index 3091ea3ba2..46541355b5 100644
--- a/tools/llvm-upgrade/UpgradeParser.y
+++ b/tools/llvm-upgrade/UpgradeParser.y
@@ -1655,13 +1655,13 @@ OptAssign
};
OptLinkage
- : INTERNAL { $$ = GlobalValue::InternalLinkage; }
+ : INTERNAL { $$ = GlobalValue::InternalLinkage; }
| LINKONCE { $$ = GlobalValue::LinkOnceLinkage; }
| WEAK { $$ = GlobalValue::WeakLinkage; }
| APPENDING { $$ = GlobalValue::AppendingLinkage; }
| DLLIMPORT { $$ = GlobalValue::DLLImportLinkage; }
| DLLEXPORT { $$ = GlobalValue::DLLExportLinkage; }
- | EXTERN_WEAK { $$ = GlobalValue::ExternalWeakLinkage; }
+ | EXTERN_WEAK { $$ = GlobalValue::ExternalWeakLinkage; }
| /*empty*/ { $$ = GlobalValue::ExternalLinkage; }
;
@@ -2625,10 +2625,34 @@ FunctionHeaderH
InsertValue(Fn, CurModule.Values);
RenameMapKey Key = std::make_pair(FunctionName,PFT);
CurModule.RenameMap[Key] = NewName;
+ } else if (Fn->hasInternalLinkage()) {
+ // The function we are creating conflicts in name with another function
+ // that has internal linkage. We'll rename that one quietly to get rid
+ // of the conflict.
+ Fn->setName(makeNameUnique(Fn->getName()));
+ RenameMapKey Key = std::make_pair(FunctionName,PFT);
+ CurModule.RenameMap[Key] = Fn->getName();
+
+ Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
+ CurModule.CurrentModule);
+
+ InsertValue(Fn, CurModule.Values);
+ } else if (CurFun.Linkage == GlobalValue::InternalLinkage) {
+ // The function we are creating has internal linkage and conflicts with
+ // another function of the same name. We'll just rename this one
+ // quietly because its internal linkage can't conflict with anything
+ // else.
+ std::string NewName = makeNameUnique(FunctionName);
+ Fn = new Function(FT, GlobalValue::ExternalLinkage, NewName,
+ CurModule.CurrentModule);
+ InsertValue(Fn, CurModule.Values);
+ RenameMapKey Key = std::make_pair(FunctionName,PFT);
+ CurModule.RenameMap[Key] = NewName;
} else {
- // The types are the same. Either the existing or the current function
- // needs to be a forward declaration. If not, they're attempting to
- // redefine a function.
+ // The types are the same and they are both external linkage. Either
+ // the existing or the current function needs to be a forward
+ // declaration. If not, they're attempting to redefine two external
+ // functions. This wasn't allowed in llvm 1.9 and it isn't allowed now.
if (!CurFun.isDeclare && !Fn->isDeclaration())
error("Redefinition of function '" + FunctionName + "'");