Author: Elizabeth Andrews Date: 2023-08-16T13:52:45-07:00 New Revision: e62b2fc40d11b6b13bcc08d7ceafe1472abe4c58
URL: https://github.com/llvm/llvm-project/commit/e62b2fc40d11b6b13bcc08d7ceafe1472abe4c58 DIFF: https://github.com/llvm/llvm-project/commit/e62b2fc40d11b6b13bcc08d7ceafe1472abe4c58.diff LOG: [NFC][Clang] Fix static analyzer concern Fixed static analyzer concern about null value dereference. getStmtForDiagnostics() can return null. Ensure statement exists before dereference in PathDiagnosticLocation::createBegin(). Differential Revision: https://reviews.llvm.org/D157888 Added: Modified: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp Removed: ################################################################################ diff --git a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp index 38b4caa12aef16..b2e55332074c49 100644 --- a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp @@ -653,10 +653,11 @@ void FuchsiaHandleChecker::reportBug(SymbolRef Sym, ExplodedNode *ErrorNode, if (Type.isSuppressOnSink()) { const ExplodedNode *AcquireNode = getAcquireSite(ErrorNode, Sym, C); if (AcquireNode) { + const Stmt *S = AcquireNode->getStmtForDiagnostics(); + assert(S && "Statement cannot be null."); PathDiagnosticLocation LocUsedForUniqueing = PathDiagnosticLocation::createBegin( - AcquireNode->getStmtForDiagnostics(), C.getSourceManager(), - AcquireNode->getLocationContext()); + S, C.getSourceManager(), AcquireNode->getLocationContext()); R = std::make_unique<PathSensitiveBugReport>( Type, Msg, ErrorNode, LocUsedForUniqueing, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits