Fix C++ backend bug introduced in d14a2de168.

(This was causing a number of tests to fail with the generic
targets.)
This commit is contained in:
Matt Pharr
2012-01-19 11:35:02 -07:00
parent 68f6ea8def
commit 2fb59c90cf
2 changed files with 12 additions and 3 deletions

View File

@@ -778,6 +778,16 @@ raw_ostream &CWriter::printType(raw_ostream &Out, Type *Ty,
Out << " return ret;\n";
Out << " }\n ";
// if it's an array of i8s, also provide a version that takes a const
// char *
if (ATy->getElementType() == LLVMTypes::Int8Type) {
Out << " static " << NameSoFar << " init(const char *p) {\n";
Out << " " << NameSoFar << " ret;\n";
Out << " strncpy((char *)ret.array, p, " << NumElements << ");\n";
Out << " return ret;\n";
Out << " }\n";
}
printType(Out, ATy->getElementType(), false,
"array[" + utostr(NumElements) + "]");
return Out << ";\n} ";
@@ -1330,7 +1340,7 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
case Type::ArrayTyID: {
ArrayType *AT = cast<ArrayType>(CPV->getType());
if (Static || !isa<StructType>(AT->getElementType()))
if (Static)
// arrays are wrapped in structs...
Out << "{ ";
else {
@@ -1352,7 +1362,7 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
}
}
}
if (Static || !isa<StructType>(AT->getElementType()))
if (Static)
Out << " }";
else
Out << ")";

View File

@@ -387,7 +387,6 @@ lGenericTypeLayoutIndeterminate(LLVM_TYPE_CONST llvm::Type *type) {
return false;
}
type->dump();
Assert(llvm::isa<LLVM_TYPE_CONST llvm::VectorType>(type));
return true;
}