Skip to content

Commit 8e85e1e

Browse files
committed
[NFC] Eliminate applyParamAttributes()
1 parent a281feb commit 8e85e1e

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,15 +1998,6 @@ ImportTypeAttrs swift::getImportTypeAttrs(const clang::Decl *D, bool isParam,
19981998
return attrs;
19991999
}
20002000

2001-
Type ClangImporter::Implementation::applyParamAttributes(
2002-
const clang::ParmVarDecl *param, Type type, bool sendableByDefault) {
2003-
auto parentDecl = cast<clang::Decl>(param->getDeclContext());
2004-
ImportDiagnosticAdder addDiag(*this, parentDecl, param->getLocation());
2005-
2006-
auto attrs = getImportTypeAttrs(param, /*isParam=*/true, sendableByDefault);
2007-
return applyImportTypeAttrs(attrs, type, addDiag);
2008-
}
2009-
20102001
Type ClangImporter::Implementation::
20112002
applyImportTypeAttrs(ImportTypeAttrs attrs, Type type,
20122003
llvm::function_ref<void(Diagnostic &&)> addDiag) {
@@ -2221,6 +2212,7 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
22212212
importKind = ImportTypeKind::CFUnretainedOutParameter;
22222213

22232214
// Import the parameter type into Swift.
2215+
ImportDiagnosticAdder paramAddDiag(*this, clangDecl, param->getLocation());
22242216
Type swiftParamTy;
22252217
bool isParamTypeImplicitlyUnwrapped = false;
22262218
bool isInOut = false;
@@ -2254,9 +2246,7 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
22542246
if (!paramTy.isConstQualified())
22552247
isInOut = true;
22562248
}
2257-
auto importedType = importType(paramTy, importKind,
2258-
ImportDiagnosticAdder(*this, clangDecl,
2259-
param->getLocation()),
2249+
auto importedType = importType(paramTy, importKind, paramAddDiag,
22602250
allowNSUIntegerAsInt, Bridgeability::Full,
22612251
OptionalityOfParam);
22622252
if (!importedType) {
@@ -2271,8 +2261,8 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
22712261
}
22722262

22732263
// Apply attributes to the type.
2274-
swiftParamTy = applyParamAttributes(
2275-
param, swiftParamTy, /*sendableByDefault=*/false);
2264+
auto attrs = getImportTypeAttrs(param, /*isParam=*/true);
2265+
swiftParamTy = applyImportTypeAttrs(attrs, swiftParamTy, paramAddDiag);
22762266

22772267
// Figure out the name for this parameter.
22782268
Identifier bodyName = importFullName(param, CurrentVersion)
@@ -2878,8 +2868,9 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
28782868
}
28792869

28802870
// Apply Clang attributes to the parameter type.
2881-
swiftParamTy = applyParamAttributes(param, swiftParamTy,
2882-
/*sendableByDefault=*/paramIsCompletionHandler);
2871+
auto attrs = getImportTypeAttrs(param, /*isParam=*/true,
2872+
/*sendableByDefault=*/paramIsCompletionHandler);
2873+
swiftParamTy = applyImportTypeAttrs(attrs, swiftParamTy, paramAddDiag);
28832874

28842875
// Figure out the name for this parameter.
28852876
Identifier bodyName = importFullName(param, CurrentVersion)

lib/ClangImporter/ImporterImpl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -995,9 +995,6 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
995995
void importAttributes(const clang::NamedDecl *ClangDecl, Decl *MappedDecl,
996996
const clang::ObjCContainerDecl *NewContext = nullptr);
997997

998-
Type applyParamAttributes(const clang::ParmVarDecl *param, Type type,
999-
bool sendableByDefault);
1000-
1001998
Type applyImportTypeAttrs(ImportTypeAttrs attrs, Type type,
1002999
llvm::function_ref<void(Diagnostic &&)> addImportDiagnosticFn);
10031000

0 commit comments

Comments
 (0)