-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Support building swift/AST with MSVC on Windows #5948
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -863,7 +863,11 @@ class alignas(1 << DeclAlignInBits) Decl { | |
|
|
||
| // Make vanilla new/delete illegal for Decls. | ||
| void *operator new(size_t Bytes) = delete; | ||
|
|
||
| // Work around MSVC error: attempting to reference a deleted function. | ||
|
||
| #if !defined(_MSC_VER) || defined(__clang__) | ||
| void operator delete(void *Data) = delete; | ||
| #endif | ||
|
|
||
| // Only allow allocation of Decls using the allocator in ASTContext | ||
| // or by doing a placement new. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -662,13 +662,27 @@ class TrailingCallArguments | |
| return *static_cast<const Derived *>(this); | ||
| } | ||
|
|
||
| // Work around MSVC bug: can't infer llvm::trailing_objects_internal, | ||
| // even though we granted friend access to it. | ||
| size_t numTrailingObjects( | ||
| #if defined(_MSC_VER) && !defined(__clang__) | ||
| llvm::trailing_objects_internal::TrailingObjectsBase::OverloadToken< | ||
|
||
| Identifier>) const { | ||
| #else | ||
| typename TrailingObjects::template OverloadToken<Identifier>) const { | ||
| #endif | ||
| return asDerived().getNumArguments(); | ||
| } | ||
|
|
||
| // Work around MSVC bug: can't infer llvm::trailing_objects_internal, | ||
| // even though we granted friend access to it. | ||
| size_t numTrailingObjects( | ||
| #if defined(_MSC_VER) && !defined(__clang__) | ||
| llvm::trailing_objects_internal::TrailingObjectsBase::OverloadToken< | ||
| SourceLoc>) const { | ||
| #else | ||
| typename TrailingObjects::template OverloadToken<SourceLoc>) const { | ||
| #endif | ||
| return asDerived().hasArgumentLabelLocs() | ||
| ? asDerived().getNumArguments() | ||
| : 0; | ||
|
|
@@ -4447,6 +4461,8 @@ class ObjCSelectorExpr : public Expr { | |
| case ObjCSelectorKind::Setter: | ||
| return true; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled ObjcSelectorKind in switch."); | ||
| } | ||
|
|
||
| /// Whether this selector references a method. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1381,7 +1381,7 @@ class ParameterTypeFlags { | |
| NumBits = 3 | ||
| }; | ||
| OptionSet<ParameterFlags> value; | ||
| static_assert(NumBits < 8*sizeof(value), "overflowed"); | ||
| static_assert(NumBits < 8*sizeof(OptionSet<ParameterFlags>), "overflowed"); | ||
|
||
|
|
||
| ParameterTypeFlags(OptionSet<ParameterFlags, uint8_t> val) : value(val) {} | ||
|
|
||
|
|
@@ -2255,6 +2255,8 @@ inline bool canBeCalledIndirectly(SILFunctionTypeRepresentation rep) { | |
| case SILFunctionTypeRepresentation::WitnessMethod: | ||
| return true; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled SILFunctionTypeRepresentation in switch."); | ||
| } | ||
|
|
||
| /// Map a SIL function representation to the base language calling convention | ||
|
|
@@ -2273,6 +2275,8 @@ getSILFunctionLanguage(SILFunctionTypeRepresentation rep) { | |
| case SILFunctionTypeRepresentation::Closure: | ||
| return SILFunctionLanguage::Swift; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled SILFunctionTypeRepresentation in switch."); | ||
| } | ||
|
|
||
| /// AnyFunctionType - A function type has a single input and result, but | ||
|
|
@@ -2357,6 +2361,8 @@ class AnyFunctionType : public TypeBase { | |
| case SILFunctionTypeRepresentation::WitnessMethod: | ||
| return true; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled SILFunctionTypeRepresentation in switch."); | ||
| } | ||
|
|
||
| /// True if the function representation carries context. | ||
|
|
@@ -2373,6 +2379,8 @@ class AnyFunctionType : public TypeBase { | |
| case SILFunctionTypeRepresentation::Closure: | ||
| return false; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled SILFunctionTypeRepresentation in switch."); | ||
| } | ||
|
|
||
| // Note that we don't have setters. That is by design, use | ||
|
|
@@ -3043,6 +3051,8 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode, | |
| case Representation::WitnessMethod: | ||
| return true; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled Representation in switch."); | ||
| } | ||
|
|
||
| bool hasGuaranteedSelfParam() const { | ||
|
|
@@ -3058,6 +3068,8 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode, | |
| case Representation::WitnessMethod: | ||
| return true; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled Representation in switch."); | ||
| } | ||
|
|
||
| /// True if the function representation carries context. | ||
|
|
@@ -3074,6 +3086,8 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode, | |
| case Representation::Closure: | ||
| return false; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled Representation in switch."); | ||
| } | ||
|
|
||
| // Note that we don't have setters. That is by design, use | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -275,8 +275,16 @@ struct ASTContext::Implementation { | |
| ~Arena() { | ||
| for (auto &conformance : SpecializedConformances) | ||
| conformance.~SpecializedProtocolConformance(); | ||
| // Work around MSVC warning: local variable is initialized but | ||
| // not referenced. | ||
| #if defined(_MSC_VER) | ||
| #pragma warning (disable: 4189) | ||
|
||
| #endif | ||
| for (auto &conformance : InheritedConformances) | ||
| conformance.~InheritedProtocolConformance(); | ||
| #if defined(_MSC_VER) | ||
| #pragma warning (default: 4189) | ||
| #endif | ||
|
|
||
| // Call the normal conformance destructors last since they could be | ||
| // referenced by the other conformance types. | ||
|
|
@@ -536,6 +544,8 @@ EnumDecl *ASTContext::getOptionalDecl(OptionalTypeKind kind) const { | |
| case OTK_Optional: | ||
| return getOptionalDecl(); | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled OptionalTypeKind in switch."); | ||
| } | ||
|
|
||
| static EnumElementDecl *findEnumElement(EnumDecl *e, Identifier name) { | ||
|
|
@@ -1714,6 +1724,8 @@ std::pair<unsigned, DeclName> swift::getObjCMethodDiagInfo( | |
| // Normal method. | ||
| return { 4, func->getFullName() }; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled AccessorKind in switch."); | ||
| } | ||
|
|
||
| bool swift::fixDeclarationName(InFlightDiagnostic &diag, ValueDecl *decl, | ||
|
|
@@ -3760,6 +3772,8 @@ ASTContext::getForeignRepresentationInfo(NominalTypeDecl *nominal, | |
| case ForeignLanguage::ObjectiveC: | ||
| return entry; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled ForeignLanguage in switch."); | ||
| } | ||
|
|
||
| bool ASTContext::isTypeBridgedInExternalModule( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,11 +36,11 @@ | |
| #include "llvm/Support/CommandLine.h" | ||
|
|
||
| using namespace swift; | ||
| using namespace NewMangling; | ||
| using namespace swift::NewMangling; | ||
|
|
||
| std::string NewMangling::mangleTypeForDebugger(Type Ty, const DeclContext *DC) { | ||
| if (useNewMangling()) { | ||
| ASTMangler::ASTMangler NewMangler(/* DWARF */ true); | ||
| ASTMangler NewMangler(/* DWARF */ true); | ||
|
||
| return NewMangler.mangleTypeForDebugger(Ty, DC); | ||
| } | ||
| Mangle::Mangler OldMangler(/* DWARF */ true); | ||
|
|
@@ -50,7 +50,7 @@ std::string NewMangling::mangleTypeForDebugger(Type Ty, const DeclContext *DC) { | |
|
|
||
| std::string NewMangling::mangleTypeAsUSR(Type Ty) { | ||
| if (useNewMangling()) { | ||
| ASTMangler::ASTMangler NewMangler; | ||
| ASTMangler NewMangler; | ||
| return NewMangler.mangleTypeAsUSR(Ty); | ||
| } | ||
| Mangle::Mangler OldMangler; | ||
|
|
@@ -369,7 +369,7 @@ void ASTMangler::appendDeclName(const ValueDecl *decl) { | |
| assert(!discriminator.empty()); | ||
| assert(!isNonAscii(discriminator.str()) && | ||
| "discriminator contains non-ASCII characters"); | ||
| (void)isNonAscii; | ||
| (void)&isNonAscii; | ||
| assert(!clang::isDigit(discriminator.str().front()) && | ||
| "not a valid identifier"); | ||
|
|
||
|
|
@@ -387,6 +387,8 @@ static const char *getMetatypeRepresentationOp(MetatypeRepresentation Rep) { | |
| case MetatypeRepresentation::ObjC: | ||
| return "o"; | ||
| } | ||
|
|
||
| llvm_unreachable("Unhandled MetatypeRepresentation in switch."); | ||
| } | ||
|
|
||
| static bool isStdlibType(const NominalTypeDecl *decl) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://connect.microsoft.com/VisualStudio/feedback/details/3116508/msvc-shouldnt-show-errors-using-deprecated-methods-from-deprecated-methods