mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-13 01:15:32 +00:00
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
This commit is contained in:
parent
49b8b55c29
commit
0ec8200811
@ -2620,15 +2620,39 @@ FunctionHeaderH
|
|||||||
warning("Renaming function '" + FunctionName + "' as '" + NewName +
|
warning("Renaming function '" + FunctionName + "' as '" + NewName +
|
||||||
"' may cause linkage errors");
|
"' may cause linkage errors");
|
||||||
|
|
||||||
|
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 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,
|
Fn = new Function(FT, GlobalValue::ExternalLinkage, NewName,
|
||||||
CurModule.CurrentModule);
|
CurModule.CurrentModule);
|
||||||
InsertValue(Fn, CurModule.Values);
|
InsertValue(Fn, CurModule.Values);
|
||||||
RenameMapKey Key = std::make_pair(FunctionName,PFT);
|
RenameMapKey Key = std::make_pair(FunctionName,PFT);
|
||||||
CurModule.RenameMap[Key] = NewName;
|
CurModule.RenameMap[Key] = NewName;
|
||||||
} else {
|
} else {
|
||||||
// The types are the same. Either the existing or the current function
|
// The types are the same and they are both external linkage. Either
|
||||||
// needs to be a forward declaration. If not, they're attempting to
|
// the existing or the current function needs to be a forward
|
||||||
// redefine a function.
|
// 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())
|
if (!CurFun.isDeclare && !Fn->isDeclaration())
|
||||||
error("Redefinition of function '" + FunctionName + "'");
|
error("Redefinition of function '" + FunctionName + "'");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user