Skip to content

Commit a1748cb

Browse files
authored
[vs2017] Adapt some variadic template aliases to not trip MSVC 2017. (#37284)
It seems that MSVC 2017 trips parsing an using of a using of a variadic template. Removing one level of using seems to work fine. A preprocessor macro allows to keep using the same syntax in both MSVC 2017 and other compilers without making a lot of a mess. I think this might have been uncovered by landing swiftlang/llvm-project#2898 when it was picked up by the auto-merger for the swift/main branch. I think this was not a problem until now, because Metadata.h was compiled using the just compiled Clang until now. LLDB is compiled using MSVC in Windows.
1 parent 4486aac commit a1748cb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

include/swift/ABI/Metadata.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,8 +2906,13 @@ class TargetGenericEnvironment
29062906
uint16_t, GenericParamDescriptor, GenericRequirementDescriptor>;
29072907
friend TrailingObjects;
29082908

2909+
#if !defined(_MSC_VER) || _MSC_VER >= 1920
29092910
template<typename T>
29102911
using OverloadToken = typename TrailingObjects::template OverloadToken<T>;
2912+
#else
2913+
// MSVC 2017 trips parsing an using of an using, of a variadic template
2914+
#define OverloadToken typename TrailingObjects::template OverloadToken
2915+
#endif
29112916

29122917
size_t numTrailingObjects(OverloadToken<uint16_t>) const {
29132918
return Flags.getNumGenericParameterLevels();
@@ -2921,6 +2926,10 @@ class TargetGenericEnvironment
29212926
return Flags.getNumGenericRequirements();
29222927
}
29232928

2929+
#if defined(_MSC_VER) && _MSC_VER < 1920
2930+
#undef OverloadToken
2931+
#endif
2932+
29242933
GenericEnvironmentFlags Flags;
29252934

29262935
public:
@@ -2982,8 +2991,13 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
29822991
FollowingTrailingObjects...>;
29832992
friend TrailingObjects;
29842993

2994+
#if !defined(_MSC_VER) || _MSC_VER >= 1920
29852995
template<typename T>
29862996
using OverloadToken = typename TrailingObjects::template OverloadToken<T>;
2997+
#else
2998+
// MSVC 2017 trips parsing an using of an using, of a variadic template
2999+
#define OverloadToken typename TrailingObjects::template OverloadToken
3000+
#endif
29873001

29883002
const Self *asSelf() const {
29893003
return static_cast<const Self *>(this);
@@ -3047,6 +3061,11 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
30473061
size_t numTrailingObjects(OverloadToken<GenericRequirementDescriptor>) const {
30483062
return asSelf()->isGeneric() ? getGenericContextHeader().NumRequirements : 0;
30493063
}
3064+
3065+
#if defined(_MSC_VER) && _MSC_VER < 1920
3066+
#undef OverloadToken
3067+
#endif
3068+
30503069
};
30513070

30523071
/// Reference to a generic context.

0 commit comments

Comments
 (0)