@@ -2241,6 +2241,34 @@ getImportTypeKindForParam(const clang::ParmVarDecl *param) {
2241
2241
return importKind;
2242
2242
}
2243
2243
2244
+ static ParamDecl *getParameterInfo (ClangImporter::Implementation *impl,
2245
+ const clang::ParmVarDecl *param,
2246
+ const Identifier &name,
2247
+ const swift::Type &swiftParamTy,
2248
+ const bool isInOut,
2249
+ const bool isParamTypeImplicitlyUnwrapped) {
2250
+ // Figure out the name for this parameter.
2251
+ Identifier bodyName = impl->importFullName (param, impl->CurrentVersion )
2252
+ .getDeclName ()
2253
+ .getBaseIdentifier ();
2254
+
2255
+ // It doesn't actually matter which DeclContext we use, so just use the
2256
+ // imported header unit.
2257
+ auto paramInfo = impl->createDeclWithClangNode <ParamDecl>(
2258
+ param, AccessLevel::Private, SourceLoc (), SourceLoc (), name,
2259
+ impl->importSourceLoc (param->getLocation ()), bodyName,
2260
+ impl->ImportedHeaderUnit );
2261
+ // Foreign references are already references so they don't need to be passed
2262
+ // as inout.
2263
+ paramInfo->setSpecifier (isInOut && !swiftParamTy->isForeignReferenceType ()
2264
+ ? ParamSpecifier::InOut
2265
+ : ParamSpecifier::Default);
2266
+ paramInfo->setInterfaceType (swiftParamTy);
2267
+ impl->recordImplicitUnwrapForDecl (paramInfo, isParamTypeImplicitlyUnwrapped);
2268
+
2269
+ return paramInfo;
2270
+ }
2271
+
2244
2272
ParameterList *ClangImporter::Implementation::importFunctionParameterList (
2245
2273
DeclContext *dc, const clang::FunctionDecl *clangDecl,
2246
2274
ArrayRef<const clang::ParmVarDecl *> params, bool isVariadic,
@@ -2344,29 +2372,13 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
2344
2372
swiftParamTy = importedType.getType ();
2345
2373
}
2346
2374
2347
- // Figure out the name for this parameter.
2348
- Identifier bodyName = importFullName (param, CurrentVersion)
2349
- .getDeclName ()
2350
- .getBaseIdentifier ();
2351
-
2352
2375
// Retrieve the argument name.
2353
2376
Identifier name;
2354
2377
if (index < argNames.size ())
2355
2378
name = argNames[index];
2356
2379
2357
- // It doesn't actually matter which DeclContext we use, so just use the
2358
- // imported header unit.
2359
- auto paramInfo = createDeclWithClangNode<ParamDecl>(
2360
- param, AccessLevel::Private, SourceLoc (), SourceLoc (), name,
2361
- importSourceLoc (param->getLocation ()), bodyName,
2362
- ImportedHeaderUnit);
2363
- // Foreign references are already references so they don't need to be passed
2364
- // as inout.
2365
- paramInfo->setSpecifier (isInOut && !swiftParamTy->isForeignReferenceType ()
2366
- ? ParamSpecifier::InOut
2367
- : ParamSpecifier::Default);
2368
- paramInfo->setInterfaceType (swiftParamTy);
2369
- recordImplicitUnwrapForDecl (paramInfo, isParamTypeImplicitlyUnwrapped);
2380
+ auto paramInfo = getParameterInfo (this , param, name, swiftParamTy, isInOut,
2381
+ isParamTypeImplicitlyUnwrapped);
2370
2382
parameters.push_back (paramInfo);
2371
2383
++index;
2372
2384
}
@@ -3013,28 +3025,16 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
3013
3025
llvm_unreachable (" async info computed incorrectly?" );
3014
3026
}
3015
3027
3016
- // Figure out the name for this parameter.
3017
- Identifier bodyName = importFullName (param, CurrentVersion)
3018
- .getDeclName ()
3019
- .getBaseIdentifier ();
3020
-
3021
3028
// Figure out the name for this argument, which comes from the method name.
3022
3029
Identifier name;
3023
3030
if (nameIndex < argNames.size ()) {
3024
3031
name = argNames[nameIndex];
3025
3032
}
3026
3033
++nameIndex;
3027
3034
3028
- // Set up the parameter info.
3029
- auto paramInfo
3030
- = createDeclWithClangNode<ParamDecl>(param, AccessLevel::Private,
3031
- SourceLoc (), SourceLoc (), name,
3032
- importSourceLoc (param->getLocation ()),
3033
- bodyName,
3034
- ImportedHeaderUnit);
3035
- paramInfo->setSpecifier (ParamSpecifier::Default);
3036
- paramInfo->setInterfaceType (swiftParamTy);
3037
- recordImplicitUnwrapForDecl (paramInfo, paramIsIUO);
3035
+ // Set up the parameter info
3036
+ auto paramInfo = getParameterInfo (this , param, name, swiftParamTy,
3037
+ /* isInOut=*/ false , paramIsIUO);
3038
3038
3039
3039
// Determine whether we have a default argument.
3040
3040
if (kind == SpecialMethodKind::Regular ||
0 commit comments