Fix regression with @encode string. rdar://9624314.

llvm-svn: 133312
This commit is contained in:
Argyrios Kyrtzidis 2011-06-17 23:19:38 +00:00
parent 00758b08ae
commit 95a76f3715
2 changed files with 20 additions and 2 deletions

View File

@ -4511,6 +4511,8 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
BE = CXXRec->bases_end(); BI != BE; ++BI) {
if (!BI->isVirtual()) {
CXXRecordDecl *base = BI->getType()->getAsCXXRecordDecl();
if (base->isEmpty())
continue;
uint64_t offs = layout.getBaseClassOffsetInBits(base);
FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
std::make_pair(offs, base));
@ -4532,6 +4534,8 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
BI = CXXRec->vbases_begin(),
BE = CXXRec->vbases_end(); BI != BE; ++BI) {
CXXRecordDecl *base = BI->getType()->getAsCXXRecordDecl();
if (base->isEmpty())
continue;
uint64_t offs = layout.getVBaseClassOffsetInBits(base);
FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
std::make_pair(offs, base));
@ -4595,8 +4599,8 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
// expands virtual bases each time one is encountered in the hierarchy,
// making the encoding type bigger than it really is.
getObjCEncodingForStructureImpl(base, S, FD, /*includeVBases*/false);
if (!base->isEmpty())
CurOffs += toBits(getASTRecordLayout(base).getNonVirtualSize());
assert(!base->isEmpty());
CurOffs += toBits(getASTRecordLayout(base).getNonVirtualSize());
} else {
FieldDecl *field = cast<FieldDecl>(dcl);
if (FD) {

View File

@ -91,6 +91,20 @@ namespace rdar9357400 {
const char gg[] = @encode(vector4f);
}
// rdar://9624314
namespace rdar9624314 {
struct B2 { int x; };
struct B3 {};
struct S : B2, B3 {};
// CHECK: @_ZN11rdar9624314L2ggE = internal constant [6 x i8] c"{S=i}\00"
const char gg[] = @encode(S);
struct S2 { unsigned : 0; int x; unsigned : 0; };
// CHECK: @_ZN11rdar9624314L2g2E = internal constant [11 x i8] c"{S2=b0ib0}\00"
const char g2[] = @encode(S2);
}
struct Base1 {
char x;
};