[PATCH] D67079: [analyzer] CastValueChecker: Model inheritance
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 13:43:13 PDT 2019
NoQ added inline comments.
================
Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h:24
+ DynamicTypeInfo(QualType ty, bool CanBeSub = true)
+ : Ty(ty), CanBeASubClass(CanBeSub) {}
----------------
`Ty(Ty)` is the idiom here.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:126
+
+ // If the casts have a common anchestor it could not be a succeeded downcast.
+ for (const auto &PreviousBase : PreviousRD->bases())
----------------
Counterexample:
```
struct A {};
struct B : A {};
struct C : A, B {};
```
Downcast from `C` to `B` should succeed, even though they have a common ancestor `A` (which has the same `CXXRecordDecl` but currently isn't the same object within `C`, but can be, if `B` declares `A` as a virtual base).
================
Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:174
+
+constexpr llvm::StringLiteral Vowels = "aeiou";
+
----------------
Omg lol nice. Did you try to figure out how do other people normally do it?
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67079/new/
https://reviews.llvm.org/D67079
More information about the cfe-commits
mailing list