[cfe-commits] r133312 - in /cfe/trunk: lib/AST/ASTContext.cpp test/CodeGenObjCXX/encode.mm
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Jun 17 16:19:38 PDT 2011
Author: akirtzidis
Date: Fri Jun 17 18:19:38 2011
New Revision: 133312
URL: http://llvm.org/viewvc/llvm-project?rev=133312&view=rev
Log:
Fix regression with @encode string. rdar://9624314.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenObjCXX/encode.mm
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=133312&r1=133311&r2=133312&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jun 17 18:19:38 2011
@@ -4511,6 +4511,8 @@
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 @@
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 @@
// 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) {
Modified: cfe/trunk/test/CodeGenObjCXX/encode.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/encode.mm?rev=133312&r1=133311&r2=133312&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/encode.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/encode.mm Fri Jun 17 18:19:38 2011
@@ -91,6 +91,20 @@
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;
};
More information about the cfe-commits
mailing list