summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
diff options
context:
space:
mode:
authorDaniel Marjamaki <daniel.marjamaki@evidente.se>2017-03-07 19:20:48 +0000
committerDaniel Marjamaki <daniel.marjamaki@evidente.se>2017-03-07 19:20:48 +0000
commitcf715bd33006599db3b6d472bdf6bbe40a616dd0 (patch)
tree0adc143fc1eea7ade621bf7021409248f316a39f /clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
parentac2b5767afb8362bd86a0cb73bb9b528097ca22f (diff)
downloadbcm5719-llvm-cf715bd33006599db3b6d472bdf6bbe40a616dd0.tar.gz
bcm5719-llvm-cf715bd33006599db3b6d472bdf6bbe40a616dd0.zip
[analyzer] Fix crashes in CastToStruct checker for undefined structs
This crash was reported in https://bugs.llvm.org//show_bug.cgi?id=31173 Differential Revision: https://reviews.llvm.org/D28297 llvm-svn: 297187
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
index 16a475ae9dd..65e81315f09 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
@@ -84,6 +84,10 @@ bool CastToStructVisitor::VisitCastExpr(const CastExpr *CE) {
if (!VD || VD->getType()->isReferenceType())
return true;
+ if (ToPointeeTy->isIncompleteType() ||
+ OrigPointeeTy->isIncompleteType())
+ return true;
+
// Warn when there is widening cast.
unsigned ToWidth = Ctx.getTypeInfo(ToPointeeTy).Width;
unsigned OrigWidth = Ctx.getTypeInfo(OrigPointeeTy).Width;
OpenPOWER on IntegriCloud