Skip to content

Commit 071ec47

Browse files
hughbejrose-apple
authored andcommitted
Fix errors and warnings build swift/clangImporter using MSVC on Windows (#5950)
1 parent 6c4273f commit 071ec47

File tree

7 files changed

+29
-3
lines changed

7 files changed

+29
-3
lines changed

lib/ClangImporter/ClangAdapter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ OptionalTypeKind importer::translateNullability(clang::NullabilityKind kind) {
563563
case clang::NullabilityKind::Unspecified:
564564
return OptionalTypeKind::OTK_ImplicitlyUnwrappedOptional;
565565
}
566+
567+
llvm_unreachable("Invalid NullabilityKind.");
566568
}
567569

568570
bool importer::hasDesignatedInitializers(

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,8 @@ namespace {
27252725
return nullptr;
27262726
}
27272727
}
2728+
2729+
llvm_unreachable("Invalid EnumKind.");
27282730
}
27292731

27302732

lib/ClangImporter/ImportEnumInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ void EnumInfo::determineConstantNamePrefix(ASTContext &ctx,
222222
case clang::AR_Unavailable:
223223
return false;
224224
}
225+
226+
llvm_unreachable("Invalid AvailabilityAttr.");
225227
};
226228

227229
// Move to the first non-deprecated enumerator, or non-swift_name'd

lib/ClangImporter/ImportName.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
10941094
// Objective-C categories and extensions don't have names, despite
10951095
// being "named" declarations.
10961096
if (isa<clang::ObjCCategoryDecl>(D))
1097-
return {};
1097+
return ImportedName();
10981098

10991099
// Dig out the definition, if there is one.
11001100
if (auto def = getDefinitionForClangTypeDecl(D)) {
@@ -1106,7 +1106,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
11061106
auto dc = const_cast<clang::DeclContext *>(D->getDeclContext());
11071107
auto effectiveCtx = determineEffectiveContext(D, dc, options);
11081108
if (!effectiveCtx)
1109-
return {};
1109+
return ImportedName();
11101110
result.EffectiveContext = effectiveCtx;
11111111

11121112
// FIXME: ugly to check here, instead perform unified check up front in
@@ -1192,7 +1192,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
11921192
if (!shouldImportAsInitializer(method, initPrefixLength,
11931193
result.InitKind)) {
11941194
// We cannot import this as an initializer anyway.
1195-
return {};
1195+
return ImportedName();
11961196
}
11971197

11981198
// If this swift_name attribute maps a factory method to an

lib/ClangImporter/ImportName.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ struct ImportedName {
130130
case ImportedAccessorKind::SubscriptSetter:
131131
return true;
132132
}
133+
134+
llvm_unreachable("Invalid ImportedAccessorKind.");
133135
}
134136
};
135137

lib/ClangImporter/ImportType.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ namespace {
140140
case ImportHint::SwiftNewtypeFromCFPointer:
141141
return true;
142142
}
143+
144+
llvm_unreachable("Invalid ImportHint.");
143145
}
144146

145147
struct ImportResult {
@@ -173,6 +175,8 @@ namespace {
173175
return OptionalType::get(payloadType);
174176
return ImplicitlyUnwrappedOptionalType::get(payloadType);
175177
}
178+
179+
llvm_unreachable("Invalid OptionalTypeKind.");
176180
}
177181

178182
class SwiftTypeConverter :
@@ -296,6 +300,8 @@ namespace {
296300
case clang::BuiltinType::OMPArraySection:
297301
return Type();
298302
}
303+
304+
llvm_unreachable("Invalid BuiltinType.");
299305
}
300306

301307
ImportResult VisitComplexType(const clang::ComplexType *type) {
@@ -783,6 +789,8 @@ namespace {
783789
return getAdjustedTypeDeclReferenceType(decl);
784790
}
785791
}
792+
793+
llvm_unreachable("Invalid EnumKind.");
786794
}
787795

788796
ImportResult VisitObjCObjectType(const clang::ObjCObjectType *type) {
@@ -1051,6 +1059,8 @@ static bool canBridgeTypes(ImportTypeKind importKind) {
10511059
case ImportTypeKind::BridgedValue:
10521060
return true;
10531061
}
1062+
1063+
llvm_unreachable("Invalid ImportTypeKind.");
10541064
}
10551065

10561066
/// True if the type has known CoreFoundation reference counting semantics.
@@ -1075,6 +1085,8 @@ static bool isCFAudited(ImportTypeKind importKind) {
10751085
case ImportTypeKind::PropertyWithReferenceSemantics:
10761086
return true;
10771087
}
1088+
1089+
llvm_unreachable("Invalid ImportTypeKind.");
10781090
}
10791091

10801092
/// Turn T into Unmanaged<T>.
@@ -1744,6 +1756,8 @@ adjustResultTypeForThrowingFunction(const ImportedErrorInfo &errorInfo,
17441756
case ForeignErrorConvention::NonNilError:
17451757
return resultTy;
17461758
}
1759+
1760+
llvm_unreachable("Invalid ForeignErrorConvention.");
17471761
}
17481762

17491763
/// Produce the foreign error convention from the imported error info,

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ bool SwiftLookupTable::contextRequiresName(ContextKind kind) {
214214
case ContextKind::TranslationUnit:
215215
return false;
216216
}
217+
218+
llvm_unreachable("Invalid ContextKind.");
217219
}
218220

219221
/// Try to translate the given Clang declaration into a context.
@@ -293,6 +295,8 @@ SwiftLookupTable::translateContext(EffectiveClangContext context) {
293295

294296
return None;
295297
}
298+
299+
llvm_unreachable("Invalid EffectiveClangContext.");
296300
}
297301

298302
/// Lookup an unresolved context name and resolve it to a Clang

0 commit comments

Comments
 (0)