diff options
author | elizabethandrews <elizabeth.andrews@intel.com> | 2024-04-12 14:41:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-12 14:41:49 -0400 |
commit | b074f25329501487e312b59e463a2d5f743090f8 (patch) | |
tree | 8afa3b0216f4f2647536fc3d5192bfd777d47027 | |
parent | 0318ce8552896df7b180ee5481463eada65c755e (diff) | |
download | llvm-b074f25329501487e312b59e463a2d5f743090f8.zip llvm-b074f25329501487e312b59e463a2d5f743090f8.tar.gz llvm-b074f25329501487e312b59e463a2d5f743090f8.tar.bz2 |
[NFC][Clang] Fix static analyzer concern (#88179)
Fix static analyzer concerns about dereferencing
null values.
-rw-r--r-- | clang/lib/AST/Interp/InterpState.h | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaAPINotes.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/AST/Interp/InterpState.h b/clang/lib/AST/Interp/InterpState.h index 8f84bf6..c17cfad 100644 --- a/clang/lib/AST/Interp/InterpState.h +++ b/clang/lib/AST/Interp/InterpState.h @@ -89,7 +89,11 @@ public: /// Delegates source mapping to the mapper. SourceInfo getSource(const Function *F, CodePtr PC) const override { - return M ? M->getSource(F, PC) : F->getSource(PC); + if (M) + return M->getSource(F, PC); + + assert(F && "Function cannot be null"); + return F->getSource(PC); } Context &getContext() const { return Ctx; } diff --git a/clang/lib/Sema/SemaAPINotes.cpp b/clang/lib/Sema/SemaAPINotes.cpp index a312830..4c445f2 100644 --- a/clang/lib/Sema/SemaAPINotes.cpp +++ b/clang/lib/Sema/SemaAPINotes.cpp @@ -463,6 +463,8 @@ static void ProcessAPINotes(Sema &S, FunctionOrMethod AnyFunc, D = MD; } + assert((FD || MD) && "Expecting Function or ObjCMethod"); + // Nullability of return type. if (Info.NullabilityAudited) applyNullability(S, D, Info.getReturnTypeInfo(), Metadata); |