llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: None (smanna12) <details> <summary>Changes</summary> This patch addresses static analyzer concerns where `TSI` could be dereferenced after being assigned a null value from `SubstType` in `ConvertConstructorToDeductionGuideTransform()`. The fixes now check null value of `TSI` after the call to `SubstType` and return `nullptr` to prevent potential null pointer dereferences when calling getTypeLoc() or getType() and ensure safe execution. --- Full diff: https://github.com/llvm/llvm-project/pull/97097.diff 1 Files Affected: - (modified) clang/lib/Sema/SemaTemplate.cpp (+6) ``````````diff diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index e36ee2d5a46cf..9f4acbe5e6dd5 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2513,6 +2513,9 @@ struct ConvertConstructorToDeductionGuideTransform { TSI = SemaRef.SubstType(TSI, OuterInstantiationArgs, Loc, DeductionGuideName); + if (!TSI) + return nullptr; + FunctionProtoTypeLoc FPTL = TSI->getTypeLoc().castAs<FunctionProtoTypeLoc>(); @@ -2523,6 +2526,9 @@ struct ConvertConstructorToDeductionGuideTransform { if (NestedPattern) TSI = SemaRef.SubstType(TSI, OuterInstantiationArgs, Loc, DeclarationName()); + if (!TSI) + return nullptr; + ParmVarDecl *NewParam = ParmVarDecl::Create(SemaRef.Context, DC, Loc, Loc, nullptr, TSI->getType(), TSI, SC_None, nullptr); `````````` </details> https://github.com/llvm/llvm-project/pull/97097 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits