tbaeder created this revision. tbaeder added reviewers: aaron.ballman, erichkeane, shafik, cor3ntin. Herald added a project: All. tbaeder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Since we have visitAPValue now, we might as well use it here. Not really possible to test this, so no test included. Repository: rG LLVM Github Monorepo 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 @@ -764,8 +764,11 @@ 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. + 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 @@ -764,8 +764,11 @@ 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. + 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