From 8fa2c671f890ec3cd36c137ed8f6cfae1e676750 Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Sat, 12 Nov 2016 09:33:16 +0000 Subject: [PATCH] Add workaround for MSVC bug See https://github.com/apple/swift/pull/3759#event-734591467 The problem is that MSVC doesn't recognise the following syntax, reporting multiple errors [here](https://github.com/apple/swift/blob/master/include/swift/AST/Expr.h#L661): ``` size_t numTrailingObjects( typename TrailingObjects::template OverloadToken) const { return asDerived().hasArgumentLabelLocs() ? asDerived().getNumArguments() : 0; } ``` For some reason, MSVC ignores the fact that we gave friend access to `llvm::TrailingObjects` [here](). Note that the Swift source code also has to be modified, as this is not enough. This is the new source code, that fully compiles after this change! ``` // Work around MSVC bug: can't infer llvm::trailing_objects_internal, even though we granted friend access to it size_t numTrailingObjects( llvm::trailing_objects_internal::TrailingObjectsBase::OverloadToken) const { typename TrailingObjects::template OverloadToken) const { return asDerived().getNumArguments(); } ``` --- include/llvm/Support/TrailingObjects.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/llvm/Support/TrailingObjects.h b/include/llvm/Support/TrailingObjects.h index 4d355724149..051c65ad0d9 100644 --- a/include/llvm/Support/TrailingObjects.h +++ b/include/llvm/Support/TrailingObjects.h @@ -231,7 +231,14 @@ class TrailingObjectsImpl /// See the file comment for details on the usage of the /// TrailingObjects type. template + +// Work around MSVC build error: cannot access inaccessible struct declared +// in class'llvm::trailing_objects_internal::TrailingObjectsBase' +#if defined(_MSC_VER) +class TrailingObjects : protected trailing_objects_internal::TrailingObjectsImpl< +#else class TrailingObjects : private trailing_objects_internal::TrailingObjectsImpl< +#endif trailing_objects_internal::AlignmentCalcHelper< TrailingTys...>::Alignment, BaseTy, TrailingObjects,