[clang] [Clang] Initialize bypassed variables w/ trivial-auto-var-init (PR #181937)
Justin Stitt via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 6 14:33:15 PDT 2026
================
@@ -1544,8 +1544,12 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
ShouldEmitLifetimeMarkers = true;
// Initialize helper which will detect jumps which can cause invalid
- // lifetime markers.
- if (ShouldEmitLifetimeMarkers)
+ // lifetime markers or bypass trivial auto var init.
+ bool NeedsBypassDetection =
+ ShouldEmitLifetimeMarkers ||
+ (CGM.getLangOpts().getTrivialAutoVarInit() !=
+ LangOptions::TrivialAutoVarInitKind::Uninitialized);
+ if (NeedsBypassDetection)
Bypasses.Init(CGM, Body);
----------------
JustinStitt wrote:
I emailed @nikic for access to his tool.
AFAICT, the cost here is a linear AST scan -- which should be pretty minimal (reminder to others, this already runs for optimized builds due to `shouldEmitLifetimeMarkers()`).
https://github.com/llvm/llvm-project/pull/181937
More information about the cfe-commits
mailing list