Author: Timm Bäder Date: 2023-08-01T12:23:57+02:00 New Revision: eec6931d778774bd0c03802e2ea21d8da9fa0362
URL: https://github.com/llvm/llvm-project/commit/eec6931d778774bd0c03802e2ea21d8da9fa0362 DIFF: https://github.com/llvm/llvm-project/commit/eec6931d778774bd0c03802e2ea21d8da9fa0362.diff LOG: [clang][Interp] Fix ignoring String- and CharacterLiterals Differential Revision: https://reviews.llvm.org/D149960 Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/test/AST/Interp/literals.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 79b0a3857d075c..40a06b3b80ac0e 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -616,6 +616,8 @@ bool ByteCodeExprGen<Emitter>::VisitAbstractConditionalOperator( template <class Emitter> bool ByteCodeExprGen<Emitter>::VisitStringLiteral(const StringLiteral *E) { + if (DiscardResult) + return true; unsigned StringIndex = P.createGlobalString(E); return this->emitGetPtrGlobal(StringIndex, E); } @@ -623,6 +625,8 @@ bool ByteCodeExprGen<Emitter>::VisitStringLiteral(const StringLiteral *E) { template <class Emitter> bool ByteCodeExprGen<Emitter>::VisitCharacterLiteral( const CharacterLiteral *E) { + if (DiscardResult) + return true; return this->emitConst(E->getValue(), E); } diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp index b8467b86c4c906..64ba381057c458 100644 --- a/clang/test/AST/Interp/literals.cpp +++ b/clang/test/AST/Interp/literals.cpp @@ -901,6 +901,8 @@ namespace DiscardExprs { (int[]){1,2,3}; int arr[] = {1,2,3}; arr[0]; + "a"; + 'b'; return 0; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits