]> granicus.if.org Git - clang/commitdiff
Refine placement of LangOptions object in CompilerInvocation by adding a new baseclas...
authorTed Kremenek <kremenek@apple.com>
Fri, 18 Nov 2011 04:32:13 +0000 (04:32 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 18 Nov 2011 04:32:13 +0000 (04:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144973 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/CompilerInvocation.h
lib/ARCMigrate/ARCMT.cpp
lib/Frontend/CompilerInvocation.cpp

index 10cb4bc93566390d00ae995824c70b02fc6cb42d..bbefdb662d1cbb1d1780e7a15d0daa44f5a65dfe 100644 (file)
 
 namespace clang {
 
+class CompilerInvocation;
 class DiagnosticsEngine;
+  
+class CompilerInvocationBase : public llvm::RefCountedBase<CompilerInvocation> { 
+protected:
+  /// Options controlling the language variant.
+  llvm::IntrusiveRefCntPtr<LangOptions> LangOpts;
+public:
+  CompilerInvocationBase();
 
+  CompilerInvocationBase(const CompilerInvocationBase &X);
+  
+  LangOptions *getLangOpts() { return LangOpts.getPtr(); }
+  const LangOptions *getLangOpts() const { return LangOpts.getPtr(); }
+};
+  
 /// CompilerInvocation - Helper class for holding the data necessary to invoke
 /// the compiler.
 ///
 /// This class is designed to represent an abstract "invocation" of the
 /// compiler, including data such as the include paths, the code generation
 /// options, the warning flags, and so on.
-class CompilerInvocation : public llvm::RefCountedBase<CompilerInvocation> {
+class CompilerInvocation : public CompilerInvocationBase {
   /// Options controlling the static analyzer.
   AnalyzerOptions AnalyzerOpts;
 
@@ -60,9 +74,6 @@ class CompilerInvocation : public llvm::RefCountedBase<CompilerInvocation> {
   /// Options controlling the #include directive.
   HeaderSearchOptions HeaderSearchOpts;
 
-  /// Options controlling the language variant.
-  llvm::IntrusiveRefCntPtr<LangOptions> LangOpts;
-
   /// Options controlling the preprocessor (aside from #include handling).
   PreprocessorOptions PreprocessorOpts;
 
@@ -73,7 +84,7 @@ class CompilerInvocation : public llvm::RefCountedBase<CompilerInvocation> {
   TargetOptions TargetOpts;
 
 public:
-  CompilerInvocation();
+  CompilerInvocation() {}
 
   /// @name Utility Methods
   /// @{
@@ -111,7 +122,7 @@ public:
   /// \param LangStd - The input language standard.
   void setLangDefaults(InputKind IK,
                   LangStandard::Kind LangStd = LangStandard::lang_unspecified) {
-    setLangDefaults(*LangOpts, IK, LangStd);
+    setLangDefaults(*getLangOpts(), IK, LangStd);
   }
 
   /// setLangDefaults - Set language defaults for the given input language and
@@ -166,11 +177,6 @@ public:
     return FrontendOpts;
   }
 
-  LangOptions *getLangOpts() { return LangOpts.getPtr(); }
-  const LangOptions *getLangOpts() const { return LangOpts.getPtr(); }
-
-  void setLangOpts(LangOptions *LangOpts);
-
   PreprocessorOptions &getPreprocessorOpts() { return PreprocessorOpts; }
   const PreprocessorOptions &getPreprocessorOpts() const {
     return PreprocessorOpts;
index 06bc6b8c04511794ce2c8b365a6d80d43f3a89fe..9985160468c9047655ab5e817c21a92384f1dfb1 100644 (file)
@@ -190,7 +190,6 @@ createInvocationForMigration(CompilerInvocation &origCI) {
   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);
index 13be408141c7d7ae7a4d81a2dc65d5a5e11e6932..738facf0695c69ceaf6a72e4fac4612947a4aec7 100644 (file)
@@ -34,12 +34,11 @@ using namespace clang;
 // 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.