llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (smanna12)

<details>
<summary>Changes</summary>

This patch addresses static analyzer concern where TSI could be dereferenced 
after being assigned a null value from SubstType in 
clang::TemplateDeclInstantiator::VisitUsingEnumDecl(clang::UsingEnumDecl *).

The fix now checks null value of TSI after the call to SubstType and return 
nullptr to prevent potential null pointer dereferences when calling 
UsingEnumDecl::Create() and ensures safe execution.

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


1 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+4) 


``````````diff
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 64f6b01bed229..8d856b807889f 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3413,6 +3413,10 @@ Decl 
*TemplateDeclInstantiator::VisitUsingEnumDecl(UsingEnumDecl *D) {
 
   TypeSourceInfo *TSI = SemaRef.SubstType(D->getEnumType(), TemplateArgs,
                                           D->getLocation(), D->getDeclName());
+
+  if (!TSI)
+    return nullptr;
+
   UsingEnumDecl *NewUD =
       UsingEnumDecl::Create(SemaRef.Context, Owner, D->getUsingLoc(),
                             D->getEnumLoc(), D->getLocation(), TSI);

``````````

</details>


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

Reply via email to