[clang] [clang] Reject using uninitialized reference in constant evaluation (PR #180923)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 16 21:17:01 PST 2026
================
@@ -7150,8 +7150,20 @@ bool Compiler<Emitter>::VisitVectorUnaryOperator(const UnaryOperator *E) {
template <class Emitter>
bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
- if (DiscardResult)
- return true;
+ if (DiscardResult) {
+ if (!(isa<VarDecl>(D) && D->getType()->isReferenceType()))
----------------
efriedma-quic wrote:
Is a VarDecl the only relevant kind of decl here?
Even if VarDecl is currently the only relevant kind of decl, this seems like a bad way to structure the code; it's likely to get missed if a new kind of relevant decl gets added.
https://github.com/llvm/llvm-project/pull/180923
More information about the cfe-commits
mailing list