Refine placement of LangOptions object in CompilerInvocation by adding a new baseclass CompilerInvocationBase with a custom copy constructor.  This ensures that whenever the CompilerInvocation object's copy constructor is used we always clone the LangOptions object.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144973 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp
index 06bc6b8..9985160 100644
--- a/lib/ARCMigrate/ARCMT.cpp
+++ b/lib/ARCMigrate/ARCMT.cpp
@@ -190,7 +190,6 @@
   CInvok->getPreprocessorOpts().ImplicitPTHInclude = std::string();
   std::string define = getARCMTMacroName();
   define += '=';
-  CInvok->setLangOpts(new LangOptions(*CInvok->getLangOpts()));
   CInvok->getPreprocessorOpts().addMacroDef(define);
   CInvok->getLangOpts()->ObjCAutoRefCount = true;
   CInvok->getLangOpts()->setGC(LangOptions::NonGC);
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 13be408..738facf 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -34,12 +34,11 @@
 // Initialization.
 //===----------------------------------------------------------------------===//
 
-CompilerInvocation::CompilerInvocation()
+CompilerInvocationBase::CompilerInvocationBase()
   : LangOpts(new LangOptions()) {}
 
-void CompilerInvocation::setLangOpts(LangOptions *LOpts) {
-  LangOpts = LOpts;
-}
+CompilerInvocationBase::CompilerInvocationBase(const CompilerInvocationBase &X)
+  : LangOpts(new LangOptions(*X.getLangOpts())) {}
 
 //===----------------------------------------------------------------------===//
 // Utility functions.