Skip to content

Remove now unecessary MSVC trailing objects workaround #7890

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
Mar 6, 2017
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
15 changes: 12 additions & 3 deletions include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "swift/AST/TypeAlignments.h"
#include "swift/AST/TypeLoc.h"
#include "swift/AST/Availability.h"
#include "swift/Basic/Compiler.h"
#include "llvm/Support/TrailingObjects.h"

namespace llvm {
Expand Down Expand Up @@ -659,6 +658,14 @@ class alignas(8) Expr {
template<typename Derived>
class TrailingCallArguments
: private llvm::TrailingObjects<Derived, Identifier, SourceLoc> {
// We need to friend TrailingObjects twice here to work around an MSVC bug.
// If we have two functions of the same name with the parameter
// typename TrailingObjectsIdentifier::template OverloadToken<T> where T is
// different for each function, then MSVC reports a "member function already
// defined or declared" error, which is incorrect.
using TrailingObjectsIdentifier = llvm::TrailingObjects<Derived, Identifier>;
friend TrailingObjectsIdentifier;

using TrailingObjects = llvm::TrailingObjects<Derived, Identifier, SourceLoc>;
friend TrailingObjects;

Expand All @@ -671,12 +678,14 @@ class TrailingCallArguments
}

size_t numTrailingObjects(
SWIFT_TRAILING_OBJECTS_OVERLOAD_TOKEN(Identifier)) const {
typename TrailingObjectsIdentifier::template OverloadToken<Identifier>)
const {
return asDerived().getNumArguments();
}

size_t numTrailingObjects(
SWIFT_TRAILING_OBJECTS_OVERLOAD_TOKEN(SourceLoc)) const {
typename TrailingObjectsIdentifier::template OverloadToken<SourceLoc>)
const {
return asDerived().hasArgumentLabelLocs() ? asDerived().getNumArguments()
: 0;
}
Expand Down
9 changes: 0 additions & 9 deletions include/swift/Basic/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,8 @@
// https://connect.microsoft.com/VisualStudio/feedback/details/3116505
#define SWIFT_DELETE_OPERATOR_DELETED \
{ llvm_unreachable("Delete operator should not be called."); }

// Work around MSVC bug: can't infer llvm::trailing_objects_internal,
// even though we granted friend access to it.
// https://connect.microsoft.com/VisualStudio/feedback/details/3116517
#define SWIFT_TRAILING_OBJECTS_OVERLOAD_TOKEN(TokenType) \
llvm::trailing_objects_internal::TrailingObjectsBase::OverloadToken<TokenType>
#else
#define SWIFT_DELETE_OPERATOR_DELETED = delete;

#define SWIFT_TRAILING_OBJECTS_OVERLOAD_TOKEN(TokenType) \
typename TrailingObjects::template OverloadToken<TokenType>
#endif

#endif // SWIFT_BASIC_COMPILER_H
8 changes: 4 additions & 4 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ class UnaryInstructionWithTypeDependentOperandsBase :
}
}

size_t
numTrailingObjects(SWIFT_TRAILING_OBJECTS_OVERLOAD_TOKEN(Operand)) const {
size_t numTrailingObjects(
typename TrailingObjects::template OverloadToken<Operand>) const {
return NumOperands;
}

Expand Down Expand Up @@ -2300,8 +2300,8 @@ class BindMemoryInst final :
SILType getBoundType() const { return BoundType ; }

// Implement llvm::TrailingObjects.
size_t
numTrailingObjects(SWIFT_TRAILING_OBJECTS_OVERLOAD_TOKEN(Operand)) const {
size_t numTrailingObjects(
typename TrailingObjects::template OverloadToken<Operand>) const {
return NumOperands;
}

Expand Down