Commit 01710aa
authored
[clang] Fix cast for injected types in case name lookup for dependent bases (llvm#119024)
An assertion failure occurs in Clang when attempting to compile such an
example:
```c++
template <typename, typename, bool> struct MozPromise {
class Private;
private:
int mMagic4 = 42;
};
template <typename ResolveValueT, typename RejectValueT, bool IsExclusive>
struct MozPromise<ResolveValueT, RejectValueT, IsExclusive>::Private : MozPromise {
void SetTaskPriority() { mMagic4 ; }
};
```
Output:
```
clang: llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From&) [with To = clang::RecordType; From = clang::QualType]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
```
The reason is in the incorrect way of casting types when searching for
names in base classes
```c++
return Specifier->getType()->castAs<RecordType>()->getDecl()->getCanonicalDecl() == BaseRecord;
```
It loses injected types for template class names.
This patch provides fix for such cases1 parent 98b694b commit 01710aa
2 files changed
+15
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
372 | | - | |
| 371 | + | |
| 372 | + | |
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
382 | | - | |
| 381 | + | |
| 382 | + | |
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
| |||
692 | 692 | | |
693 | 693 | | |
694 | 694 | | |
695 | | - | |
| 695 | + | |
696 | 696 | | |
697 | 697 | | |
698 | 698 | | |
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
717 | | - | |
| 717 | + | |
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1209 | 1209 | | |
1210 | 1210 | | |
1211 | 1211 | | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
1212 | 1217 | | |
1213 | 1218 | | |
1214 | 1219 | | |
| |||
1224 | 1229 | | |
1225 | 1230 | | |
1226 | 1231 | | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
1227 | 1236 | | |
1228 | 1237 | | |
1229 | 1238 | | |
| |||
0 commit comments