tbaeder created this revision. tbaeder added reviewers: aaron.ballman, tahonermann, shafik, erichkeane. Herald added a project: All. tbaeder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D148689 Files: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/lib/AST/Interp/ByteCodeExprGen.h clang/test/AST/Interp/literals.cpp Index: clang/test/AST/Interp/literals.cpp =================================================================== --- clang/test/AST/Interp/literals.cpp +++ clang/test/AST/Interp/literals.cpp @@ -779,3 +779,12 @@ } static_assert(ignoredDecls() == 12, ""); #endif + +namespace PredefinedExprs { + constexpr char heh(unsigned index) { + return __FUNCTION__[index]; + } + static_assert(heh(0) == 'h', ""); + static_assert(heh(1) == 'e', ""); + static_assert(heh(2) == 'h', ""); +} Index: clang/lib/AST/Interp/ByteCodeExprGen.h =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.h +++ clang/lib/AST/Interp/ByteCodeExprGen.h @@ -93,6 +93,7 @@ bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E); bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E); bool VisitTypeTraitExpr(const TypeTraitExpr *E); + bool VisitPredefinedExpr(const PredefinedExpr *E); protected: bool visitExpr(const Expr *E) override; Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -867,6 +867,14 @@ return this->emitConstBool(E->getValue(), E); } +template <class Emitter> +bool ByteCodeExprGen<Emitter>::VisitPredefinedExpr(const PredefinedExpr *E) { + if (DiscardResult) + return true; + + return this->visit(E->getFunctionName()); +} + template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) { if (E->containsErrors()) return false;
Index: clang/test/AST/Interp/literals.cpp =================================================================== --- clang/test/AST/Interp/literals.cpp +++ clang/test/AST/Interp/literals.cpp @@ -779,3 +779,12 @@ } static_assert(ignoredDecls() == 12, ""); #endif + +namespace PredefinedExprs { + constexpr char heh(unsigned index) { + return __FUNCTION__[index]; + } + static_assert(heh(0) == 'h', ""); + static_assert(heh(1) == 'e', ""); + static_assert(heh(2) == 'h', ""); +} Index: clang/lib/AST/Interp/ByteCodeExprGen.h =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.h +++ clang/lib/AST/Interp/ByteCodeExprGen.h @@ -93,6 +93,7 @@ bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E); bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E); bool VisitTypeTraitExpr(const TypeTraitExpr *E); + bool VisitPredefinedExpr(const PredefinedExpr *E); protected: bool visitExpr(const Expr *E) override; Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -867,6 +867,14 @@ return this->emitConstBool(E->getValue(), E); } +template <class Emitter> +bool ByteCodeExprGen<Emitter>::VisitPredefinedExpr(const PredefinedExpr *E) { + if (DiscardResult) + return true; + + return this->visit(E->getFunctionName()); +} + template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) { if (E->containsErrors()) return false;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits