================
@@ -2425,6 +2425,33 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty,
ExprValueKind VK,
if (const auto *BE = BD->getBinding())
E->setObjectKind(BE->getObjectKind());
+ auto IsScopeContaining = [](Scope *S, Scope *DeclaredScope) -> bool {
+ while (S) {
+ if (S == DeclaredScope)
+ return true;
+
+ // If we hit an if/else scope boundary, stop searching
+ if (S->getFlags() & Scope::ControlScope)
+ return false;
+
+ S = S->getParent();
+ }
+
+ return false;
+ };
+
+ if (auto *VD = dyn_cast_or_null<VarDecl>(D)) {
+ auto It = IfScopeVars.find(VD);
+
+ if (It != IfScopeVars.end()) {
----------------
erichkeane wrote:
This whole bit looks expensive, we should jsut be able to walk up the Scope
stack and find the appropriate scope, and pick check whether it has the var.
ALSO, the var decl probably needs to get its canonical version.
https://github.com/llvm/llvm-project/pull/156436
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits