This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG18a628ec4ef7: [AST] Use correct APSInt width when evaluating string literals (authored by barannikov88).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D154773/new/ https://reviews.llvm.org/D154773 Files: clang/lib/AST/ExprConstant.cpp Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -3463,8 +3463,7 @@ assert(CAT && "string literal isn't an array"); QualType CharType = CAT->getElementType(); assert(CharType->isIntegerType() && "unexpected character type"); - - APSInt Value(S->getCharByteWidth() * Info.Ctx.getCharWidth(), + APSInt Value(Info.Ctx.getTypeSize(CharType), CharType->isUnsignedIntegerType()); if (Index < S->getLength()) Value = S->getCodeUnit(Index); @@ -3487,7 +3486,7 @@ unsigned Elts = CAT->getSize().getZExtValue(); Result = APValue(APValue::UninitArray(), std::min(S->getLength(), Elts), Elts); - APSInt Value(S->getCharByteWidth() * Info.Ctx.getCharWidth(), + APSInt Value(Info.Ctx.getTypeSize(CharType), CharType->isUnsignedIntegerType()); if (Result.hasArrayFiller()) Result.getArrayFiller() = APValue(Value);
Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -3463,8 +3463,7 @@ assert(CAT && "string literal isn't an array"); QualType CharType = CAT->getElementType(); assert(CharType->isIntegerType() && "unexpected character type"); - - APSInt Value(S->getCharByteWidth() * Info.Ctx.getCharWidth(), + APSInt Value(Info.Ctx.getTypeSize(CharType), CharType->isUnsignedIntegerType()); if (Index < S->getLength()) Value = S->getCodeUnit(Index); @@ -3487,7 +3486,7 @@ unsigned Elts = CAT->getSize().getZExtValue(); Result = APValue(APValue::UninitArray(), std::min(S->getLength(), Elts), Elts); - APSInt Value(S->getCharByteWidth() * Info.Ctx.getCharWidth(), + APSInt Value(Info.Ctx.getTypeSize(CharType), CharType->isUnsignedIntegerType()); if (Result.hasArrayFiller()) Result.getArrayFiller() = APValue(Value);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits