[clang] [Clang][NFC] Fix potential null dereference in encodeTypeForFunctionPointerAuth (PR #104737)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 18 21:19:23 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (smanna12)
<details>
<summary>Changes</summary>
This patch replaces getAs with castAs to prevent dereferencing a potential null pointer, ensuring type safety as per static analysis report.
---
Full diff: https://github.com/llvm/llvm-project/pull/104737.diff
1 Files Affected:
- (modified) clang/lib/AST/ASTContext.cpp (+1-1)
``````````diff
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index f35a025fc8edfc..b201d201e1ea6a 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3279,7 +3279,7 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx,
case Type::MemberPointer: {
OS << "M";
- const auto *MPT = T->getAs<MemberPointerType>();
+ const auto *MPT = T->castAs<MemberPointerType>();
encodeTypeForFunctionPointerAuth(Ctx, OS, QualType(MPT->getClass(), 0));
encodeTypeForFunctionPointerAuth(Ctx, OS, MPT->getPointeeType());
return;
``````````
</details>
https://github.com/llvm/llvm-project/pull/104737
More information about the cfe-commits
mailing list