]> granicus.if.org Git - clang/commitdiff
Use non-intrusive refcounting for LangOptions
authorAlp Toker <alp@nuanti.com>
Sun, 6 Jul 2014 05:26:07 +0000 (05:26 +0000)
committerAlp Toker <alp@nuanti.com>
Sun, 6 Jul 2014 05:26:07 +0000 (05:26 +0000)
This type is only refcounted in a couple of places so making ownership explicit
improves clarity.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212387 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/LangOptions.h
include/clang/Frontend/ASTUnit.h
include/clang/Frontend/CompilerInvocation.h
lib/Frontend/ASTUnit.cpp

index e969161b8ff4ea109040f7419eb120f3a6094be7..9bffc7cb18cf49e8179bff064c75c1d2aa34cbfa 100644 (file)
@@ -19,7 +19,6 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Visibility.h"
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include <string>
 
 namespace clang {
@@ -53,7 +52,7 @@ protected:
 
 /// \brief Keeps track of the various options that can be
 /// enabled, which controls the dialect of C or C++ that is accepted.
-class LangOptions : public RefCountedBase<LangOptions>, public LangOptionsBase {
+class LangOptions : public LangOptionsBase {
 public:
   typedef clang::Visibility Visibility;
   
index d5d6d49bdee3d5a6654621a1e0049e07c832d7ed..c9ba6d238dad176a01342954f63da35c8eabf8a0 100644 (file)
@@ -83,7 +83,7 @@ public:
   };
 
 private:
-  IntrusiveRefCntPtr<LangOptions>         LangOpts;
+  std::shared_ptr<LangOptions>            LangOpts;
   IntrusiveRefCntPtr<DiagnosticsEngine>   Diagnostics;
   IntrusiveRefCntPtr<FileManager>         FileMgr;
   IntrusiveRefCntPtr<SourceManager>       SourceMgr;
index 4b3b9be55f5b40d74b4a498cf1690ab3f466444f..0305d8a9afb15f841bbab3e8c42de4738b68d05e 100644 (file)
@@ -52,9 +52,9 @@ bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args,
 class CompilerInvocationBase : public RefCountedBase<CompilerInvocation> {
   void operator=(const CompilerInvocationBase &) LLVM_DELETED_FUNCTION;
 
-protected:
+public:
   /// Options controlling the language variant.
-  IntrusiveRefCntPtr<LangOptions> LangOpts;
+  std::shared_ptr<LangOptions> LangOpts;
 
   /// Options controlling the target.
   IntrusiveRefCntPtr<TargetOptions> TargetOpts;
@@ -68,7 +68,6 @@ protected:
   /// Options controlling the preprocessor (aside from \#include handling).
   IntrusiveRefCntPtr<PreprocessorOptions> PreprocessorOpts;
 
-public:
   CompilerInvocationBase();
   ~CompilerInvocationBase();
 
index be35e31a0b6d9f59536b5b3ba24a4987208a28f9..15f4ca4b0e8229c9315a85154062335828e3cede 100644 (file)
@@ -1087,7 +1087,7 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
          "IR inputs not support here!");
 
   // Configure the various subsystems.
-  LangOpts = &Clang->getLangOpts();
+  LangOpts = Clang->getInvocation().LangOpts;
   FileSystemOpts = Clang->getFileSystemOpts();
   IntrusiveRefCntPtr<vfs::FileSystem> VFS =
       createVFSFromCompilerInvocation(Clang->getInvocation(), getDiagnostics());
@@ -1709,7 +1709,7 @@ void ASTUnit::transferASTDataFromCompilerInstance(CompilerInstance &CI) {
   // Steal the created target, context, and preprocessor if they have been
   // created.
   assert(CI.hasInvocation() && "missing invocation");
-  LangOpts = CI.getInvocation().getLangOpts();
+  LangOpts = CI.getInvocation().LangOpts;
   TheSema.reset(CI.takeSema());
   Consumer.reset(CI.takeASTConsumer());
   if (CI.hasASTContext())