@@ -6006,6 +6006,9 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
60066006
60076007 return this ->emitGetPtrParam (It->second .Offset , E);
60086008 }
6009+
6010+ if (D->getType ()->isReferenceType ())
6011+ return false ; // FIXME: Do we need to emit InvalidDeclRef?
60096012 }
60106013
60116014 // In case we need to re-visit a declaration.
@@ -6042,9 +6045,7 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
60426045 const auto typeShouldBeVisited = [&](QualType T) -> bool {
60436046 if (T.isConstant (Ctx.getASTContext ()))
60446047 return true ;
6045- if (const auto *RT = T->getAs <ReferenceType>())
6046- return RT->getPointeeType ().isConstQualified ();
6047- return false ;
6048+ return T->isReferenceType ();
60486049 };
60496050
60506051 // DecompositionDecls are just proxies for us.
@@ -6060,9 +6061,12 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
60606061 // other words, we're evaluating the initializer, just to know if we can
60616062 // evaluate the initializer.
60626063 if (VD->isLocalVarDecl () && typeShouldBeVisited (VD->getType ()) &&
6063- VD->getInit () && !VD->getInit ()->isValueDependent () &&
6064- VD->evaluateValue ())
6065- return revisit (VD);
6064+ VD->getInit () && !VD->getInit ()->isValueDependent ()) {
6065+
6066+ if (VD->evaluateValue ())
6067+ return revisit (VD);
6068+ return this ->emitInvalidDeclRef (cast<DeclRefExpr>(E), E);
6069+ }
60666070 }
60676071 } else {
60686072 if (const auto *VD = dyn_cast<VarDecl>(D);
0 commit comments