[clang] [clang] Fix TemplateInstantiator crash transforming loop hint argument (PR #172289)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 15 06:18:41 PST 2025
================
@@ -2197,19 +2197,23 @@ TemplateInstantiator::TransformLoopHintAttr(const LoopHintAttr *LH) {
// Generate error if there is a problem with the value.
if (getSema().CheckLoopHintExpr(TransformedExpr, LH->getLocation(),
- LH->getSemanticSpelling() ==
+ /*AllowZero=*/LH->getSemanticSpelling() ==
LoopHintAttr::Pragma_unroll))
return LH;
LoopHintAttr::OptionType Option = LH->getOption();
LoopHintAttr::LoopHintState State = LH->getState();
- llvm::APSInt ValueAPS =
- TransformedExpr->EvaluateKnownConstInt(getSema().getASTContext());
- // The values of 0 and 1 block any unrolling of the loop.
- if (ValueAPS.isZero() || ValueAPS.isOne()) {
- Option = LoopHintAttr::Unroll;
- State = LoopHintAttr::Disable;
+ if (Option == LoopHintAttr::UnrollCount &&
----------------
erichkeane wrote:
Why does the 'UnrollCount' matter here at all? It seems like the previous code didn't really need to check that?
https://github.com/llvm/llvm-project/pull/172289
More information about the cfe-commits
mailing list