For a rather short code snippet, if debug.ReportStmts (added in this patch) was enabled, a bug reporter visitor crashed:
struct h { operator int(); }; int k() { return h(); }
include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h:472: clang::ento::PathDiagnosticSpotPiece::PathDiagnosticSpotPiece(const clang::ento::PathDiagnosticLocation &, llvm::StringRef, PathDiagnosticPiece::Kind, bool): Assertion `Pos.isValid() && Pos.asLocation().isValid() && "PathDiagnosticSpotPiece's must have a valid location."' failed.
Ultimately, this originated from PathDiagnosticLocation::createMemberLoc, as it didn't handle the case where it's MemberExpr typed parameter returned and invalid SourceLocation for MemberExpr::getMemberLoc. The solution was to find any related valid SourceLocaion, and Stmt::getBeginLoc happens to be just that.
Technically, we don't invoke checkPreStmt for every Stmt (eg., IfStmt is omitted in favor of checkBranchCondition, IntegerLiteral is outright skipped because ExprEngine doesn't even evaluate anything at this point). Moreover, for some Stmts we more-or-less-intentionally only invoke checkPreStmt but not checkPostStmt.
Also would you eventually want to expand this checker with non-Stmt callbacks?