[llvm-branch-commits] [llvm-gcc-branch] r76114 - /llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp
Bill Wendling
isanbard at gmail.com
Thu Jul 16 15:13:40 PDT 2009
Author: void
Date: Thu Jul 16 17:13:40 2009
New Revision: 76114
URL: http://llvm.org/viewvc/llvm-project?rev=76114&view=rev
Log:
--- Merging r75822 into 'gcc/llvm-convert.cpp':
U gcc/llvm-convert.cpp
Code for truncating/padding string constants was
comparing size in bytes with size in elements.
OK for normal strings, not for wchar_t.
Modified:
llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp?rev=76114&r1=76113&r2=76114&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp Thu Jul 16 17:13:40 2009
@@ -6560,25 +6560,27 @@
assert(0 && "Unknown character type!");
}
+ unsigned LenInElts = Len /
+ TREE_INT_CST_LOW(TYPE_SIZE_UNIT(TREE_TYPE(TREE_TYPE(exp))));
unsigned ConstantSize = StrTy->getNumElements();
- if (Len != ConstantSize) {
- // If this is a variable sized array type, set the length to Len.
+ if (LenInElts != ConstantSize) {
+ // If this is a variable sized array type, set the length to LenInElts.
if (ConstantSize == 0) {
tree Domain = TYPE_DOMAIN(TREE_TYPE(exp));
if (!Domain || !TYPE_MAX_VALUE(Domain)) {
- ConstantSize = Len;
- StrTy = ArrayType::get(ElTy, Len);
+ ConstantSize = LenInElts;
+ StrTy = ArrayType::get(ElTy, LenInElts);
}
}
- if (ConstantSize < Len) {
+ if (ConstantSize < LenInElts) {
// Only some chars are being used, truncate the string: char X[2] = "foo";
Elts.resize(ConstantSize);
} else {
// Fill the end of the string with nulls.
Constant *C = Constant::getNullValue(ElTy);
- for (; Len != ConstantSize; ++Len)
+ for (; LenInElts != ConstantSize; ++LenInElts)
Elts.push_back(C);
}
}
More information about the llvm-branch-commits
mailing list