[ExternalASTMerger] Import Objective-C classes

This patch adds functionality and a test for importing Objective-C classes
and their methods.

It also adds a flag to clang-import-test to set the language used for
parsing. This takes the same argument format as the -x option to the
driver.

Differential Revision: https://reviews.llvm.org/D35274

llvm-svn: 309014
diff --git a/clang/lib/AST/ExternalASTMerger.cpp b/clang/lib/AST/ExternalASTMerger.cpp
index 4f4a997..f69b5d6 100644
--- a/clang/lib/AST/ExternalASTMerger.cpp
+++ b/clang/lib/AST/ExternalASTMerger.cpp
@@ -44,6 +44,9 @@
       ToTag->setMustBuildLookupTable();
     } else if (auto ToNamespace = dyn_cast<NamespaceDecl>(To)) {
       ToNamespace->setHasExternalVisibleStorage();
+    } else if (auto ToContainer = dyn_cast<ObjCContainerDecl>(To)) {
+      ToContainer->setHasExternalLexicalStorage();
+      ToContainer->setMustBuildLookupTable();
     }
     return ASTImporter::Imported(From, To);
   }
@@ -80,11 +83,12 @@
 }
 
 bool IsForwardDeclaration(Decl *D) {
-  assert(!isa<ObjCInterfaceDecl>(D)); // TODO handle this case
   if (auto TD = dyn_cast<TagDecl>(D)) {
     return !TD->isThisDeclarationADefinition();
   } else if (auto FD = dyn_cast<FunctionDecl>(D)) {
     return !FD->isThisDeclarationADefinition();
+  } else if (auto OID = dyn_cast<ObjCInterfaceDecl>(D)) {
+     return OID->isThisDeclarationADefinition();
   } else {
     return false;
   }