diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2020-09-16 16:58:29 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2020-09-16 16:58:29 +0000 |
| commit | 16d6b3b3da62aa5baaf3c66c8d4e6f8c8f70aeb7 (patch) | |
| tree | 6031356a30dab2c3c69c332095eb59f34b4e0961 /contrib/llvm-project/clang/lib/StaticAnalyzer/Core | |
| parent | ceff9b9d2587c46759fd6fb312916d5748986918 (diff) | |
| parent | e588341d487d7ec86b5282968e3223f8c0e6de27 (diff) | |
Notes
Diffstat (limited to 'contrib/llvm-project/clang/lib/StaticAnalyzer/Core')
| -rw-r--r-- | contrib/llvm-project/clang/lib/StaticAnalyzer/Core/DynamicType.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/contrib/llvm-project/clang/lib/StaticAnalyzer/Core/DynamicType.cpp b/contrib/llvm-project/clang/lib/StaticAnalyzer/Core/DynamicType.cpp index e9b64fd79614..9ed915aafcab 100644 --- a/contrib/llvm-project/clang/lib/StaticAnalyzer/Core/DynamicType.cpp +++ b/contrib/llvm-project/clang/lib/StaticAnalyzer/Core/DynamicType.cpp @@ -65,6 +65,13 @@ const DynamicTypeInfo *getRawDynamicTypeInfo(ProgramStateRef State, return State->get<DynamicTypeMap>(MR); } +static void unbox(QualType &Ty) { + // FIXME: Why are we being fed references to pointers in the first place? + while (Ty->isReferenceType() || Ty->isPointerType()) + Ty = Ty->getPointeeType(); + Ty = Ty.getCanonicalType().getUnqualifiedType(); +} + const DynamicCastInfo *getDynamicCastInfo(ProgramStateRef State, const MemRegion *MR, QualType CastFromTy, @@ -73,6 +80,9 @@ const DynamicCastInfo *getDynamicCastInfo(ProgramStateRef State, if (!Lookup) return nullptr; + unbox(CastFromTy); + unbox(CastToTy); + for (const DynamicCastInfo &Cast : *Lookup) if (Cast.equals(CastFromTy, CastToTy)) return &Cast; @@ -112,6 +122,9 @@ ProgramStateRef setDynamicTypeAndCastInfo(ProgramStateRef State, State = State->set<DynamicTypeMap>(MR, CastToTy); } + unbox(CastFromTy); + unbox(CastToTy); + DynamicCastInfo::CastResult ResultKind = CastSucceeds ? DynamicCastInfo::CastResult::Success : DynamicCastInfo::CastResult::Failure; |
