Skip to content

Commit adb3698

Browse files
committed
[Mangling] Also use the new ASTMangler::Context member in ASTMangler.cpp instead of getASTContext() calls
1 parent 1f3acc7 commit adb3698

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,8 @@ static Type getTypeForDWARFMangling(Type t) {
713713
}
714714

715715
std::string ASTMangler::mangleTypeForDebugger(Type Ty, GenericSignature sig) {
716-
PrettyStackTraceType prettyStackTrace(Ty->getASTContext(),
717-
"mangling type for debugger", Ty);
716+
PrettyStackTraceType prettyStackTrace(Context, "mangling type for debugger",
717+
Ty);
718718

719719
DWARFMangling = true;
720720
RespectOriginallyDefinedIn = false;
@@ -1322,7 +1322,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
13221322
// unless the type alias references a builtin type.
13231323
auto underlyingType = aliasTy->getSinglyDesugaredType();
13241324
TypeAliasDecl *decl = aliasTy->getDecl();
1325-
if (decl->getModuleContext() == decl->getASTContext().TheBuiltinModule) {
1325+
if (decl->getModuleContext() == Context.TheBuiltinModule) {
13261326
return appendType(underlyingType, sig, forDecl);
13271327
}
13281328

@@ -2123,8 +2123,8 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
21232123
OpArgs.push_back('t');
21242124
}
21252125

2126-
bool mangleClangType = fn->getASTContext().LangOpts.UseClangFunctionTypes &&
2127-
fn->hasNonDerivableClangType();
2126+
bool mangleClangType =
2127+
Context.LangOpts.UseClangFunctionTypes && fn->hasNonDerivableClangType();
21282128

21292129
auto appendClangTypeToVec = [this, fn](auto &Vec) {
21302130
llvm::raw_svector_ostream OpArgsOS(Vec);
@@ -3034,8 +3034,8 @@ void ASTMangler::appendFunctionType(AnyFunctionType *fn, GenericSignature sig,
30343034

30353035
appendFunctionSignature(fn, sig, forDecl, NoFunctionMangling, isRecursedInto);
30363036

3037-
bool mangleClangType = fn->getASTContext().LangOpts.UseClangFunctionTypes &&
3038-
fn->hasNonDerivableClangType();
3037+
bool mangleClangType =
3038+
Context.LangOpts.UseClangFunctionTypes && fn->hasNonDerivableClangType();
30393039

30403040
// Note that we do not currently use thin representations in the AST
30413041
// for the types of function decls. This may need to change at some
@@ -3086,7 +3086,7 @@ void ASTMangler::appendClangType(FnType *fn, llvm::raw_svector_ostream &out) {
30863086
SmallString<64> scratch;
30873087
llvm::raw_svector_ostream scratchOS(scratch);
30883088
clang::ASTContext &clangCtx =
3089-
fn->getASTContext().getClangModuleLoader()->getClangASTContext();
3089+
Context.getClangModuleLoader()->getClangASTContext();
30903090
std::unique_ptr<clang::ItaniumMangleContext> mangler{
30913091
clang::ItaniumMangleContext::create(clangCtx, clangCtx.getDiagnostics())};
30923092
mangler->mangleCanonicalTypeName(clang::QualType(clangType, 0), scratchOS);
@@ -3112,7 +3112,7 @@ void ASTMangler::appendFunctionSignature(AnyFunctionType *fn,
31123112
if (fn->isSendable())
31133113
appendOperator("Yb");
31143114
if (auto thrownError = fn->getEffectiveThrownErrorType()) {
3115-
if ((*thrownError)->isEqual(fn->getASTContext().getErrorExistentialType())
3115+
if ((*thrownError)->isEqual(Context.getErrorExistentialType())
31163116
|| !AllowTypedThrows) {
31173117
appendOperator("K");
31183118
} else {
@@ -3811,7 +3811,7 @@ void ASTMangler::appendClosureEntity(const AbstractClosureExpr *closure) {
38113811
// code; the type-checker currently isn't strict about producing typed
38123812
// expression nodes when it fails. Once we enforce that, we can remove this.
38133813
if (!type)
3814-
type = CanType(ErrorType::get(closure->getASTContext()));
3814+
type = CanType(ErrorType::get(Context));
38153815

38163816
auto canType = type->getCanonicalType();
38173817
if (canType->hasLocalArchetype())
@@ -3882,18 +3882,16 @@ CanType ASTMangler::getDeclTypeForMangling(
38823882
genericSig = GenericSignature();
38833883
parentGenericSig = GenericSignature();
38843884

3885-
auto &C = decl->getASTContext();
3886-
38873885
auto ty = decl->getInterfaceType()->getReferenceStorageReferent();
38883886
if (ty->hasError()) {
38893887
if (isa<AbstractFunctionDecl>(decl) || isa<EnumElementDecl>(decl) ||
38903888
isa<SubscriptDecl>(decl)) {
38913889
// FIXME: Verify ExtInfo state is correct, not working by accident.
38923890
CanFunctionType::ExtInfo info;
3893-
return CanFunctionType::get({AnyFunctionType::Param(C.TheErrorType)},
3894-
C.TheErrorType, info);
3891+
return CanFunctionType::get({AnyFunctionType::Param(Context.TheErrorType)},
3892+
Context.TheErrorType, info);
38953893
}
3896-
return C.TheErrorType;
3894+
return Context.TheErrorType;
38973895
}
38983896

38993897
// If this declaration predates concurrency, adjust its type to not
@@ -4503,8 +4501,7 @@ void ASTMangler::appendMacroExpansionContext(
45034501
if (loc.isInvalid())
45044502
return appendContext(origDC, nullBase, StringRef());
45054503

4506-
ASTContext &ctx = origDC->getASTContext();
4507-
SourceManager &sourceMgr = ctx.SourceMgr;
4504+
SourceManager &sourceMgr = Context.SourceMgr;
45084505

45094506
auto appendMacroExpansionLoc = [&]() {
45104507
appendIdentifier(origDC->getParentModule()->getName().str());
@@ -4582,7 +4579,7 @@ void ASTMangler::appendMacroExpansionContext(
45824579
if (auto *macroDecl = decl->getResolvedMacro(attr))
45834580
baseName = macroDecl->getBaseName();
45844581
else
4585-
baseName = ctx.getIdentifier("__unknown_macro__");
4582+
baseName = Context.getIdentifier("__unknown_macro__");
45864583

45874584
discriminator = decl->getAttachedMacroDiscriminator(baseName, role, attr);
45884585
break;

0 commit comments

Comments
 (0)