[analyzer] Fix an assertation failure for invalid sourcelocation, add a new debug...
authorKristof Umann <dkszelethus@gmail.com>
Thu, 14 Mar 2019 16:10:29 +0000 (16:10 +0000)
committerKristof Umann <dkszelethus@gmail.com>
Thu, 14 Mar 2019 16:10:29 +0000 (16:10 +0000)
commit4962816e7242b9cec7a1a1157e4efaac75a6120a
tree2ddff6e82f79a0a6ef6901f2058909cad53bf67c
parentac093d61c468b96f82d719f75e4dca8eab1e85cb
[analyzer] Fix an assertation failure for invalid sourcelocation, add a new debug checker

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();
}

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.

Differential Revision: https://reviews.llvm.org/D58777

llvm-svn: 356161
clang/docs/analyzer/developer-docs/DebugChecks.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
clang/test/Analysis/diagnostics/invalid-srcloc-fix.cpp [new file with mode: 0644]
clang/test/Analysis/plist-html-macros.c