Skip to content

Commit a5092f8

Browse files
authored
Merge pull request #77922 from kubamracek/embedded-mangling2
[ASTMangler] Drop the legacy ASTManger constructor, always require ASTContext&
2 parents 22741db + b68b7d1 commit a5092f8

File tree

2 files changed

+1
-62
lines changed

2 files changed

+1
-62
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ enum class DestructorKind {
4545
/// The mangler for AST declarations.
4646
class ASTMangler : public Mangler {
4747
protected:
48-
#if 0 // STAGING
4948
const ASTContext &Context;
50-
#endif
5149
ModuleDecl *Mod = nullptr;
5250

5351
/// Optimize out protocol names if a type only conforms to one protocol.
@@ -189,19 +187,6 @@ class ASTMangler : public Mangler {
189187
HasSymbolQuery,
190188
};
191189

192-
// STAGING: legacy constructor for LLDB
193-
/// lldb overrides the defaulted argument to 'true'.
194-
ASTMangler(bool DWARFMangling = false) {
195-
if (DWARFMangling) {
196-
DWARFMangling = true;
197-
RespectOriginallyDefinedIn = false;
198-
}
199-
}
200-
201-
/// lldb overrides the defaulted argument to 'true'.
202-
ASTMangler(const ASTContext &Ctx, bool DWARFMangling = false) : ASTMangler(DWARFMangling) {}
203-
204-
#if 0
205190
/// lldb overrides the defaulted argument to 'true'.
206191
ASTMangler(const ASTContext &Ctx, bool DWARFMangling = false) : Context(Ctx) {
207192
if (DWARFMangling) {
@@ -214,7 +199,6 @@ class ASTMangler : public Mangler {
214199
}
215200

216201
const ASTContext &getASTContext() { return Context; }
217-
#endif
218202

219203
void addTypeSubstitution(Type type, GenericSignature sig) {
220204
type = dropProtocolsFromAssociatedTypes(type, sig);

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,7 @@ static NodePointer mangleSILDifferentiabilityWitnessAsNode(
600600
Node::Kind::IndexSubset, config.resultIndices->getString()),
601601
demangler);
602602
if (auto genSig = config.derivativeGenericSignature) {
603-
#if 0 // STAGING
604603
ASTMangler genSigMangler(mangler->getASTContext());
605-
#else
606-
ASTMangler genSigMangler;
607-
#endif
608604
auto genSigSymbol = genSigMangler.mangleGenericSignature(genSig);
609605
auto demangledGenSig = demangler.demangleSymbol(genSigSymbol);
610606
assert(demangledGenSig);
@@ -717,13 +713,8 @@ static Type getTypeForDWARFMangling(Type t) {
717713
}
718714

719715
std::string ASTMangler::mangleTypeForDebugger(Type Ty, GenericSignature sig) {
720-
#if 0 // STAGING
721716
PrettyStackTraceType prettyStackTrace(Context, "mangling type for debugger",
722717
Ty);
723-
#else
724-
PrettyStackTraceType prettyStackTrace(Ty->getASTContext(), "mangling type for debugger",
725-
Ty);
726-
#endif
727718

728719
DWARFMangling = true;
729720
RespectOriginallyDefinedIn = false;
@@ -1332,11 +1323,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
13321323
// unless the type alias references a builtin type.
13331324
auto underlyingType = aliasTy->getSinglyDesugaredType();
13341325
TypeAliasDecl *decl = aliasTy->getDecl();
1335-
#if 0 // STAGING
13361326
if (decl->getModuleContext() == Context.TheBuiltinModule) {
1337-
#else
1338-
if (decl->getModuleContext() == decl->getASTContext().TheBuiltinModule) {
1339-
#endif
13401327
return appendType(underlyingType, sig, forDecl);
13411328
}
13421329

@@ -2137,13 +2124,8 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
21372124
OpArgs.push_back('t');
21382125
}
21392126

2140-
#if 0 // STAGING
21412127
bool mangleClangType =
21422128
Context.LangOpts.UseClangFunctionTypes && fn->hasNonDerivableClangType();
2143-
#else
2144-
bool mangleClangType = fn->getASTContext().LangOpts.UseClangFunctionTypes &&
2145-
fn->hasNonDerivableClangType();
2146-
#endif
21472129

21482130
auto appendClangTypeToVec = [this, fn](auto &Vec) {
21492131
llvm::raw_svector_ostream OpArgsOS(Vec);
@@ -3053,13 +3035,8 @@ void ASTMangler::appendFunctionType(AnyFunctionType *fn, GenericSignature sig,
30533035

30543036
appendFunctionSignature(fn, sig, forDecl, NoFunctionMangling, isRecursedInto);
30553037

3056-
#if 0 // STAGING
30573038
bool mangleClangType =
30583039
Context.LangOpts.UseClangFunctionTypes && fn->hasNonDerivableClangType();
3059-
#else
3060-
bool mangleClangType = fn->getASTContext().LangOpts.UseClangFunctionTypes &&
3061-
fn->hasNonDerivableClangType();
3062-
#endif
30633040

30643041
// Note that we do not currently use thin representations in the AST
30653042
// for the types of function decls. This may need to change at some
@@ -3109,13 +3086,8 @@ void ASTMangler::appendClangType(FnType *fn, llvm::raw_svector_ostream &out) {
31093086
auto clangType = fn->getClangTypeInfo().getType();
31103087
SmallString<64> scratch;
31113088
llvm::raw_svector_ostream scratchOS(scratch);
3112-
#if 0 // STAGING
31133089
clang::ASTContext &clangCtx =
31143090
Context.getClangModuleLoader()->getClangASTContext();
3115-
#else
3116-
clang::ASTContext &clangCtx =
3117-
fn->getASTContext().getClangModuleLoader()->getClangASTContext();
3118-
#endif
31193091
std::unique_ptr<clang::ItaniumMangleContext> mangler{
31203092
clang::ItaniumMangleContext::create(clangCtx, clangCtx.getDiagnostics())};
31213093
mangler->mangleCanonicalTypeName(clang::QualType(clangType, 0), scratchOS);
@@ -3141,11 +3113,7 @@ void ASTMangler::appendFunctionSignature(AnyFunctionType *fn,
31413113
if (fn->isSendable())
31423114
appendOperator("Yb");
31433115
if (auto thrownError = fn->getEffectiveThrownErrorType()) {
3144-
#if 0 // STAGING
31453116
if ((*thrownError)->isEqual(Context.getErrorExistentialType())
3146-
#else
3147-
if ((*thrownError)->isEqual(fn->getASTContext().getErrorExistentialType())
3148-
#endif
31493117
|| !AllowTypedThrows) {
31503118
appendOperator("K");
31513119
} else {
@@ -3844,11 +3812,7 @@ void ASTMangler::appendClosureEntity(const AbstractClosureExpr *closure) {
38443812
// code; the type-checker currently isn't strict about producing typed
38453813
// expression nodes when it fails. Once we enforce that, we can remove this.
38463814
if (!type)
3847-
#if 0 // STAGING
38483815
type = CanType(ErrorType::get(Context));
3849-
#else
3850-
type = CanType(ErrorType::get(closure->getASTContext()));
3851-
#endif
38523816

38533817
auto canType = type->getCanonicalType();
38543818
if (canType->hasLocalArchetype())
@@ -3919,11 +3883,7 @@ CanType ASTMangler::getDeclTypeForMangling(
39193883
genericSig = GenericSignature();
39203884
parentGenericSig = GenericSignature();
39213885

3922-
#if 0 // STAGING
39233886
auto &C = Context;
3924-
#else
3925-
auto &C = decl->getASTContext();
3926-
#endif
39273887

39283888
auto ty = decl->getInterfaceType()->getReferenceStorageReferent();
39293889
if (ty->hasError()) {
@@ -4565,12 +4525,7 @@ void ASTMangler::appendMacroExpansionContext(
45654525
if (loc.isInvalid())
45664526
return appendContext(origDC, nullBase, StringRef());
45674527

4568-
#if 0 // STAGING
45694528
SourceManager &sourceMgr = Context.SourceMgr;
4570-
#else
4571-
ASTContext &ctx = origDC->getASTContext();
4572-
SourceManager &sourceMgr = ctx.SourceMgr;
4573-
#endif
45744529

45754530
auto appendMacroExpansionLoc = [&]() {
45764531
appendIdentifier(origDC->getParentModule()->getName().str());
@@ -4648,7 +4603,7 @@ void ASTMangler::appendMacroExpansionContext(
46484603
if (auto *macroDecl = decl->getResolvedMacro(attr))
46494604
baseName = macroDecl->getBaseName();
46504605
else
4651-
baseName = ctx.getIdentifier("__unknown_macro__");
4606+
baseName = Context.getIdentifier("__unknown_macro__");
46524607

46534608
discriminator = decl->getAttachedMacroDiscriminator(baseName, role, attr);
46544609
break;

0 commit comments

Comments
 (0)