[cfe-commits] r139380 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplate.cpp test/Modules/module-private.cpp

Douglas Gregor dgregor at apple.com
Fri Sep 9 11:32:39 PDT 2011


Author: dgregor
Date: Fri Sep  9 13:32:39 2011
New Revision: 139380

URL: http://llvm.org/viewvc/llvm-project?rev=139380&view=rev
Log:
Propagate __module_private__ from previous declarations to later
declarations.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/Modules/module-private.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=139380&r1=139379&r2=139380&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Sep  9 13:32:39 2011
@@ -1394,6 +1394,10 @@
   if (TypedefNameDecl *Typedef = dyn_cast<TypedefNameDecl>(Old))
     New->setPreviousDeclaration(Typedef);
 
+  // __module_private__ is propagated to later declarations.
+  if (Old->isModulePrivate())
+    New->setModulePrivate();
+    
   if (getLangOptions().Microsoft)
     return;
 
@@ -1959,6 +1963,10 @@
   if (Old->isPure())
     New->setPure();
 
+  // __module_private__ is propagated to later declarations.
+  if (Old->isModulePrivate())
+    New->setModulePrivate();
+  
   // Merge attributes from the parameters.  These can mismatch with K&R
   // declarations.
   if (New->getNumParams() == Old->getNumParams())
@@ -2141,6 +2149,10 @@
     return New->setInvalidDecl();
   }
 
+  // __module_private__ is propagated to later declarations.
+  if (Old->isModulePrivate())
+    New->setModulePrivate();
+
   // Variables with external linkage are analyzed in FinalizeDeclaratorGroup.
 
   // FIXME: The test for external storage here seems wrong? We still
@@ -5242,6 +5254,10 @@
           NewTemplateDecl->setMemberSpecialization();
           assert(OldTemplateDecl->isMemberSpecialization());
         }
+        
+        if (OldTemplateDecl->isModulePrivate())
+          NewTemplateDecl->setModulePrivate();
+        
       } else {
         if (isa<CXXMethodDecl>(NewFD)) // Set access for out-of-line definitions
           NewFD->setAccess(OldDecl->getAccess());
@@ -7726,7 +7742,9 @@
     AddMsStructLayoutForRecord(RD);
   }
 
-  if (IsModulePrivate)
+  if (PrevDecl && PrevDecl->isModulePrivate())
+    New->setModulePrivate();
+  else if (IsModulePrivate)
     New->setModulePrivate();
 
   // If this is a specialization of a member class (of a class template),

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=139380&r1=139379&r2=139380&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Sep  9 13:32:39 2011
@@ -945,7 +945,7 @@
         // definition, as part of error recovery?
         return true;
       }
-    }
+    }    
   } else if (PrevDecl && PrevDecl->isTemplateParameter()) {
     // Maybe we will complain about the shadowed template parameter.
     DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
@@ -999,8 +999,10 @@
                                 DeclarationName(Name), TemplateParams,
                                 NewClass, PrevClassTemplate);
   NewClass->setDescribedClassTemplate(NewTemplate);
-
-  if (IsModulePrivate)
+  
+  if (PrevClassTemplate && PrevClassTemplate->isModulePrivate()) {
+    NewTemplate->setModulePrivate();
+  } else if (IsModulePrivate)
     NewTemplate->setModulePrivate();
   
   // Build the type for the class template declaration now.

Modified: cfe/trunk/test/Modules/module-private.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-private.cpp?rev=139380&r1=139379&r2=139380&view=diff
==============================================================================
--- cfe/trunk/test/Modules/module-private.cpp (original)
+++ cfe/trunk/test/Modules/module-private.cpp Fri Sep  9 13:32:39 2011
@@ -5,7 +5,9 @@
 
 #if defined(MODULE_LEFT)
 
-__module_private__ struct HiddenStruct {
+__module_private__ struct HiddenStruct;
+
+struct HiddenStruct {
 };
 
 
@@ -15,15 +17,23 @@
 __module_private__ void f1(T*);
 
 template<typename T>
-__module_private__ class vector {
+void f1(T*);
+
+template<typename T>
+__module_private__ class vector;
+
+template<typename T>
+class vector {
 };
 
 vector<float> vec_float;
 
 typedef __module_private__ int Integer;
+typedef int Integer;
 
 #elif defined(MODULE_RIGHT)
 __module_private__ double &f0(double);
+double &f0(double);
 
 __module_private__ int hidden_var;
 





More information about the cfe-commits mailing list