[all-commits] [llvm/llvm-project] 01710a: [clang] Fix cast for injected types in case name l...

Vladislav Belov via All-commits all-commits at lists.llvm.org
Mon Dec 9 01:28:49 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 01710aa345f2fb26e2312dd1c62bd0044fc75bed
      https://github.com/llvm/llvm-project/commit/01710aa345f2fb26e2312dd1c62bd0044fc75bed
  Author: Vladislav Belov <vladislav.belov at syntacore.com>
  Date:   2024-12-09 (Mon, 09 Dec 2024)

  Changed paths:
    M clang/lib/AST/CXXInheritance.cpp
    M clang/test/CXX/drs/cwg5xx.cpp

  Log Message:
  -----------
  [clang] Fix cast for injected types in case name lookup for dependent bases (#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 cases



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list