[PATCH] D158775: [NFC] Initialize member pointer and avoid potential null dereference

Sindhu Chittireddy via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 25 11:36:17 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbcc7c5614cd: [NFC] Initialize member pointer and avoid potential null dereference (authored by schittir).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158775/new/

https://reviews.llvm.org/D158775

Files:
  clang/lib/AST/Interp/Interp.h
  clang/lib/Analysis/ThreadSafety.cpp


Index: clang/lib/Analysis/ThreadSafety.cpp
===================================================================
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -1008,7 +1008,7 @@
   threadSafety::SExprBuilder SxBuilder;
 
   ThreadSafetyHandler &Handler;
-  const CXXMethodDecl *CurrentMethod;
+  const CXXMethodDecl *CurrentMethod = nullptr;
   LocalVariableMap LocalVarMap;
   FactManager FactMan;
   std::vector<CFGBlockInfo> BlockInfo;
Index: clang/lib/AST/Interp/Interp.h
===================================================================
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -201,13 +201,14 @@
       return false;
   }
 
+  assert(S.Current);
   assert(S.Current->getFrameOffset() == S.Stk.size() && "Invalid frame");
   if (!S.checkingPotentialConstantExpression() || S.Current->Caller) {
     // Certain builtin functions are declared as func-name(...), so the
     // parameters are checked in Sema and only available through the CallExpr.
     // The interp::Function we create for them has 0 parameters, so we need to
     // remove them from the stack by checking the CallExpr.
-    if (S.Current && S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()))
+    if (S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()))
       popBuiltinArgs(S, PC);
     else
       S.Current->popArgs();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158775.553555.patch
Type: text/x-patch
Size: 1376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230825/21600958/attachment.bin>


More information about the cfe-commits mailing list