[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)
Christian Holler via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 13 06:58:53 PST 2023
choller wrote:
I looked into Tom's bug report and I hit the following assertion in a debug build:
```
clang: /srv/repos/llvm-project/clang/lib/StaticAnalyzer/Core/DynamicType.cpp:134: clang::ento::ProgramStateRef clang::ento::setDynamicTypeAndCastInfo(clang::ento::ProgramStateRef, const clang::ento::MemRegion*, clang::QualType, clang::QualType, bool): Assertion `(CastToTy->isAnyPointerType() || CastToTy->isReferenceType()) && "DynamicTypeInfo should always be a pointer."' failed.
```
I was also able to greatly reduce the CPP testfile:
```
class c {};
class e : public c {};
class g {
c &d();
e &i() { return static_cast<e &>(d()); }
};
```
If I output the `QualType` information in `fromTy` and `toTy` right before the assertion, I get this:
```
From:
ElaboratedType 0x55be9d7264b0 'c' sugar
`-RecordType 0x55be9d726260 'class c'
`-CXXRecord 0x55be9d7261d0 'c'
To:
ElaboratedType 0x55be9d726940 'e' sugar
`-RecordType 0x55be9d726420 'class e'
`-CXXRecord 0x55be9d726390 'e'
```
What I don't understand is why these are not reference types. @steakhal do you know more here?
https://github.com/llvm/llvm-project/pull/69057
More information about the cfe-commits
mailing list