[PATCH] D58777: [analyzer] Fix an assertation failurure for invalid sourcelocation, add a new debug checker
Kristóf Umann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 28 04:46:42 PST 2019
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, rnkovacs, baloghadamsoftware, Charusso.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, szepet, whisperity.
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.
Repository:
rC Clang
https://reviews.llvm.org/D58777
Files:
docs/analyzer/developer-docs/DebugChecks.rst
include/clang/StaticAnalyzer/Checkers/Checkers.td
lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
lib/StaticAnalyzer/Core/PathDiagnostic.cpp
test/Analysis/invalid-pos-fix.cpp
test/Analysis/plist-html-macros.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58777.188711.patch
Type: text/x-patch
Size: 4421 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190228/022d6936/attachment.bin>
More information about the cfe-commits
mailing list