tbaeder updated this revision to Diff 556474. tbaeder marked 2 inline comments as done.
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158502/new/ https://reviews.llvm.org/D158502 Files: clang/lib/AST/Interp/ByteCodeExprGen.cpp Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -733,8 +733,14 @@ template <class Emitter> bool ByteCodeExprGen<Emitter>::VisitConstantExpr(const ConstantExpr *E) { - // TODO: Check if the ConstantExpr already has a value set and if so, - // use that instead of evaluating it again. + // Try to emit the APValue directly, without visiting the subexpr. + // This will only fail if we can't emit the APValue, so won't emit any + // diagnostics or any double values. + std::optional<PrimType> T = classify(E->getType()); + if (T && E->hasAPValueResult() && + this->visitAPValue(E->getAPValueResult(), *T, E)) + return true; + return this->delegate(E->getSubExpr()); }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -733,8 +733,14 @@ template <class Emitter> bool ByteCodeExprGen<Emitter>::VisitConstantExpr(const ConstantExpr *E) { - // TODO: Check if the ConstantExpr already has a value set and if so, - // use that instead of evaluating it again. + // Try to emit the APValue directly, without visiting the subexpr. + // This will only fail if we can't emit the APValue, so won't emit any + // diagnostics or any double values. + std::optional<PrimType> T = classify(E->getType()); + if (T && E->hasAPValueResult() && + this->visitAPValue(E->getAPValueResult(), *T, E)) + return true; + return this->delegate(E->getSubExpr()); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits