[llvm-commits] CVS: llvm/tools/llvm-upgrade/UpgradeParser.y
Reid Spencer
reid at x10sys.com
Wed Feb 7 16:21:22 PST 2007
Changes in directory llvm/tools/llvm-upgrade:
UpgradeParser.y updated: 1.58 -> 1.59
---
Log message:
For PR1187: http://llvm.org/PR1187 :
When a naming conflict arises, allow internal linkage functions to be
renamed without warning or error.
---
Diffs of the changes: (+29 -5)
UpgradeParser.y | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
Index: llvm/tools/llvm-upgrade/UpgradeParser.y
diff -u llvm/tools/llvm-upgrade/UpgradeParser.y:1.58 llvm/tools/llvm-upgrade/UpgradeParser.y:1.59
--- llvm/tools/llvm-upgrade/UpgradeParser.y:1.58 Mon Feb 5 15:19:13 2007
+++ llvm/tools/llvm-upgrade/UpgradeParser.y Wed Feb 7 18:21:06 2007
@@ -1655,13 +1655,13 @@
};
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 @@
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 + "'");
More information about the llvm-commits
mailing list