Author: smanna12 Date: 2024-08-19T09:37:06-05:00 New Revision: 79f6ae05c139d3d5b6446f8a265a3c6e3f5b18f8
URL: https://github.com/llvm/llvm-project/commit/79f6ae05c139d3d5b6446f8a265a3c6e3f5b18f8 DIFF: https://github.com/llvm/llvm-project/commit/79f6ae05c139d3d5b6446f8a265a3c6e3f5b18f8.diff LOG: [Clang][NFC] Fix potential null dereference in encodeTypeForFunctionPointerAuth (#104737) This patch replaces getAs with castAs in encodeTypeForFunctionPointerAuth to prevent dereferencing a potential null pointer, enhancing type safety as reported by static analyzer tool. Added: Modified: clang/lib/AST/ASTContext.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index f35a025fc8edf..b201d201e1ea6 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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits