teak-llvm/clang/test/Analysis/diagnostics/invalid-srcloc-fix.cpp
Kristof Umann 4962816e72 [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
2019-03-14 16:10:29 +00:00

13 lines
264 B
C++

// RUN: %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-output=plist -o %t.plist \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=debug.ReportStmts
struct h {
operator int();
};
int k() {
return h(); // expected-warning 3 {{Statement}}
}