[cfe-commits] r54777 - /cfe/trunk/lib/AST/ASTContext.cpp

Steve Naroff snaroff at apple.com
Thu Aug 14 08:00:41 PDT 2008


Author: snaroff
Date: Thu Aug 14 10:00:38 2008
New Revision: 54777

URL: http://llvm.org/viewvc/llvm-project?rev=54777&view=rev
Log:
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, ... 

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=54777&r1=54776&r2=54777&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Aug 14 10:00:38 2008
@@ -1485,6 +1485,11 @@
     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 @@
         found = true;
         break;
       }
-    if (!found) {
+    if (!found && inlining) {
       ERType.push_back(RTy);
       S += '=';
       for (int i = 0; i < RDecl->getNumMembers(); i++) {





More information about the cfe-commits mailing list