Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NFC][CLANG] Fix static code analyzer concerns
Reported by Static Code Analyzer Tool, Coverity: Dereference null return value Inside "ExprConstant.cpp" file, in <unnamed>::RecordExprEvaluator::VisitCXXStdInitializerListExpr(clang::CXXStdInitializerListExpr const *): Return value of function which returns null is dereferenced without checking. bool RecordExprEvaluator::VisitCXXStdInitializerListExpr( const CXXStdInitializerListExpr *E) { // returned_null: getAsConstantArrayType returns nullptr (checked 81 out of 93 times). //var_assigned: Assigning: ArrayType = nullptr return value from getAsConstantArrayType. const ConstantArrayType *ArrayType = Info.Ctx.getAsConstantArrayType(E->getSubExpr()->getType()); LValue Array; //Condition !EvaluateLValue(E->getSubExpr(), Array, this->Info, false), taking false branch. if (!EvaluateLValue(E->getSubExpr(), Array, Info)) return false; // Get a pointer to the first element of the array. //Dereference null return value (NULL_RETURNS) //dereference: Dereferencing a pointer that might be nullptr ArrayType when calling addArray. Array.addArray(Info, E, ArrayType); This patch adds an assert for unexpected type for array initializer. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D151040
- Loading branch information