llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (elizabethandrews)

<details>
<summary>Changes</summary>

Fix static analyzer concerns about dereferencing
null values.

---
Full diff: https://github.com/llvm/llvm-project/pull/88179.diff


2 Files Affected:

- (modified) clang/lib/AST/Interp/InterpState.h (+5-1) 
- (modified) clang/lib/Sema/SemaAPINotes.cpp (+2) 


``````````diff
diff --git a/clang/lib/AST/Interp/InterpState.h 
b/clang/lib/AST/Interp/InterpState.h
index 8f84bf6ed2eaff..c17cfad11b1e2b 100644
--- a/clang/lib/AST/Interp/InterpState.h
+++ b/clang/lib/AST/Interp/InterpState.h
@@ -89,7 +89,11 @@ class InterpState final : public State, public SourceMapper {
 
   /// 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 836c633e9d2042..abcf5132578eb4 100644
--- a/clang/lib/Sema/SemaAPINotes.cpp
+++ b/clang/lib/Sema/SemaAPINotes.cpp
@@ -458,6 +458,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);

``````````

</details>


https://github.com/llvm/llvm-project/pull/88179
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to