Fix a number of issues w.r.t. emission of global for functions and
aliases.
 - Attributes specific to a definition are only set when the
   definition is seen.
 - Alias generation is delayed until the end of the module; necessary
   since the alias may reference forward.
 - Fixes: PR2743, <rdr://6140807&6094512>
 - Improves: <rdr://6095112> (added XFAIL)

Also, print module on verification failures.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55966 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index 41985fb..bcb464b 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -79,11 +79,16 @@
   /// (which may change with attributes such as asm-labels).
   llvm::DenseMap<IdentifierInfo*, llvm::GlobalValue*> GlobalDeclMap;
 
-  /// List of static global for which code generation is delayed. When
-  /// the translation unit has been fully processed we will lazily
-  /// emit definitions for only the decls that were actually used.
-  /// This should contain only Function and Var decls, and only those
-  /// which actually define something.
+  /// Aliases - List of aliases in module. These cannot be emitted
+  /// until all the code has been seen, as they reference things by
+  /// name instead of directly and may reference forward.
+  std::vector<const FunctionDecl*> Aliases;
+
+  /// StaticDecls - List of static global for which code generation is
+  /// delayed. When the translation unit has been fully processed we
+  /// will lazily emit definitions for only the decls that were
+  /// actually used.  This should contain only Function and Var decls,
+  /// and only those which actually define something.
   std::vector<const ValueDecl*> StaticDecls;
   
   /// GlobalCtors - Store the list of global constructors and their
@@ -213,7 +218,9 @@
 private:
   /// SetFunctionAttributesForDefinition - Set function attributes
   /// specific to a function definition.
-  void SetFunctionAttributesForDefinition(llvm::Function *F);
+  /// \param D - The ObjCMethodDecl or FunctionDecl defining \arg F.
+  void SetFunctionAttributesForDefinition(const Decl *D,
+                                          llvm::Function *F);
 
   void SetFunctionAttributes(const FunctionDecl *FD,
                              llvm::Function *F);
@@ -238,9 +245,9 @@
   /// or destructor array.
   void EmitCtorList(const CtorList &Fns, const char *GlobalName);
 
+  void EmitAliases(void);
   void EmitAnnotations(void);
   void EmitStatics(void);
-
 };
 }  // end namespace CodeGen
 }  // end namespace clang