Memoize CGFunctionInfo construction.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63576 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCall.h b/lib/CodeGen/CGCall.h
index aaab36c..6113049 100644
--- a/lib/CodeGen/CGCall.h
+++ b/lib/CodeGen/CGCall.h
@@ -15,6 +15,7 @@
 #ifndef CLANG_CODEGEN_CGCALL_H
 #define CLANG_CODEGEN_CGCALL_H
 
+#include <llvm/ADT/FoldingSet.h>
 #include "clang/AST/Type.h"
 
 #include "CGValue.h"
@@ -49,7 +50,7 @@
   
   /// CGFunctionInfo - Class to encapsulate the information about a
   /// function definition.
-  class CGFunctionInfo {
+  class CGFunctionInfo : public llvm::FoldingSetNode {
     llvm::SmallVector<QualType, 16> ArgTypes;
 
   public:
@@ -62,6 +63,19 @@
     arg_iterator arg_end() const;
 
     QualType getReturnType() const { return ArgTypes[0]; }
+
+    void Profile(llvm::FoldingSetNodeID &ID) {
+      Profile(ID, getReturnType(), arg_begin(), arg_end());
+    }
+    template<class Iterator>
+    static void Profile(llvm::FoldingSetNodeID &ID, 
+                        QualType ResTy,
+                        Iterator begin,
+                        Iterator end) {
+      ResTy.Profile(ID);
+      for (; begin != end; ++begin)
+        begin->Profile(ID);
+    }
   };
 }  // end namespace CodeGen
 }  // end namespace clang