Skip to content

Commit b074f25

Browse files
[NFC][Clang] Fix static analyzer concern (llvm#88179)
Fix static analyzer concerns about dereferencing null values.
1 parent 0318ce8 commit b074f25

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/AST/Interp/InterpState.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ class InterpState final : public State, public SourceMapper {
8989

9090
/// Delegates source mapping to the mapper.
9191
SourceInfo getSource(const Function *F, CodePtr PC) const override {
92-
return M ? M->getSource(F, PC) : F->getSource(PC);
92+
if (M)
93+
return M->getSource(F, PC);
94+
95+
assert(F && "Function cannot be null");
96+
return F->getSource(PC);
9397
}
9498

9599
Context &getContext() const { return Ctx; }

clang/lib/Sema/SemaAPINotes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ static void ProcessAPINotes(Sema &S, FunctionOrMethod AnyFunc,
463463
D = MD;
464464
}
465465

466+
assert((FD || MD) && "Expecting Function or ObjCMethod");
467+
466468
// Nullability of return type.
467469
if (Info.NullabilityAudited)
468470
applyNullability(S, D, Info.getReturnTypeInfo(), Metadata);

0 commit comments

Comments
 (0)