Keep track of type source information in the return type of an
Objective-C method declaration, e.g., for 

  - (Foo *)myMethod;

we now have TypeSourceInfo for the Foo*.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97942 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp
index 2bcf07e..bf1551a 100644
--- a/lib/AST/ASTImporter.cpp
+++ b/lib/AST/ASTImporter.cpp
@@ -2244,12 +2244,14 @@
   if (ResultTy.isNull())
     return 0;
 
+  TypeSourceInfo *ResultTInfo = Importer.Import(D->getResultTypeSourceInfo());
+
   ObjCMethodDecl *ToMethod
     = ObjCMethodDecl::Create(Importer.getToContext(),
                              Loc,
                              Importer.Import(D->getLocEnd()),
                              Name.getObjCSelector(),
-                             ResultTy, DC,
+                             ResultTy, ResultTInfo, DC,
                              D->isInstanceMethod(),
                              D->isVariadic(),
                              D->isSynthesized(),
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 8decafa..67b71a0 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -304,15 +304,16 @@
                                        SourceLocation beginLoc,
                                        SourceLocation endLoc,
                                        Selector SelInfo, QualType T,
+                                       TypeSourceInfo *ResultTInfo,
                                        DeclContext *contextDecl,
                                        bool isInstance,
                                        bool isVariadic,
                                        bool isSynthesized,
                                        ImplementationControl impControl) {
   return new (C) ObjCMethodDecl(beginLoc, endLoc,
-                                  SelInfo, T, contextDecl,
-                                  isInstance,
-                                  isVariadic, isSynthesized, impControl);
+                                SelInfo, T, ResultTInfo, contextDecl,
+                                isInstance,
+                                isVariadic, isSynthesized, impControl);
 }
 
 void ObjCMethodDecl::Destroy(ASTContext &C) {
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index 356bd07..a3f5eac 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -211,6 +211,7 @@
   MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]);
   MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
   MD->setResultType(Reader.GetType(Record[Idx++]));
+  MD->setResultTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
   MD->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
   unsigned NumParams = Record[Idx++];
   llvm::SmallVector<ParmVarDecl *, 16> Params;
@@ -690,7 +691,7 @@
     break;
   case pch::DECL_OBJC_METHOD:
     D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(),
-                               Selector(), QualType(), 0);
+                               Selector(), QualType(), 0, 0);
     break;
   case pch::DECL_OBJC_INTERFACE:
     D = ObjCInterfaceDecl::Create(*Context, 0, SourceLocation(), 0);
diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp
index e776d32..0774797 100644
--- a/lib/Frontend/PCHWriterDecl.cpp
+++ b/lib/Frontend/PCHWriterDecl.cpp
@@ -210,6 +210,7 @@
   // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway
   Record.push_back(D->getObjCDeclQualifier());
   Writer.AddTypeRef(D->getResultType(), Record);
+  Writer.AddTypeSourceInfo(D->getResultTypeSourceInfo(), Record);
   Writer.AddSourceLocation(D->getLocEnd(), Record);
   Record.push_back(D->param_size());
   for (ObjCMethodDecl::param_iterator P = D->param_begin(),
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 149fe15..762ef38 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1681,7 +1681,7 @@
     // for this class.
     GetterMethod = ObjCMethodDecl::Create(Context, property->getLocation(),
                              property->getLocation(), property->getGetterName(),
-                             property->getType(), CD, true, false, true,
+                             property->getType(), 0, CD, true, false, true,
                              (property->getPropertyImplementation() ==
                               ObjCPropertyDecl::Optional) ?
                              ObjCMethodDecl::Optional :
@@ -1703,7 +1703,7 @@
       SetterMethod = ObjCMethodDecl::Create(Context, property->getLocation(),
                                property->getLocation(),
                                property->getSetterName(),
-                               Context.VoidTy, CD, true, false, true,
+                               Context.VoidTy, 0, CD, true, false, true,
                                (property->getPropertyImplementation() ==
                                 ObjCPropertyDecl::Optional) ?
                                ObjCMethodDecl::Optional :
@@ -1992,8 +1992,9 @@
   }
   QualType resultDeclType;
 
+  TypeSourceInfo *ResultTInfo = 0;
   if (ReturnType) {
-    resultDeclType = GetTypeFromParser(ReturnType);
+    resultDeclType = GetTypeFromParser(ReturnType, &ResultTInfo);
 
     // Methods cannot return interface types. All ObjC objects are
     // passed by reference.
@@ -2007,6 +2008,7 @@
 
   ObjCMethodDecl* ObjCMethod =
     ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType,
+                           ResultTInfo,
                            cast<DeclContext>(ClassDecl),
                            MethodType == tok::minus, isVariadic,
                            false,