Commit 464aaf0
committed
[Clang][WIP][RFC] Bypass TAD during overload resolution if a perfect match exists
This implements the same overload resolution behavior as GCC,
as described in https://wg21.link/p3606 (section 1-2, not 3)
If during overload resolution, there is a non-template candidate
that would be always be picked - because each of the argument
is a perfect match (ie the source and target types are the same),
we do not perform deduction for any template candidate
that might exists.
The goal is to be able to merge llvm#122423 without being too disruptive.
This change means that the selection of the best viable candidate and
template argument deduction become interleaved.
To avoid rewriting half of Clang we store in `OverloadCandidateSet`
enough information to be able to deduce template candidates from
`OverloadCandidateSet::BestViableFunction`. Which means
the lifetime of any object used by template argument must outlive
a call to `Add*Template*Candidate`.
This two phase resolution is not performed for some initialization
as there are cases where template candidate are better match
in these cases per the standard. It's also bypassed for code completion.
The change has a nice impact on compile times
https://llvm-compile-time-tracker.com/compare.php?from=719b029c16eeb1035da522fd641dfcc4cee6be74&to=bf7041045c9408490c395230047c5461de72fc39&stat=instructions%3Au
Fixes llvm#62096
Fixes llvm#745811 parent 719b029 commit 464aaf0
File tree
5 files changed
+395
-40
lines changed- clang
- include/clang/Sema
- lib/Sema
5 files changed
+395
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
743 | 744 | | |
744 | 745 | | |
745 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
746 | 753 | | |
747 | 754 | | |
748 | 755 | | |
| |||
979 | 986 | | |
980 | 987 | | |
981 | 988 | | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
982 | 1001 | | |
983 | 1002 | | |
984 | 1003 | | |
| |||
1015 | 1034 | | |
1016 | 1035 | | |
1017 | 1036 | | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
1018 | 1092 | | |
1019 | 1093 | | |
1020 | 1094 | | |
| |||
1043 | 1117 | | |
1044 | 1118 | | |
1045 | 1119 | | |
| 1120 | + | |
| 1121 | + | |
1046 | 1122 | | |
1047 | 1123 | | |
1048 | 1124 | | |
| |||
1116 | 1192 | | |
1117 | 1193 | | |
1118 | 1194 | | |
| 1195 | + | |
1119 | 1196 | | |
1120 | 1197 | | |
1121 | 1198 | | |
| |||
1126 | 1203 | | |
1127 | 1204 | | |
1128 | 1205 | | |
1129 | | - | |
| 1206 | + | |
1130 | 1207 | | |
1131 | 1208 | | |
1132 | 1209 | | |
| |||
1144 | 1221 | | |
1145 | 1222 | | |
1146 | 1223 | | |
1147 | | - | |
1148 | | - | |
| 1224 | + | |
| 1225 | + | |
1149 | 1226 | | |
1150 | 1227 | | |
1151 | 1228 | | |
| |||
1199 | 1276 | | |
1200 | 1277 | | |
1201 | 1278 | | |
1202 | | - | |
1203 | | - | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
1204 | 1285 | | |
1205 | 1286 | | |
1206 | 1287 | | |
| |||
1216 | 1297 | | |
1217 | 1298 | | |
1218 | 1299 | | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
1219 | 1313 | | |
1220 | 1314 | | |
1221 | 1315 | | |
| |||
1231 | 1325 | | |
1232 | 1326 | | |
1233 | 1327 | | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
1234 | 1350 | | |
1235 | 1351 | | |
1236 | 1352 | | |
1237 | 1353 | | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
1238 | 1358 | | |
1239 | 1359 | | |
1240 | 1360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
10342 | 10343 | | |
10343 | 10344 | | |
10344 | 10345 | | |
| 10346 | + | |
| 10347 | + | |
| 10348 | + | |
| 10349 | + | |
| 10350 | + | |
| 10351 | + | |
| 10352 | + | |
| 10353 | + | |
10345 | 10354 | | |
10346 | 10355 | | |
10347 | 10356 | | |
| 10357 | + | |
| 10358 | + | |
| 10359 | + | |
| 10360 | + | |
| 10361 | + | |
| 10362 | + | |
| 10363 | + | |
| 10364 | + | |
| 10365 | + | |
10348 | 10366 | | |
10349 | 10367 | | |
10350 | 10368 | | |
| |||
10389 | 10407 | | |
10390 | 10408 | | |
10391 | 10409 | | |
| 10410 | + | |
| 10411 | + | |
| 10412 | + | |
| 10413 | + | |
| 10414 | + | |
| 10415 | + | |
| 10416 | + | |
10392 | 10417 | | |
10393 | 10418 | | |
10394 | 10419 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6364 | 6364 | | |
6365 | 6365 | | |
6366 | 6366 | | |
6367 | | - | |
| 6367 | + | |
| 6368 | + | |
6368 | 6369 | | |
6369 | 6370 | | |
6370 | 6371 | | |
| |||
6567 | 6568 | | |
6568 | 6569 | | |
6569 | 6570 | | |
6570 | | - | |
| 6571 | + | |
| 6572 | + | |
6571 | 6573 | | |
6572 | 6574 | | |
6573 | 6575 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10043 | 10043 | | |
10044 | 10044 | | |
10045 | 10045 | | |
10046 | | - | |
10047 | | - | |
| 10046 | + | |
| 10047 | + | |
| 10048 | + | |
10048 | 10049 | | |
10049 | | - | |
| 10050 | + | |
10050 | 10051 | | |
10051 | | - | |
| 10052 | + | |
| 10053 | + | |
| 10054 | + | |
10052 | 10055 | | |
10053 | 10056 | | |
10054 | 10057 | | |
| |||
0 commit comments