Fix errors and warnings building swift/SIL on Windows using MSVC#5954
Fix errors and warnings building swift/SIL on Windows using MSVC#5954slavapestov merged 1 commit intoswiftlang:masterfrom hughbe:sil-msvc
Conversation
There was a problem hiding this comment.
This is as a result of an MSVC ABI bug
There was a problem hiding this comment.
... That has been fixed in VS 2017 :D
There was a problem hiding this comment.
There it is again, the horrible hack.
There was a problem hiding this comment.
This fixes the "cannot instantiate abstract class" error seen in #5948. The error happens for each alignof(TypeLowering) check. @jrose-apple FYI
2>C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): error C2259: 'swift::Lowering::TypeLowering': cannot instantiate abstract class
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: due to following members:
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'swift::SILValue swift::Lowering::TypeLowering::emitLoadOfCopy(swift::SILBuilder &,swift::SILLocation,swift::SILValue,swift::IsTake_t) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(194): note: see declaration of 'swift::Lowering::TypeLowering::emitLoadOfCopy'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'void swift::Lowering::TypeLowering::emitStoreOfCopy(swift::SILBuilder &,swift::SILLocation,swift::SILValue,swift::SILValue,swift::IsInitialization_t) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(207): note: see declaration of 'swift::Lowering::TypeLowering::emitStoreOfCopy'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'void swift::Lowering::TypeLowering::emitStore(swift::SILBuilder &,swift::SILLocation,swift::SILValue,swift::SILValue,swift::StoreOwnershipQualifier) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(218): note: see declaration of 'swift::Lowering::TypeLowering::emitStore'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'swift::SILValue swift::Lowering::TypeLowering::emitLoad(swift::SILBuilder &,swift::SILLocation,swift::SILValue,swift::LoadOwnershipQualifier) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(225): note: see declaration of 'swift::Lowering::TypeLowering::emitLoad'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'void swift::Lowering::TypeLowering::emitCopyInto(swift::SILBuilder &,swift::SILLocation,swift::SILValue,swift::SILValue,swift::IsTake_t,swift::IsInitialization_t) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(230): note: see declaration of 'swift::Lowering::TypeLowering::emitCopyInto'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'void swift::Lowering::TypeLowering::emitDestroyAddress(swift::SILBuilder &,swift::SILLocation,swift::SILValue) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(240): note: see declaration of 'swift::Lowering::TypeLowering::emitDestroyAddress'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'void swift::Lowering::TypeLowering::emitDestroyRValue(swift::SILBuilder &,swift::SILLocation,swift::SILValue) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(246): note: see declaration of 'swift::Lowering::TypeLowering::emitDestroyRValue'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'void swift::Lowering::TypeLowering::emitLoweredDestroyValue(swift::SILBuilder &,swift::SILLocation,swift::SILValue,swift::Lowering::TypeLowering::LoweringStyle) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(254): note: see declaration of 'swift::Lowering::TypeLowering::emitLoweredDestroyValue'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'void swift::Lowering::TypeLowering::emitDestroyValue(swift::SILBuilder &,swift::SILLocation,swift::SILValue) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(290): note: see declaration of 'swift::Lowering::TypeLowering::emitDestroyValue'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'swift::SILValue swift::Lowering::TypeLowering::emitLoweredCopyValue(swift::SILBuilder &,swift::SILLocation,swift::SILValue,swift::Lowering::TypeLowering::LoweringStyle) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(296): note: see declaration of 'swift::Lowering::TypeLowering::emitLoweredCopyValue'
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\lib\SIL\TypeLowering.cpp(1215): note: 'swift::SILValue swift::Lowering::TypeLowering::emitCopyValue(swift::SILBuilder &,swift::SILLocation,swift::SILValue) const': is abstract
2> C:\Users\Lukey\Documents\GitHub\my-swift\swift\include\swift/SIL/TypeLowering.h(324): note: see declaration of 'swift::Lowering::TypeLowering::emitCopyValue'
There was a problem hiding this comment.
As long as we have a complete type, it seems to be doing the right thing.
|
@jckarter PTAL if you have time and are not on holiday. I don't think I should add |
There was a problem hiding this comment.
Is the warning legitimate, or an MSVC bug? Can we slap an enable_if on a generic constructor somewhere to avoid formally having multiple copy ctors?
There was a problem hiding this comment.
I'm inclined to think this is an MSVC bug. I think it is related to
The line SILOpenedArchetypesTracker &operator = (const SILOpenedArchetypesTracker &) = delete; but have been unable to put a repo together.
I'm not surre I fully understand the enable_if comment you made, sorry
There was a problem hiding this comment.
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 const T & argument, thereby also potentially fulfilling the role of copy constructor.
|
@swift-ci Please smoke test |
|
@jckarter Does this LGTM? |
|
I need to add an |
| Operand>) const { | ||
| #else | ||
| typename TrailingBase::template OverloadToken<Operand>) const { | ||
| #endif |
There was a problem hiding this comment.
I think it would be better to consolidate the workaround in a single typedef somewhere, without the conditional.
// Equivalent to `typename TrailingBase::template OverloadToken<Operand>`.
// We have to fully elaborate the type because of an MSVC bug.
using OperandOverloadToken
= llvm::trailing_objects_internal::TrailingObjectsBase::OverloadToken<Operand>;
| // 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.
It might be nice to consolidate these into a compatibility macro in a swift/Basic header:
#if !defined(_MSC_VER) || defined(__clang__)
# define SWIFT_DELETE_OPERATOR_DELETE(...) \
void operator delete(__VA_ARGS__) = delete
#else
// Due to an MSVC bug, deleting an operator delete
// also causes the destructor to be deleted.
# define SWIFT_DELETE_OPERATOR_DELETE(...)
#endif
|
I think we should avoid conditionals where possible by consolidating the repeated cases into compatibility macros. Other than that, LGTM. |
|
Fine by me thanks for getting this in |
Various control path warnings
Various deleted function errors
Various sign warnings
Various function argument missing warnings
Relies on apple/swift-llvm#33 but PRs can be merged in any order