forked from OSchip/llvm-project
Use the new isInteger() method in a couple places, some random cleanup, and
add a fixme. llvm-svn: 93179
This commit is contained in:
parent
b90b66178e
commit
e3e76e2a69
|
@ -38,12 +38,10 @@ CodeGenTypes::~CodeGenTypes() {
|
||||||
I = CGRecordLayouts.begin(), E = CGRecordLayouts.end();
|
I = CGRecordLayouts.begin(), E = CGRecordLayouts.end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
delete I->second;
|
delete I->second;
|
||||||
{
|
|
||||||
llvm::FoldingSet<CGFunctionInfo>::iterator
|
for (llvm::FoldingSet<CGFunctionInfo>::iterator
|
||||||
I = FunctionInfos.begin(), E = FunctionInfos.end();
|
I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; )
|
||||||
while (I != E)
|
|
||||||
delete &*I++;
|
delete &*I++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ConvertType - Convert the specified type to its LLVM form.
|
/// ConvertType - Convert the specified type to its LLVM form.
|
||||||
|
@ -55,9 +53,8 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T) {
|
||||||
// circular types. Loop through all these defered pointees, if any, and
|
// circular types. Loop through all these defered pointees, if any, and
|
||||||
// resolve them now.
|
// resolve them now.
|
||||||
while (!PointersToResolve.empty()) {
|
while (!PointersToResolve.empty()) {
|
||||||
std::pair<QualType, llvm::OpaqueType*> P =
|
std::pair<QualType, llvm::OpaqueType*> P = PointersToResolve.pop_back_val();
|
||||||
PointersToResolve.back();
|
|
||||||
PointersToResolve.pop_back();
|
|
||||||
// We can handle bare pointers here because we know that the only pointers
|
// We can handle bare pointers here because we know that the only pointers
|
||||||
// to the Opaque type are P.second and from other types. Refining the
|
// to the Opaque type are P.second and from other types. Refining the
|
||||||
// opqaue type away will invalidate P.second, but we don't mind :).
|
// opqaue type away will invalidate P.second, but we don't mind :).
|
||||||
|
@ -87,9 +84,10 @@ const llvm::Type *CodeGenTypes::ConvertTypeRecursive(QualType T) {
|
||||||
|
|
||||||
const llvm::Type *CodeGenTypes::ConvertTypeForMemRecursive(QualType T) {
|
const llvm::Type *CodeGenTypes::ConvertTypeForMemRecursive(QualType T) {
|
||||||
const llvm::Type *ResultType = ConvertTypeRecursive(T);
|
const llvm::Type *ResultType = ConvertTypeRecursive(T);
|
||||||
if (ResultType == llvm::Type::getInt1Ty(getLLVMContext()))
|
if (ResultType->isInteger(1))
|
||||||
return llvm::IntegerType::get(getLLVMContext(),
|
return llvm::IntegerType::get(getLLVMContext(),
|
||||||
(unsigned)Context.getTypeSize(T));
|
(unsigned)Context.getTypeSize(T));
|
||||||
|
// FIXME: Should assert that the llvm type and AST type has the same size.
|
||||||
return ResultType;
|
return ResultType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +99,7 @@ const llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T) {
|
||||||
const llvm::Type *R = ConvertType(T);
|
const llvm::Type *R = ConvertType(T);
|
||||||
|
|
||||||
// If this is a non-bool type, don't map it.
|
// If this is a non-bool type, don't map it.
|
||||||
if (R != llvm::Type::getInt1Ty(getLLVMContext()))
|
if (!R->isInteger(1))
|
||||||
return R;
|
return R;
|
||||||
|
|
||||||
// Otherwise, return an integer of the target-specified size.
|
// Otherwise, return an integer of the target-specified size.
|
||||||
|
@ -383,10 +381,9 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
|
||||||
QualType ETy = cast<MemberPointerType>(Ty).getPointeeType();
|
QualType ETy = cast<MemberPointerType>(Ty).getPointeeType();
|
||||||
const llvm::Type *PtrDiffTy =
|
const llvm::Type *PtrDiffTy =
|
||||||
ConvertTypeRecursive(Context.getPointerDiffType());
|
ConvertTypeRecursive(Context.getPointerDiffType());
|
||||||
if (ETy->isFunctionType()) {
|
if (ETy->isFunctionType())
|
||||||
return llvm::StructType::get(TheModule.getContext(), PtrDiffTy, PtrDiffTy,
|
return llvm::StructType::get(TheModule.getContext(), PtrDiffTy, PtrDiffTy,
|
||||||
NULL);
|
NULL);
|
||||||
} else
|
|
||||||
return PtrDiffTy;
|
return PtrDiffTy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,10 +432,8 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
|
||||||
|
|
||||||
// Okay, this is a definition of a type. Compile the implementation now.
|
// Okay, this is a definition of a type. Compile the implementation now.
|
||||||
|
|
||||||
if (TD->isEnum()) {
|
if (TD->isEnum()) // Don't bother storing enums in TagDeclTypes.
|
||||||
// Don't bother storing enums in TagDeclTypes.
|
|
||||||
return ConvertTypeRecursive(cast<EnumDecl>(TD)->getIntegerType());
|
return ConvertTypeRecursive(cast<EnumDecl>(TD)->getIntegerType());
|
||||||
}
|
|
||||||
|
|
||||||
// This decl could well be recursive. In this case, insert an opaque
|
// This decl could well be recursive. In this case, insert an opaque
|
||||||
// definition of this type, which the recursive uses will get. We will then
|
// definition of this type, which the recursive uses will get. We will then
|
||||||
|
@ -449,15 +444,13 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
|
||||||
llvm::PATypeHolder ResultHolder = llvm::OpaqueType::get(getLLVMContext());
|
llvm::PATypeHolder ResultHolder = llvm::OpaqueType::get(getLLVMContext());
|
||||||
TagDeclTypes.insert(std::make_pair(Key, ResultHolder));
|
TagDeclTypes.insert(std::make_pair(Key, ResultHolder));
|
||||||
|
|
||||||
const llvm::Type *ResultType;
|
|
||||||
const RecordDecl *RD = cast<const RecordDecl>(TD);
|
const RecordDecl *RD = cast<const RecordDecl>(TD);
|
||||||
|
|
||||||
// Layout fields.
|
// Layout fields.
|
||||||
CGRecordLayout *Layout =
|
CGRecordLayout *Layout = CGRecordLayoutBuilder::ComputeLayout(*this, RD);
|
||||||
CGRecordLayoutBuilder::ComputeLayout(*this, RD);
|
|
||||||
|
|
||||||
CGRecordLayouts[Key] = Layout;
|
CGRecordLayouts[Key] = Layout;
|
||||||
ResultType = Layout->getLLVMType();
|
const llvm::Type *ResultType = Layout->getLLVMType();
|
||||||
|
|
||||||
// Refine our Opaque type to ResultType. This can invalidate ResultType, so
|
// Refine our Opaque type to ResultType. This can invalidate ResultType, so
|
||||||
// make sure to read the result out of the holder.
|
// make sure to read the result out of the holder.
|
||||||
|
@ -499,8 +492,7 @@ void CodeGenTypes::addBitFieldInfo(const FieldDecl *FD, unsigned FieldNo,
|
||||||
/// getCGRecordLayout - Return record layout info for the given llvm::Type.
|
/// getCGRecordLayout - Return record layout info for the given llvm::Type.
|
||||||
const CGRecordLayout &
|
const CGRecordLayout &
|
||||||
CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const {
|
CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const {
|
||||||
const Type *Key =
|
const Type *Key = Context.getTagDeclType(TD).getTypePtr();
|
||||||
Context.getTagDeclType(TD).getTypePtr();
|
|
||||||
llvm::DenseMap<const Type*, CGRecordLayout *>::const_iterator I
|
llvm::DenseMap<const Type*, CGRecordLayout *>::const_iterator I
|
||||||
= CGRecordLayouts.find(Key);
|
= CGRecordLayouts.find(Key);
|
||||||
assert (I != CGRecordLayouts.end()
|
assert (I != CGRecordLayouts.end()
|
||||||
|
|
Loading…
Reference in New Issue