]> granicus.if.org Git - clang/commitdiff
Fix ASTContext::getObjCEncodingForType() to limit the type info for structure bodies...
authorSteve Naroff <snaroff@apple.com>
Thu, 14 Aug 2008 15:00:38 +0000 (15:00 +0000)
committerSteve Naroff <snaroff@apple.com>
Thu, 14 Aug 2008 15:00:38 +0000 (15:00 +0000)
This fixes <rdar://problem/6140902> clang ObjC rewriter: If a class contains a struct ivar with a lot of members, ...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54777 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp

index 7ff4ae916545e6691a176ae0f66d7398e447ba6c..fa3139c50005a37ce33b8eb89526ea4afb513cc1 100644 (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++) {