зеркало из https://github.com/microsoft/clang-1.git
IRgen/i386/C++: Fix isSingleElementStruct computation for C++ record decls.
- Fixes PR7098. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103514 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
bbbe074566
Коммит
9430d5a615
|
@ -130,6 +130,30 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) {
|
|||
return 0;
|
||||
|
||||
const Type *Found = 0;
|
||||
|
||||
// If this is a C++ record, check the bases first.
|
||||
if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
|
||||
for (CXXRecordDecl::base_class_const_iterator i = CXXRD->bases_begin(),
|
||||
e = CXXRD->bases_end(); i != e; ++i) {
|
||||
const CXXRecordDecl *Base =
|
||||
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
|
||||
// Ignore empty records.
|
||||
if (Base->isEmpty())
|
||||
continue;
|
||||
|
||||
// If we already found an element then this isn't a single-element struct.
|
||||
if (Found)
|
||||
return 0;
|
||||
|
||||
// If this is non-empty and not a single element struct, the composite
|
||||
// cannot be a single element struct.
|
||||
Found = isSingleElementStruct(i->getType(), Context);
|
||||
if (!Found)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for single element.
|
||||
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
|
||||
i != e; ++i) {
|
||||
const FieldDecl *FD = *i;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s
|
||||
// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
// Non-trivial dtors, should both be passed indirectly.
|
||||
struct S {
|
||||
|
@ -13,6 +13,7 @@ void f(S) { }
|
|||
|
||||
// Non-trivial dtors, should both be passed indirectly.
|
||||
class C {
|
||||
public:
|
||||
~C();
|
||||
double c;
|
||||
};
|
||||
|
@ -51,3 +52,34 @@ struct BasicAliasAnalysis : public ModulePass, public AliasAnalysis {
|
|||
|
||||
void BasicAliasAnalysis::getModRefInfo(CallSite CS) {
|
||||
}
|
||||
|
||||
// Check various single element struct type conditions.
|
||||
//
|
||||
// PR7098.
|
||||
|
||||
// CHECK: define i64 @_Z2f0v()
|
||||
struct s0_0 { int x; };
|
||||
struct s0_1 : s0_0 { int* y; };
|
||||
s0_1 f0() { return s0_1(); }
|
||||
|
||||
// CHECK: define i32 @_Z2f1v()
|
||||
struct s1_0 { int x; };
|
||||
struct s1_1 : s1_0 { };
|
||||
s1_1 f1() { return s1_1(); }
|
||||
|
||||
// CHECK: define double @_Z2f2v()
|
||||
struct s2_0 { double x; };
|
||||
struct s2_1 : s2_0 { };
|
||||
s2_1 f2() { return s2_1(); }
|
||||
|
||||
// CHECK: define double @_Z2f3v()
|
||||
struct s3_0 { };
|
||||
struct s3_1 { double x; };
|
||||
struct s3_2 : s3_0, s3_1 { };
|
||||
s3_2 f3() { return s3_2(); }
|
||||
|
||||
// CHECK: define i64 @_Z2f4v()
|
||||
struct s4_0 { float x; };
|
||||
struct s4_1 { float x; };
|
||||
struct s4_2 : s4_0, s4_1 { };
|
||||
s4_2 f4() { return s4_2(); }
|
||||
|
|
Загрузка…
Ссылка в новой задаче