-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix errors and warnings building swift/SIL on Windows using MSVC #5954
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 |
---|---|---|
|
@@ -36,7 +36,11 @@ SILFunctionType::getSILArgumentConvention(unsigned index) const { | |
|
||
class SILArgument : public ValueBase { | ||
void operator=(const SILArgument &) = delete; | ||
|
||
// Work around MSVC error: attempting to reference a deleted function. | ||
#if !defined(_MSC_VER) || defined(__clang__) | ||
void operator delete(void *Ptr, size_t) = delete; | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be nice to consolidate these into a compatibility macro in a
|
||
|
||
SILBasicBlock *ParentBB; | ||
const ValueDecl *Decl; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,11 @@ class SILInstruction : public ValueBase,public llvm::ilist_node<SILInstruction>{ | |
|
||
SILInstruction() = delete; | ||
void operator=(const SILInstruction &) = delete; | ||
|
||
// Work around MSVC error: attempting to reference a deleted function. | ||
#if !defined(_MSC_VER) || defined(__clang__) | ||
void operator delete(void *Ptr, size_t) = delete; | ||
#endif | ||
|
||
/// Check any special state of instructions that are not represented in the | ||
/// instructions operands/type. | ||
|
@@ -459,8 +463,15 @@ class UnaryInstructionWithTypeDependentOperandsBase : | |
} | ||
} | ||
|
||
// 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< | ||
Operand>) const { | ||
#else | ||
typename TrailingBase::template OverloadToken<Operand>) const { | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better to consolidate the workaround in a single typedef somewhere, without the conditional.
|
||
return NumOperands; | ||
} | ||
|
||
|
@@ -2302,8 +2313,16 @@ class BindMemoryInst final : | |
SILType getBoundType() const { return BoundType ; } | ||
|
||
// Implement llvm::TrailingObjects. | ||
|
||
// 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__) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There it is again, the horrible hack. |
||
llvm::trailing_objects_internal::TrailingObjectsBase::OverloadToken< | ||
Operand>) const { | ||
#else | ||
typename TrailingBase::template OverloadToken<Operand>) const { | ||
#endif | ||
return NumOperands; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,12 @@ | |
|
||
namespace swift { | ||
|
||
// Disable MSVC warning: multiple copy constructors specified. | ||
#if defined(_MSC_VER) | ||
#pragma warning(push) | ||
#pragma warning(disable: 4521) | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the warning legitimate, or an MSVC bug? Can we slap an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm inclined to think this is an MSVC bug. I think it is related to I'm not surre I fully understand the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was referring to the not-uncommon situation where there's a formal copy constructor and a generic constructor that could also be called with a |
||
|
||
/// SILOpenedArchetypesTracker is a helper class that can be used to create | ||
/// and maintain a mapping from opened archetypes to instructions | ||
/// defining them, e.g. open_existential_ref, open_existential_addr, | ||
|
@@ -117,17 +123,21 @@ class SILOpenedArchetypesTracker : public DeleteNotificationHandler { | |
private: | ||
// Never copy | ||
SILOpenedArchetypesTracker &operator = (const SILOpenedArchetypesTracker &) = delete; | ||
|
||
/// The function whose opened archetypes are being tracked. | ||
/// Used only for verification purposes. | ||
const SILFunction &F; | ||
|
||
/// Mapping from opened archetypes to their definitions. | ||
OpenedArchetypeDefsMap &OpenedArchetypeDefs; | ||
/// Local map to be used if no other map was provided in the | ||
/// constructor. | ||
OpenedArchetypeDefsMap LocalOpenedArchetypeDefs; | ||
}; | ||
|
||
#if defined(_MSC_VER) | ||
#pragma warning(pop) | ||
#endif | ||
|
||
// A state object containing information about opened archetypes. | ||
// This information can be used by constructors of SILInstructions, | ||
// their create methods, etc. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -338,6 +338,8 @@ namespace { | |
case ExistentialRepresentation::Metatype: | ||
return asImpl().handleTrivial(type); | ||
} | ||
|
||
llvm_unreachable("Unhandled ExistentialRepresentation in switch."); | ||
} | ||
RetTy visitProtocolType(CanProtocolType type) { | ||
return visitExistentialType(type); | ||
|
@@ -1210,8 +1212,8 @@ TypeConverter::~TypeConverter() { | |
void *TypeLowering::operator new(size_t size, TypeConverter &tc, | ||
IsDependent_t dependent) { | ||
return dependent | ||
? tc.DependentBPA.Allocate(size, alignof(TypeLowering)) | ||
: tc.IndependentBPA.Allocate(size, alignof(TypeLowering)); | ||
? tc.DependentBPA.Allocate(size, alignof(TypeLowering&)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixes the "cannot instantiate abstract class" error seen in #5948. The error happens for each
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As long as we have a complete type, it seems to be doing the right thing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, good to know. |
||
: tc.IndependentBPA.Allocate(size, alignof(TypeLowering&)); | ||
} | ||
|
||
const TypeLowering *TypeConverter::find(TypeKey k) { | ||
|
@@ -1812,6 +1814,8 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c) { | |
return getIVarInitDestroyerInterfaceType(cast<ClassDecl>(vd), | ||
c.isForeign, Context, true); | ||
} | ||
|
||
llvm_unreachable("Unhandled SILDeclRefKind in switch."); | ||
} | ||
|
||
/// Get the generic environment for an entity. | ||
|
@@ -1858,6 +1862,8 @@ TypeConverter::getConstantGenericEnvironment(SILDeclRef c) { | |
// Use the generic environment of the containing type. | ||
return c.getDecl()->getDeclContext()->getGenericEnvironmentOfContext(); | ||
} | ||
|
||
llvm_unreachable("Unhandled SILDeclRefKind in switch."); | ||
} | ||
|
||
SILType TypeConverter::getSubstitutedStorageType(AbstractStorageDecl *value, | ||
|
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.
This is as a result of an MSVC ABI bug
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.
... That has been fixed in VS 2017 :D