[clang] bbcc7c5 - [NFC] Initialize member pointer and avoid potential null dereference
Sindhu Chittireddy via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 25 11:36:03 PDT 2023
Author: Sindhu Chittireddy
Date: 2023-08-25T11:35:44-07:00
New Revision: bbcc7c5614cd642c8e71b89a6655b097454d57ea
URL: https://github.com/llvm/llvm-project/commit/bbcc7c5614cd642c8e71b89a6655b097454d57ea
DIFF: https://github.com/llvm/llvm-project/commit/bbcc7c5614cd642c8e71b89a6655b097454d57ea.diff
LOG: [NFC] Initialize member pointer and avoid potential null dereference
Differential Revision: https://reviews.llvm.org/D158775
Added:
Modified:
clang/lib/AST/Interp/Interp.h
clang/lib/Analysis/ThreadSafety.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index cfef45d2e8d689..180bd5add2e262 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -201,13 +201,14 @@ bool Ret(InterpState &S, CodePtr &PC, APValue &Result) {
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();
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index 087994e6ebd702..34260ac8f4e7d6 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1008,7 +1008,7 @@ class ThreadSafetyAnalyzer {
threadSafety::SExprBuilder SxBuilder;
ThreadSafetyHandler &Handler;
- const CXXMethodDecl *CurrentMethod;
+ const CXXMethodDecl *CurrentMethod = nullptr;
LocalVariableMap LocalVarMap;
FactManager FactMan;
std::vector<CFGBlockInfo> BlockInfo;
More information about the cfe-commits
mailing list