Skip to content

Fix errors and warnings build swift/clangImporter using MSVC on Windows #5950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ClangImporter/ClangAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ OptionalTypeKind importer::translateNullability(clang::NullabilityKind kind) {
case clang::NullabilityKind::Unspecified:
return OptionalTypeKind::OTK_ImplicitlyUnwrappedOptional;
}

llvm_unreachable("Invalid NullabilityKind.");
}

bool importer::hasDesignatedInitializers(
Expand Down
2 changes: 2 additions & 0 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2739,6 +2739,8 @@ namespace {
return nullptr;
}
}

llvm_unreachable("Invalid EnumKind.");
}


Expand Down
2 changes: 2 additions & 0 deletions lib/ClangImporter/ImportEnumInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ void EnumInfo::determineConstantNamePrefix(ASTContext &ctx,
case clang::AR_Unavailable:
return false;
}

llvm_unreachable("Invalid AvailabilityAttr.");
};

// Move to the first non-deprecated enumerator, or non-swift_name'd
Expand Down
6 changes: 3 additions & 3 deletions lib/ClangImporter/ImportName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
// Objective-C categories and extensions don't have names, despite
// being "named" declarations.
if (isa<clang::ObjCCategoryDecl>(D))
return {};
return ImportedName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this change, but is it really necessary? This seems like a pretty common C++11 feature that will keep slipping in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm sorry: MSVC reports errors for each construct, no idea why!


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

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

// If this swift_name attribute maps a factory method to an
Expand Down
2 changes: 2 additions & 0 deletions lib/ClangImporter/ImportName.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ struct ImportedName {
case ImportedAccessorKind::SubscriptSetter:
return true;
}

llvm_unreachable("Invalid ImportedAccessorKind.");
}
};

Expand Down
14 changes: 14 additions & 0 deletions lib/ClangImporter/ImportType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ namespace {
case ImportHint::SwiftNewtypeFromCFPointer:
return true;
}

llvm_unreachable("Invalid ImportHint.");
}

struct ImportResult {
Expand Down Expand Up @@ -173,6 +175,8 @@ namespace {
return OptionalType::get(payloadType);
return ImplicitlyUnwrappedOptionalType::get(payloadType);
}

llvm_unreachable("Invalid OptionalTypeKind.");
}

class SwiftTypeConverter :
Expand Down Expand Up @@ -296,6 +300,8 @@ namespace {
case clang::BuiltinType::OMPArraySection:
return Type();
}

llvm_unreachable("Invalid BuiltinType.");
}

ImportResult VisitComplexType(const clang::ComplexType *type) {
Expand Down Expand Up @@ -783,6 +789,8 @@ namespace {
return getAdjustedTypeDeclReferenceType(decl);
}
}

llvm_unreachable("Invalid EnumKind.");
}

ImportResult VisitObjCObjectType(const clang::ObjCObjectType *type) {
Expand Down Expand Up @@ -1051,6 +1059,8 @@ static bool canBridgeTypes(ImportTypeKind importKind) {
case ImportTypeKind::BridgedValue:
return true;
}

llvm_unreachable("Invalid ImportTypeKind.");
}

/// True if the type has known CoreFoundation reference counting semantics.
Expand All @@ -1075,6 +1085,8 @@ static bool isCFAudited(ImportTypeKind importKind) {
case ImportTypeKind::PropertyWithReferenceSemantics:
return true;
}

llvm_unreachable("Invalid ImportTypeKind.");
}

/// Turn T into Unmanaged<T>.
Expand Down Expand Up @@ -1744,6 +1756,8 @@ adjustResultTypeForThrowingFunction(const ImportedErrorInfo &errorInfo,
case ForeignErrorConvention::NonNilError:
return resultTy;
}

llvm_unreachable("Invalid ForeignErrorConvention.");
}

/// Produce the foreign error convention from the imported error info,
Expand Down
4 changes: 4 additions & 0 deletions lib/ClangImporter/SwiftLookupTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ bool SwiftLookupTable::contextRequiresName(ContextKind kind) {
case ContextKind::TranslationUnit:
return false;
}

llvm_unreachable("Invalid ContextKind.");
}

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

return None;
}

llvm_unreachable("Invalid EffectiveClangContext.");
}

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