summaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/Store.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2013-06-20 07:45:01 +0000
committerPavel Labath <labath@google.com>2013-06-20 07:45:01 +0000
commit9122025df6682a29ba4bdfc4330d2caebb8ea4de (patch)
treedc6b95da16bbf51421477ff2d2b19e37936f1524 /lib/StaticAnalyzer/Core/Store.cpp
parentfc5335dd8ead65b7dc1dedd75ed32f9e74f229d0 (diff)
downloadclang-9122025df6682a29ba4bdfc4330d2caebb8ea4de.tar.gz
clang-9122025df6682a29ba4bdfc4330d2caebb8ea4de.tar.bz2
clang-9122025df6682a29ba4bdfc4330d2caebb8ea4de.tar.xz
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184403 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/Store.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/Store.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Core/Store.cpp b/lib/StaticAnalyzer/Core/Store.cpp
index 690ed08ffc..0beb9dbbc5 100644
--- a/lib/StaticAnalyzer/Core/Store.cpp
+++ b/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,