From 00eb3f9c5b33e3d99aee1f8b75dd9c9678fdd66b Mon Sep 17 00:00:00 2001 From: Francois Pichet Date: Sat, 4 Dec 2010 09:14:42 +0000 Subject: More anonymous struct/union redesign. This one deals with anonymous field used in a constructor initializer list: struct X { X() : au_i1(123) {} union { int au_i1; float au_f1; }; }; clang will now deal with au_i1 explicitly as an IndirectFieldDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120900 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 35ba2543ef..5697c5f1a4 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1574,23 +1574,13 @@ LValue CodeGenFunction::EmitLValueForBitfield(llvm::Value *BaseValue, /// that the base value is a pointer to the enclosing record, derive /// an lvalue for the ultimate field. LValue CodeGenFunction::EmitLValueForAnonRecordField(llvm::Value *BaseValue, - const FieldDecl *Field, + const IndirectFieldDecl *Field, unsigned CVRQualifiers) { - llvm::SmallVector Path; - Path.push_back(Field); - - while (Field->getParent()->isAnonymousStructOrUnion()) { - const ValueDecl *VD = Field->getParent()->getAnonymousStructOrUnionObject(); - if (!isa(VD)) break; - Field = cast(VD); - Path.push_back(Field); - } - - llvm::SmallVectorImpl::reverse_iterator - I = Path.rbegin(), E = Path.rend(); + IndirectFieldDecl::chain_iterator I = Field->chain_begin(), + IEnd = Field->chain_end(); while (true) { - LValue LV = EmitLValueForField(BaseValue, *I, CVRQualifiers); - if (++I == E) return LV; + LValue LV = EmitLValueForField(BaseValue, cast(*I), CVRQualifiers); + if (++I == IEnd) return LV; assert(LV.isSimple()); BaseValue = LV.getAddress(); -- cgit v1.2.3