diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -282,22 +282,6 @@ return state; } -ProgramStateRef ExprEngine::handleLVectorSplat( - ProgramStateRef state, const LocationContext* LCtx, const CastExpr* CastE, - StmtNodeBuilder &Bldr, ExplodedNode* Pred) { - // Recover some path sensitivity by conjuring a new value. - QualType resultType = CastE->getType(); - if (CastE->isGLValue()) - resultType = getContext().getPointerType(resultType); - SVal result = svalBuilder.conjureSymbolVal(nullptr, CastE, LCtx, - resultType, - currBldrCtx->blockCount()); - state = state->BindExpr(CastE, LCtx, result); - Bldr.generateNode(CastE, Pred, state); - - return state; -} - void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, ExplodedNode *Pred, ExplodedNodeSet &Dst) { @@ -535,17 +519,20 @@ continue; } // Explicitly proceed with default handler for this case cascade. - state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred); - continue; } + LLVM_FALLTHROUGH; // Various C++ casts that are not handled yet. case CK_ToUnion: + case CK_MatrixCast: case CK_VectorSplat: { - state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred); - continue; - } - case CK_MatrixCast: { - // TODO: Handle MatrixCast here. + QualType resultType = CastE->getType(); + if (CastE->isGLValue()) + resultType = getContext().getPointerType(resultType); + SVal result = svalBuilder.conjureSymbolVal( + /*symbolTag=*/nullptr, CastE, LCtx, resultType, + currBldrCtx->blockCount()); + state = state->BindExpr(CastE, LCtx, result); + Bldr.generateNode(CastE, Pred, state); continue; } } diff --git a/clang/test/Analysis/casts.c b/clang/test/Analysis/casts.c --- a/clang/test/Analysis/casts.c +++ b/clang/test/Analysis/casts.c @@ -1,7 +1,7 @@ -// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -Wno-pointer-to-int-cast -verify -analyzer-config eagerly-assume=false %s -// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -Wno-pointer-to-int-cast -verify -analyzer-config eagerly-assume=false %s -// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -Wno-pointer-to-int-cast -verify -DEAGERLY_ASSUME=1 -w %s -// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -Wno-pointer-to-int-cast -verify -DEAGERLY_ASSUME=1 -DBIT32=1 -w %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -fenable-matrix -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -Wno-pointer-to-int-cast -verify -analyzer-config eagerly-assume=false %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -fenable-matrix -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -Wno-pointer-to-int-cast -verify -analyzer-config eagerly-assume=false %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -fenable-matrix -analyzer-checker=core,alpha.core,debug.ExprInspection -Wno-pointer-to-int-cast -verify -DEAGERLY_ASSUME=1 -w %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -fenable-matrix -analyzer-checker=core,alpha.core,debug.ExprInspection -Wno-pointer-to-int-cast -verify -DEAGERLY_ASSUME=1 -DBIT32=1 -w %s extern void clang_analyzer_eval(_Bool); @@ -193,6 +193,27 @@ } } +void test_ToUnion_cast(unsigned long long x) { + union Key { + unsigned long long data; + }; + void clang_analyzer_dump_union(union Key); + clang_analyzer_dump_union((union Key)x); // expected-warning {{Unknown}} +} + +typedef char cx5x5 __attribute__((matrix_type(5, 5))); +typedef int ix5x5 __attribute__((matrix_type(5, 5))); +void test_MatrixCast_cast(cx5x5 c) { + void clang_analyzer_dump_ix5x5(ix5x5); + clang_analyzer_dump_ix5x5((ix5x5)c); // expected-warning {{Unknown}} +} + +void test_VectorSplat_cast(long x) { + typedef int __attribute__((ext_vector_type(2))) V; + void clang_analyzer_dump_V(V); + clang_analyzer_dump_V((V)x); // expected-warning {{Unknown}} +} + #endif #ifdef EAGERLY_ASSUME