diff options
author | Pavel Labath <labath@google.com> | 2013-06-20 07:45:01 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2013-06-20 07:45:01 +0000 |
commit | cb0b876b39e22dde405f8bdf818402323806ad40 (patch) | |
tree | 360bba994ddcc9706139c115ddf4de9bef8ceb6e /clang/lib/StaticAnalyzer/Core/Store.cpp | |
parent | 265c902d9bfa0c2b32b1667771b96197994694d0 (diff) | |
download | bcm5719-llvm-cb0b876b39e22dde405f8bdf818402323806ad40.tar.gz bcm5719-llvm-cb0b876b39e22dde405f8bdf818402323806ad40.zip |
Fix static analyzer crash when casting from an incomplete type
Summary:
When doing a reinterpret+dynamic cast from an incomplete type, the analyzer
would crash (bug #16308). This fix makes the dynamic cast evaluator ignore
incomplete types, as they can never be used in a dynamic_cast. Also adding a
regression test.
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1006
llvm-svn: 184403
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/Store.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/Store.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/Store.cpp b/clang/lib/StaticAnalyzer/Core/Store.cpp index 690ed08ffc7..0beb9dbbc5b 100644 --- a/clang/lib/StaticAnalyzer/Core/Store.cpp +++ b/clang/lib/StaticAnalyzer/Core/Store.cpp @@ -325,7 +325,10 @@ SVal StoreManager::evalDynamicCast(SVal Base, QualType TargetType, if (MRClass == TargetClass) return loc::MemRegionVal(MR); - if (!TargetType->isVoidType()) { + // We skip over incomplete types. They must be the result of an earlier + // reinterpret_cast, as one can only dynamic_cast between types in the same + // class hierarchy. + if (!TargetType->isVoidType() && MRClass->hasDefinition()) { // Static upcasts are marked as DerivedToBase casts by Sema, so this will // only happen when multiple or virtual inheritance is involved. CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/true, |