Remaining work to collect objective-c's type qualifiers and use them to encode
method types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43617 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index 37b5300..acba398 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -915,7 +915,8 @@
 void ASTContext::getObjcEncodingForMethodDecl(ObjcMethodDecl *Decl, 
                                               std::string& S)
 {
-  // TODO: First encode type qualifer, 'in', 'inout', etc. for the return type.
+  // Encode type qualifer, 'in', 'inout', etc. for the return type.
+  getObjcEncodingForTypeQualifier(Decl->getObjcDeclQualifier(), S);
   // Encode result type.
   getObjcEncodingForType(Decl->getResultType(), S);
   // Compute size of all parameters.
@@ -941,8 +942,10 @@
   ParmOffset = 2 * PtrSize;
   for (int i = 0; i < NumOfParams; i++) {
     QualType PType = Decl->getParamDecl(i)->getType();
-    // TODO: Process argument qualifiers for user supplied arguments; such as,
+    // Process argument qualifiers for user supplied arguments; such as,
     // 'in', 'inout', etc.
+    getObjcEncodingForTypeQualifier(
+      Decl->getParamDecl(i)->getObjcDeclQualifier(), S);
     getObjcEncodingForType(PType, S);
     S += llvm::utostr(ParmOffset);
     ParmOffset += getObjcEncodingTypeSize(PType);
@@ -1054,6 +1057,22 @@
     assert(0 && "@encode for type not implemented!");
 }
 
+void ASTContext::getObjcEncodingForTypeQualifier(Decl::ObjcDeclQualifier QT, 
+                                                 std::string& S) const {
+  if (QT & Decl::OBJC_TQ_In)
+    S += 'n';
+  if (QT & Decl::OBJC_TQ_Inout)
+    S += 'N';
+  if (QT & Decl::OBJC_TQ_Out)
+    S += 'o';
+  if (QT & Decl::OBJC_TQ_Bycopy)
+    S += 'O';
+  if (QT & Decl::OBJC_TQ_Byref)
+    S += 'R';
+  if (QT & Decl::OBJC_TQ_Oneway)
+    S += 'V';
+}
+
 void ASTContext::setBuiltinVaListType(QualType T)
 {
   assert(BuiltinVaListType.isNull() && "__builtin_va_list type already set!");