Skip to content

Commit

Permalink
Remove getInternalLinkageFor
Browse files Browse the repository at this point in the history
Commit 1283e98 added getInternalLinkageFor for
ModuleInternalLinkage used by -fmodules-ts. Now that -fmodules-ts is removed, we
can simplify the call sites to use LinkageInfo::internal().
  • Loading branch information
MaskRay committed Jul 9, 2023
1 parent 9e362e5 commit cfbe86c
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,6 @@ static bool isDeclaredInModuleInterfaceOrPartition(const NamedDecl *D) {
return false;
}

static LinkageInfo getInternalLinkageFor(const NamedDecl *D) {
return LinkageInfo::internal();
}

static LinkageInfo getExternalLinkageFor(const NamedDecl *D) {
return LinkageInfo::external();
}
Expand Down Expand Up @@ -642,7 +638,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
// - a variable, variable template, function, or function template
// that is explicitly declared static; or
// (This bullet corresponds to C99 6.2.2p3.)
return getInternalLinkageFor(D);
return LinkageInfo::internal();
}

if (const auto *Var = dyn_cast<VarDecl>(D)) {
Expand All @@ -666,7 +662,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
if (Var->getStorageClass() != SC_Extern &&
Var->getStorageClass() != SC_PrivateExtern &&
!isSingleLineLanguageLinkage(*Var))
return getInternalLinkageFor(Var);
return LinkageInfo::internal();
}

for (const VarDecl *PrevVar = Var->getPreviousDecl(); PrevVar;
Expand All @@ -676,7 +672,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
return getDeclLinkageAndVisibility(PrevVar);
// Explicitly declared static.
if (PrevVar->getStorageClass() == SC_Static)
return getInternalLinkageFor(Var);
return LinkageInfo::internal();
}
} else if (const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
// - a data member of an anonymous union.
Expand All @@ -700,7 +696,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
// within an unnamed namespace has internal linkage.
if ((!Var || !isFirstInExternCContext(Var)) &&
(!Func || !isFirstInExternCContext(Func)))
return getInternalLinkageFor(D);
return LinkageInfo::internal();
}

// Set up the defaults.
Expand Down Expand Up @@ -1312,11 +1308,11 @@ LinkageInfo LinkageComputer::getLVForLocalDecl(const NamedDecl *D,
if (const auto *Function = dyn_cast<FunctionDecl>(D)) {
if (Function->isInAnonymousNamespace() &&
!isFirstInExternCContext(Function))
return getInternalLinkageFor(Function);
return LinkageInfo::internal();

// This is a "void f();" which got merged with a file static.
if (Function->getCanonicalDecl()->getStorageClass() == SC_Static)
return getInternalLinkageFor(Function);
return LinkageInfo::internal();

LinkageInfo LV;
if (!hasExplicitVisibilityAlready(computation)) {
Expand All @@ -1335,7 +1331,7 @@ LinkageInfo LinkageComputer::getLVForLocalDecl(const NamedDecl *D,
if (const auto *Var = dyn_cast<VarDecl>(D)) {
if (Var->hasExternalStorage()) {
if (Var->isInAnonymousNamespace() && !isFirstInExternCContext(Var))
return getInternalLinkageFor(Var);
return LinkageInfo::internal();

LinkageInfo LV;
if (Var->getStorageClass() == SC_PrivateExtern)
Expand Down Expand Up @@ -1415,7 +1411,7 @@ LinkageInfo LinkageComputer::computeLVForDecl(const NamedDecl *D,
bool IgnoreVarTypeLinkage) {
// Internal_linkage attribute overrides other considerations.
if (D->hasAttr<InternalLinkageAttr>())
return getInternalLinkageFor(D);
return LinkageInfo::internal();

// Objective-C: treat all Objective-C declarations as having external
// linkage.
Expand Down Expand Up @@ -1473,7 +1469,7 @@ LinkageInfo LinkageComputer::computeLVForDecl(const NamedDecl *D,
if (Record->hasKnownLambdaInternalLinkage() ||
!Record->getLambdaManglingNumber()) {
// This lambda has no mangling number, so it's internal.
return getInternalLinkageFor(D);
return LinkageInfo::internal();
}

return getLVForClosure(
Expand Down Expand Up @@ -1532,7 +1528,7 @@ LinkageInfo LinkageComputer::getLVForDecl(const NamedDecl *D,
LVComputationKind computation) {
// Internal_linkage attribute overrides other considerations.
if (D->hasAttr<InternalLinkageAttr>())
return getInternalLinkageFor(D);
return LinkageInfo::internal();

if (computation.IgnoreAllVisibility && D->hasCachedLinkage())
return LinkageInfo(D->getCachedLinkage(), DefaultVisibility, false);
Expand Down

0 comments on commit cfbe86c

Please sign in to comment.