Don't give a default argument to ASTContext::getFunctionType for the TypeQuals parameter, it causes subtle bugs where TypeQuals, while necessary, are omitted from the call.
-Remove the default argument.
-Update all call sites of ASTContext::getFunctionType.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58187 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index f812996..095414b 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -913,7 +913,7 @@
     
     Canonical = getFunctionType(getCanonicalType(ResultTy),
                                 &CanonicalArgs[0], NumArgs,
-                                isVariadic);
+                                isVariadic, TypeQuals);
     
     // Get the new insert position for the node we care about.
     FunctionTypeProto *NewIP =
@@ -1947,6 +1947,9 @@
     if (lproto->isVariadic() != rproto->isVariadic())
       return QualType();
 
+    if (lproto->getTypeQuals() != rproto->getTypeQuals())
+      return QualType();
+
     // Check argument compatibility
     llvm::SmallVector<QualType, 10> types;
     for (unsigned i = 0; i < lproto_nargs; i++) {
@@ -1963,7 +1966,7 @@
     if (allLTypes) return lhs;
     if (allRTypes) return rhs;
     return getFunctionType(retType, types.begin(), types.size(),
-                           lproto->isVariadic());
+                           lproto->isVariadic(), lproto->getTypeQuals());
   }
 
   if (lproto) allRTypes = false;
@@ -1988,7 +1991,8 @@
     if (allLTypes) return lhs;
     if (allRTypes) return rhs;
     return getFunctionType(retType, proto->arg_type_begin(),
-                           proto->getNumArgs(), lproto->isVariadic());
+                           proto->getNumArgs(), lproto->isVariadic(),
+                           lproto->getTypeQuals());
   }
 
   if (allLTypes) return lhs;
diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp
index 1823ee6..a721c6e 100644
--- a/lib/AST/Builtins.cpp
+++ b/lib/AST/Builtins.cpp
@@ -203,5 +203,5 @@
   if (ArgTypes.size() == 0 && TypeStr[0] == '.')
     return Context.getFunctionTypeNoProto(ResType);
   return Context.getFunctionType(ResType, &ArgTypes[0], ArgTypes.size(),
-                                 TypeStr[0] == '.');
+                                 TypeStr[0] == '.', 0);
 }
diff --git a/lib/AST/TypeSerialization.cpp b/lib/AST/TypeSerialization.cpp
index ff784cc..b336722 100644
--- a/lib/AST/TypeSerialization.cpp
+++ b/lib/AST/TypeSerialization.cpp
@@ -194,6 +194,7 @@
 void FunctionTypeProto::EmitImpl(Serializer& S) const {
   S.Emit(getResultType());
   S.EmitBool(isVariadic());
+  S.EmitInt(getTypeQuals());
   S.EmitInt(getNumArgs());
   
   for (arg_type_iterator I=arg_type_begin(), E=arg_type_end(); I!=E; ++I)
@@ -203,6 +204,7 @@
 Type* FunctionTypeProto::CreateImpl(ASTContext& Context, Deserializer& D) {
   QualType ResultType = QualType::ReadVal(D);
   bool isVariadic = D.ReadBool();
+  unsigned TypeQuals = D.ReadInt();
   unsigned NumArgs = D.ReadInt();
   
   llvm::SmallVector<QualType,15> Args;
@@ -211,7 +213,7 @@
     Args.push_back(QualType::ReadVal(D));
   
   return Context.getFunctionType(ResultType,&*Args.begin(), 
-                                 NumArgs,isVariadic).getTypePtr();
+                                 NumArgs,isVariadic,TypeQuals).getTypePtr();
 }
 
 //===----------------------------------------------------------------------===//