Skip to content

Commit 0009cdb

Browse files
urnathantstellar
authored andcommitted
[clang][NFC] Remove IgnoreLinkageSpecDecls
The Itanium mangler uses IgnoreLinkageSpecDecls to strip linkage spec contexts. It doesn't do this consistently, but there is no need for it to do it at all. getEffectiveDeclContext never returns a linkage spec, as it either recurses, uses getRedeclContext (which itself removes the specs), or gets the decl context of non-namespace entities. This patch removes the function and all calls to it. For safety I add a couple of asserts to make sure we never get them. Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D119748
1 parent 53eaee6 commit 0009cdb

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -862,18 +862,9 @@ void CXXNameMangler::mangleFunctionEncodingBareType(const FunctionDecl *FD) {
862862
MangleReturnType, FD);
863863
}
864864

865-
static const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC) {
866-
while (isa<LinkageSpecDecl>(DC)) {
867-
DC = getEffectiveParentContext(DC);
868-
}
869-
870-
return DC;
871-
}
872-
873865
/// Return whether a given namespace is the 'std' namespace.
874866
static bool isStd(const NamespaceDecl *NS) {
875-
if (!IgnoreLinkageSpecDecls(getEffectiveParentContext(NS))
876-
->isTranslationUnit())
867+
if (!getEffectiveParentContext(NS)->isTranslationUnit())
877868
return false;
878869

879870
const IdentifierInfo *II = NS->getOriginalNamespace()->getIdentifier();
@@ -978,7 +969,7 @@ void CXXNameMangler::mangleNameWithAbiTags(GlobalDecl GD,
978969
return;
979970
}
980971

981-
DC = IgnoreLinkageSpecDecls(DC);
972+
assert(!isa<LinkageSpecDecl>(DC) && "context cannot be LinkageSpecDecl");
982973

983974
if (isLocalContainerContext(DC)) {
984975
mangleLocalName(GD, AdditionalAbiTags);
@@ -1054,7 +1045,7 @@ void CXXNameMangler::mangleModuleNamePrefix(StringRef Name) {
10541045
void CXXNameMangler::mangleTemplateName(const TemplateDecl *TD,
10551046
const TemplateArgument *TemplateArgs,
10561047
unsigned NumTemplateArgs) {
1057-
const DeclContext *DC = IgnoreLinkageSpecDecls(getEffectiveDeclContext(TD));
1048+
const DeclContext *DC = getEffectiveDeclContext(TD);
10581049

10591050
if (DC->isTranslationUnit() || isStdNamespace(DC)) {
10601051
mangleUnscopedTemplateName(TD, nullptr);
@@ -1070,7 +1061,7 @@ void CXXNameMangler::mangleUnscopedName(GlobalDecl GD,
10701061
// <unscoped-name> ::= <unqualified-name>
10711062
// ::= St <unqualified-name> # ::std::
10721063

1073-
if (isStdNamespace(IgnoreLinkageSpecDecls(getEffectiveDeclContext(ND))))
1064+
if (isStdNamespace(getEffectiveDeclContext(ND)))
10741065
Out << "St";
10751066

10761067
mangleUnqualifiedName(GD, AdditionalAbiTags);
@@ -2030,7 +2021,7 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) {
20302021
// ::= # empty
20312022
// ::= <substitution>
20322023

2033-
DC = IgnoreLinkageSpecDecls(DC);
2024+
assert(!isa<LinkageSpecDecl>(DC) && "prefix cannot be LinkageSpecDecl");
20342025

20352026
if (DC->isTranslationUnit())
20362027
return;

0 commit comments

Comments
 (0)