[cfe-commits] r155843 - /cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp

Fariborz Jahanian fjahanian at apple.com
Mon Apr 30 12:46:54 PDT 2012


Author: fjahanian
Date: Mon Apr 30 14:46:53 2012
New Revision: 155843

URL: http://llvm.org/viewvc/llvm-project?rev=155843&view=rev
Log:
minor refactoring of modern objc translator.


Modified:
    cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp

Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=155843&r1=155842&r2=155843&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Mon Apr 30 14:46:53 2012
@@ -3494,6 +3494,22 @@
   return false;
 }
 
+static bool IsTagDefinedInsideClass(ASTContext *Context,
+                                    ObjCInterfaceDecl *IDecl, TagDecl *Tag) {
+  if (!IDecl)
+    return false;
+  SourceLocation TagLocation;
+  if (RecordDecl *RD = dyn_cast<RecordDecl>(Tag)) {
+    RD = RD->getDefinition();
+    if (!RD)
+      return false;
+    TagLocation = RD->getLocation();
+    return Context->getSourceManager().isBeforeInTranslationUnit(
+             IDecl->getLocation(), TagLocation);
+  }
+  return false;
+}
+
 /// RewriteObjCFieldDeclType - This routine rewrites a type into the buffer.
 /// It handles elaborated types, as well as enum types in the process.
 bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type, 
@@ -7248,11 +7264,7 @@
 
       if (IvarT->isRecordType()) {
         RecordDecl *RD = IvarT->getAs<RecordType>()->getDecl();
-        RD = RD->getDefinition();
-        bool structIsInside = RD &&
-          Context->getSourceManager().isBeforeInTranslationUnit(
-            iFaceDecl->getDecl()->getLocation(), RD->getLocation());
-        if (structIsInside) {
+        if (IsTagDefinedInsideClass(Context, iFaceDecl->getDecl(), RD)) {
           // decltype(((Foo_IMPL*)0)->bar) *
           std::string RecName = iFaceDecl->getDecl()->getName();
           RecName += "_IMPL";





More information about the cfe-commits mailing list