mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
simplify function visibility handling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52133 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
301d5b48cb
commit
bc3d1c7e4c
@ -827,19 +827,22 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
|||||||
&Dest->getTypeSymbolTable(), "");
|
&Dest->getTypeSymbolTable(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DF && DF->hasInternalLinkage())
|
||||||
|
DF = NULL;
|
||||||
|
|
||||||
// Check visibility
|
// Check visibility
|
||||||
if (DF && !DF->hasInternalLinkage() &&
|
if (DF && SF->getVisibility() != DF->getVisibility()) {
|
||||||
SF->getVisibility() != DF->getVisibility()) {
|
|
||||||
// If one is a prototype, ignore its visibility. Prototypes are always
|
// If one is a prototype, ignore its visibility. Prototypes are always
|
||||||
// overridden by the definition.
|
// overridden by the definition.
|
||||||
if (!SF->isDeclaration() && !DF->isDeclaration())
|
if (!SF->isDeclaration() && !DF->isDeclaration())
|
||||||
return Error(Err, "Linking functions named '" + SF->getName() +
|
return Error(Err, "Linking functions named '" + SF->getName() +
|
||||||
"': symbols have different visibilities!");
|
"': symbols have different visibilities!");
|
||||||
|
|
||||||
|
// Otherwise, replace the visibility of DF if DF is a prototype.
|
||||||
|
if (DF->isDeclaration())
|
||||||
|
DF->setVisibility(SF->getVisibility());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DF && DF->hasInternalLinkage())
|
|
||||||
DF = NULL;
|
|
||||||
|
|
||||||
if (DF && DF->getType() != SF->getType()) {
|
if (DF && DF->getType() != SF->getType()) {
|
||||||
if (DF->isDeclaration() && !SF->isDeclaration()) {
|
if (DF->isDeclaration() && !SF->isDeclaration()) {
|
||||||
// We have a definition of the same name but different type in the
|
// We have a definition of the same name but different type in the
|
||||||
@ -911,8 +914,6 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
|||||||
// Link the external functions, update linkage qualifiers
|
// Link the external functions, update linkage qualifiers
|
||||||
ValueMap.insert(std::make_pair(SF, DF));
|
ValueMap.insert(std::make_pair(SF, DF));
|
||||||
DF->setLinkage(SF->getLinkage());
|
DF->setLinkage(SF->getLinkage());
|
||||||
// Visibility of prototype is overridden by vis of definition.
|
|
||||||
DF->setVisibility(SF->getVisibility());
|
|
||||||
} else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage() ||
|
} else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage() ||
|
||||||
SF->hasCommonLinkage()) {
|
SF->hasCommonLinkage()) {
|
||||||
// At this point we know that DF has LinkOnce, Weak, or External* linkage.
|
// At this point we know that DF has LinkOnce, Weak, or External* linkage.
|
||||||
|
Loading…
Reference in New Issue
Block a user