diff options
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 3ad9ebf..eab1ebf 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -48,7 +48,7 @@ using namespace CodeGen; static_assert(clang::Sema::MaximumAlignment <= llvm::Value::MaximumAlignment, "Clang max alignment greater than what LLVM supports?"); -void CodeGenFunction::EmitDecl(const Decl &D) { +void CodeGenFunction::EmitDecl(const Decl &D, bool EvaluateConditionDecl) { switch (D.getKind()) { case Decl::BuiltinTemplate: case Decl::TranslationUnit: @@ -152,7 +152,7 @@ void CodeGenFunction::EmitDecl(const Decl &D) { return; case Decl::UsingPack: for (auto *Using : cast<UsingPackDecl>(D).expansions()) - EmitDecl(*Using); + EmitDecl(*Using, /*EvaluateConditionDecl=*/EvaluateConditionDecl); return; case Decl::UsingDirective: // using namespace X; [C++] if (CGDebugInfo *DI = getDebugInfo()) @@ -164,10 +164,8 @@ void CodeGenFunction::EmitDecl(const Decl &D) { assert(VD.isLocalVarDecl() && "Should not see file-scope variables inside a function!"); EmitVarDecl(VD); - if (auto *DD = dyn_cast<DecompositionDecl>(&VD)) - for (auto *B : DD->flat_bindings()) - if (auto *HD = B->getHoldingVar()) - EmitVarDecl(*HD); + if (EvaluateConditionDecl) + MaybeEmitDeferredVarDeclInit(&VD); return; } @@ -2059,6 +2057,14 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { /*IsAutoInit=*/false); } +void CodeGenFunction::MaybeEmitDeferredVarDeclInit(const VarDecl *VD) { + if (auto *DD = dyn_cast_if_present<DecompositionDecl>(VD)) { + for (auto *B : DD->flat_bindings()) + if (auto *HD = B->getHoldingVar()) + EmitVarDecl(*HD); + } +} + /// Emit an expression as an initializer for an object (variable, field, etc.) /// at the given location. The expression is not necessarily the normal /// initializer for the object, and the address is not necessarily |