[PATCH] D157888: [NFC][Clang] Fix static analyzer concern about null value dereference

Elizabeth Andrews via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 14 08:38:23 PDT 2023


eandrews created this revision.
eandrews added reviewers: aaron.ballman, tahonermann.
Herald added subscribers: steakhal, abrachet, manas, ASDenysPetrov, martong, dkrupp, donat.nagy, Szelethus, a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added a project: All.
eandrews requested review of this revision.

https://reviews.llvm.org/D157888

Files:
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -653,10 +653,11 @@
   if (Type.isSuppressOnSink()) {
     const ExplodedNode *AcquireNode = getAcquireSite(ErrorNode, Sym, C);
     if (AcquireNode) {
+      const Stmt *S = AcquireNode->getStmtForDiagnostics();
+      assert(S && "Statmement 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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157888.549962.patch
Type: text/x-patch
Size: 936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230814/8b49d482/attachment.bin>


More information about the cfe-commits mailing list