Skip to content

Commit 62b9375

Browse files
committed
[Reflection] Remove DEPENDENT_TEMPLATE2 macro
The Clang version checks introduced in #16212 and #16221 do not work well. The __clang_major__ macro is defined differently for Apple builds of Clang, and the __APPLE_CC__ macro is obsolete and not useful. The good news is that those checks appear to be unnecessary. The version of Clang used with Swift 4.2 (based on LLVM 6.0) accepts the code without the template keyword in the places where the DEPENDENT_TEMPLATE2 macro was being used. This also corrects a mistake in #16221 where the non-Clang/GCC definition of DEPENDENT_TEMPLATE was changed to use the template keyword.
1 parent 06c24dd commit 62b9375

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

include/swift/Reflection/TypeRef.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,20 @@ enum class TypeRefKind {
4040

4141
// MSVC reports an error if we use "template"
4242
// Clang reports an error if we don't use "template"
43-
#if defined(__APPLE_CC__)
43+
#if defined(__clang__) || defined(__GNUC__)
4444
# define DEPENDENT_TEMPLATE template
45-
# if __APPLE_CC__ >= 7000
46-
# define DEPENDENT_TEMPLATE2
47-
# else
48-
# define DEPENDENT_TEMPLATE2 template
49-
# endif
50-
#elif defined(__clang__) || defined(__GNUC__)
51-
# define DEPENDENT_TEMPLATE template
52-
# if __clang_major__ >= 7
53-
# define DEPENDENT_TEMPLATE2
54-
# else
55-
# define DEPENDENT_TEMPLATE2 template
56-
# endif
5745
#else
58-
# define DEPENDENT_TEMPLATE template
59-
# define DEPENDENT_TEMPLATE2
46+
# define DEPENDENT_TEMPLATE
6047
#endif
6148

6249
#define FIND_OR_CREATE_TYPEREF(Allocator, TypeRefTy, ...) \
6350
auto ID = Profile(__VA_ARGS__); \
64-
const auto Entry = Allocator.DEPENDENT_TEMPLATE2 TypeRefTy##s.find(ID); \
65-
if (Entry != Allocator.DEPENDENT_TEMPLATE2 TypeRefTy##s.end()) \
51+
const auto Entry = Allocator.TypeRefTy##s.find(ID); \
52+
if (Entry != Allocator.TypeRefTy##s.end()) \
6653
return Entry->second; \
6754
const auto TR = \
6855
Allocator.DEPENDENT_TEMPLATE makeTypeRef<TypeRefTy>(__VA_ARGS__); \
69-
Allocator.DEPENDENT_TEMPLATE2 TypeRefTy##s.insert({ID, TR}); \
56+
Allocator.TypeRefTy##s.insert({ID, TR}); \
7057
return TR;
7158

7259
/// An identifier containing the unique bit pattern made up of all of the

0 commit comments

Comments
 (0)