Fix ASTContext::getObjCEncodingForType() to limit the type info for structure bodies (mimics gcc's adhoc rules).

This fixes <rdar://problem/6140902> clang ObjC rewriter: If a class contains a struct ivar with a lot of members, ... 

llvm-svn: 54777
This commit is contained in:
Steve Naroff 2008-08-14 15:00:38 +00:00
parent 89d6c9f698
commit 40471b3ba8
1 changed files with 6 additions and 1 deletions

View File

@ -1485,6 +1485,11 @@ void ASTContext::getObjCEncodingForType(QualType T, std::string& S,
S += '?';
} else if (const RecordType *RTy = T->getAsRecordType()) {
RecordDecl *RDecl= RTy->getDecl();
// This mimics the behavior in gcc's encode_aggregate_within().
// The idea is to only inline structure definitions for top level pointers
// to structures and embedded structures.
bool inlining = (S.size() == 1 && S[0] == '^' ||
S.size() > 1 && S[S.size()-1] != '^');
S += '{';
S += RDecl->getName();
bool found = false;
@ -1493,7 +1498,7 @@ void ASTContext::getObjCEncodingForType(QualType T, std::string& S,
found = true;
break;
}
if (!found) {
if (!found && inlining) {
ERType.push_back(RTy);
S += '=';
for (int i = 0; i < RDecl->getNumMembers(); i++) {