Skip to content

Commit 191b0d8

Browse files
Revert "[AST] Add functionality for computing Clang types for SIL functions."
This reverts commit bfa2f98.
1 parent 29cc1b6 commit 191b0d8

File tree

4 files changed

+6
-92
lines changed

4 files changed

+6
-92
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,6 @@ class ASTContext final {
582582
Type getBridgedToObjC(const DeclContext *dc, Type type,
583583
Type *bridgedValueType = nullptr) const;
584584

585-
private:
586-
void initializeClangTypeConverter();
587-
588-
public:
589585
/// Get the Clang type corresponding to a Swift function type.
590586
///
591587
/// \param params The function parameters.
@@ -599,15 +595,6 @@ class ASTContext final {
599595
const FunctionType::ExtInfo incompleteExtInfo,
600596
FunctionTypeRepresentation trueRep);
601597

602-
/// Get the canonical Clang type corresponding to a SIL function type.
603-
///
604-
/// SIL analog of \c ASTContext::getClangFunctionType .
605-
const clang::Type *
606-
getCanonicalClangFunctionType(
607-
ArrayRef<SILParameterInfo> params, Optional<SILResultInfo> result,
608-
const SILFunctionType::ExtInfo incompleteExtInfo,
609-
SILFunctionType::Representation trueRep);
610-
611598
/// Determine whether the given Swift type is representable in a
612599
/// given foreign language.
613600
ForeignRepresentationInfo

lib/AST/ASTContext.cpp

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,35 +4372,17 @@ Type ASTContext::getBridgedToObjC(const DeclContext *dc, Type type,
43724372
return Type();
43734373
}
43744374

4375-
void
4376-
ASTContext::initializeClangTypeConverter() {
4377-
auto &impl = getImpl();
4378-
if (!impl.Converter) {
4379-
auto *cml = getClangModuleLoader();
4380-
impl.Converter.emplace(*this, cml->getClangASTContext(), LangOpts.Target);
4381-
}
4382-
}
4383-
43844375
const clang::Type *
43854376
ASTContext::getClangFunctionType(ArrayRef<AnyFunctionType::Param> params,
43864377
Type resultTy,
43874378
FunctionType::ExtInfo incompleteExtInfo,
43884379
FunctionTypeRepresentation trueRep) {
4389-
initializeClangTypeConverter();
4390-
return getImpl().Converter.getValue().getFunctionType(params, resultTy,
4391-
trueRep);
4392-
}
4393-
4394-
const clang::Type *
4395-
ASTContext::getCanonicalClangFunctionType(
4396-
ArrayRef<SILParameterInfo> params,
4397-
Optional<SILResultInfo> result,
4398-
SILFunctionType::ExtInfo incompleteExtInfo,
4399-
SILFunctionType::Representation trueRep) {
4400-
initializeClangTypeConverter();
4401-
auto *ty = getImpl().Converter.getValue().getFunctionType(params, result,
4402-
trueRep);
4403-
return ty ? ty->getCanonicalTypeInternal().getTypePtr() : nullptr;
4380+
auto &impl = getImpl();
4381+
if (!impl.Converter) {
4382+
auto *cml = getClangModuleLoader();
4383+
impl.Converter.emplace(*this, cml->getClangASTContext(), LangOpts.Target);
4384+
}
4385+
return impl.Converter.getValue().getFunctionType(params, resultTy, trueRep);
44044386
}
44054387

44064388
CanGenericSignature ASTContext::getSingleGenericParameterSignature() const {

lib/AST/ClangTypeConverter.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -156,57 +156,6 @@ const clang::Type *ClangTypeConverter::getFunctionType(
156156
}
157157
}
158158

159-
const clang::Type *ClangTypeConverter::getFunctionType(
160-
ArrayRef<SILParameterInfo> params, Optional<SILResultInfo> result,
161-
SILFunctionType::Representation repr) {
162-
163-
// Using the interface type is sufficient as Swift does not allow abstracting
164-
// over @convention(c) functions, hence we don't need any substitutions.
165-
auto resultClangTy = result.hasValue()
166-
? convert(result.getValue().getInterfaceType())
167-
: ClangASTContext.VoidTy;
168-
169-
if (resultClangTy.isNull())
170-
return nullptr;
171-
172-
SmallVector<clang::FunctionProtoType::ExtParameterInfo, 4> extParamInfos;
173-
SmallVector<clang::QualType, 4> paramsClangTy;
174-
bool someParamIsConsumed = false;
175-
for (auto &p : params) {
176-
auto pc = convert(p.getInterfaceType());
177-
if (pc.isNull())
178-
return nullptr;
179-
clang::FunctionProtoType::ExtParameterInfo extParamInfo;
180-
if (p.isConsumed()) {
181-
someParamIsConsumed = true;
182-
extParamInfo = extParamInfo.withIsConsumed(true);
183-
}
184-
extParamInfos.push_back(extParamInfo);
185-
paramsClangTy.push_back(pc);
186-
}
187-
188-
clang::FunctionProtoType::ExtProtoInfo info(clang::CallingConv::CC_C);
189-
if (someParamIsConsumed)
190-
info.ExtParameterInfos = extParamInfos.begin();
191-
auto fn = ClangASTContext.getFunctionType(resultClangTy, paramsClangTy, info);
192-
if (fn.isNull())
193-
return nullptr;
194-
195-
switch (repr) {
196-
case SILFunctionType::Representation::CFunctionPointer:
197-
return ClangASTContext.getPointerType(fn).getTypePtr();
198-
case SILFunctionType::Representation::Block:
199-
return ClangASTContext.getBlockPointerType(fn).getTypePtr();
200-
case SILFunctionType::Representation::Thick:
201-
case SILFunctionType::Representation::Thin:
202-
case SILFunctionType::Representation::Method:
203-
case SILFunctionType::Representation::ObjCMethod:
204-
case SILFunctionType::Representation::WitnessMethod:
205-
case SILFunctionType::Representation::Closure:
206-
llvm_unreachable("Expected a C-compatible representation.");
207-
}
208-
}
209-
210159
clang::QualType ClangTypeConverter::convertMemberType(NominalTypeDecl *DC,
211160
StringRef memberName) {
212161
auto memberTypeDecl = cast<TypeDecl>(

lib/AST/ClangTypeConverter.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ class ClangTypeConverter :
7373
ArrayRef<AnyFunctionType::Param> params, Type resultTy,
7474
AnyFunctionType::Representation repr);
7575

76-
const clang::Type *getFunctionType(
77-
ArrayRef<SILParameterInfo> params, Optional<SILResultInfo> result,
78-
SILFunctionType::Representation repr);
79-
8076
private:
8177
clang::QualType convert(Type type);
8278
clang::QualType convertMemberType(NominalTypeDecl *DC,

0 commit comments

Comments
 (0)