[clang] 37af81f - [Clang][Sema] Add a nullptr check in template name (#162377)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 8 13:57:20 PDT 2025
Author: Shafik Yaghmour
Date: 2025-10-08T13:57:16-07:00
New Revision: 37af81fbb54aed5a7433c8c48217b1d54384c3cf
URL: https://github.com/llvm/llvm-project/commit/37af81fbb54aed5a7433c8c48217b1d54384c3cf
DIFF: https://github.com/llvm/llvm-project/commit/37af81fbb54aed5a7433c8c48217b1d54384c3cf.diff
LOG: [Clang][Sema] Add a nullptr check in template name (#162377)
Static analysis flagged that when calling ActOnTemplateName, `S` can be
a `nullptr`
and we call `isTemplateName` which unconditionally dereferences the `S`
argument at
some point. I added a `nullptr` check to assure we don't dereference `S`
in
`isTemplateName` if it is a `nullptr`.
Added:
Modified:
clang/lib/Sema/SemaTemplate.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 419f3e1ad30ed..3a6ff9910667d 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -318,7 +318,7 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
}
}
- if (isPackProducingBuiltinTemplateName(Template) &&
+ if (isPackProducingBuiltinTemplateName(Template) && S &&
S->getTemplateParamParent() == nullptr)
Diag(Name.getBeginLoc(), diag::err_builtin_pack_outside_template) << TName;
// Recover by returning the template, even though we would never be able to
More information about the cfe-commits
mailing list