Index: lib/AST/ExprConstant.cpp =================================================================== --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -1989,6 +1989,7 @@ static bool HandleLValueArrayAdjustment(EvalInfo &Info, const Expr *E, LValue &LVal, QualType EltTy, int64_t Adjustment) { + assert(E && "expression to be evaluated must be not NULL"); CharUnits SizeOfPointee; if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfPointee)) return false; Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -1312,6 +1312,7 @@ CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset); V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars); } + assert(V && "constant must be not NULL at this point"); TemplateParams.push_back(DBuilder.createTemplateValueParameter( TheCU, Name, TTy, cast_or_null(V->stripPointerCasts()))); Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -2303,6 +2303,7 @@ unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace) { + assert(D && "variable declaration must be not NULL"); if (LangOpts.CUDA && LangOpts.CUDAIsDevice) { if (D->hasAttr()) AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant); Index: lib/Sema/SemaDeclCXX.cpp =================================================================== --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -434,6 +434,9 @@ /// error, false otherwise. bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S) { + assert(New && "New function declaration is NULL, aborting merge."); + assert(Old && "Old function declaration is NULL, aborting merge."); + bool Invalid = false; // The declaration context corresponding to the scope is the semantic Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -939,6 +939,7 @@ (VD && DSAStack->isForceVarCapturing())) return VD ? VD : Info.second; auto DVarPrivate = DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode()); + assert(DVarPrivate.PrivateCopy && "DSAStackTy object must be not NULL"); if (DVarPrivate.CKind != OMPC_unknown && isOpenMPPrivate(DVarPrivate.CKind)) return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl()); DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate, MatchesAlways(), @@ -3924,6 +3925,7 @@ static ExprResult tryBuildCapture(Sema &SemaRef, Expr *Capture, llvm::MapVector &Captures) { + assert(Capture && "cannot build capture if expression is NULL"); if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects)) return SemaRef.PerformImplicitConversion( Capture->IgnoreImpCasts(), Capture->getType(), Sema::AA_Converting, @@ -4177,7 +4179,7 @@ SemaRef.Diag(CollapseLoopCountExpr->getExprLoc(), diag::note_omp_collapse_ordered_expr) << 0 << CollapseLoopCountExpr->getSourceRange(); - else + else if (OrderedLoopCountExpr) SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(), diag::note_omp_collapse_ordered_expr) << 1 << OrderedLoopCountExpr->getSourceRange(); Index: lib/Sema/SemaOverload.cpp =================================================================== --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -8705,6 +8705,7 @@ void Sema::diagnoseEquivalentInternalLinkageDeclarations( SourceLocation Loc, const NamedDecl *D, ArrayRef Equiv) { + assert(D && "named declaration must be not NULL"); Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D; Module *M = getOwningModule(const_cast(D)); @@ -9185,7 +9186,9 @@ !ToRefTy->getPointeeType()->isIncompleteType() && S.IsDerivedFrom(SourceLocation(), ToRefTy->getPointeeType(), FromTy)) { BaseToDerivedConversion = 3; - } else if (ToTy->isLValueReferenceType() && !FromExpr->isLValue() && + } else if (FromExpr && + ToTy->isLValueReferenceType() && + !FromExpr->isLValue() && ToTy.getNonReferenceType().getCanonicalType() == FromTy.getNonReferenceType().getCanonicalType()) { S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_lvalue) Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp +++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp @@ -693,6 +693,8 @@ !Param->getType()->isReferenceType()) continue; + assert(ArgExpr && "cannot get the type of a NULL expression"); + NullConstraint Nullness = getNullConstraint(*ArgSVal, State); Nullability RequiredNullability =