diff options
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/AST/ASTContext.h | 3 | ||||
-rw-r--r-- | include/clang/Basic/FileManager.h | 3 | ||||
-rw-r--r-- | include/clang/Basic/SourceManager.h | 3 | ||||
-rw-r--r-- | include/clang/Basic/TargetInfo.h | 4 | ||||
-rw-r--r-- | include/clang/Frontend/ASTUnit.h | 20 | ||||
-rw-r--r-- | include/clang/Frontend/CompilerInstance.h | 73 | ||||
-rw-r--r-- | include/clang/Frontend/CompilerInvocation.h | 3 | ||||
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 3 |
8 files changed, 54 insertions, 58 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 68a12bba24..9e3d10f63b 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -28,6 +28,7 @@ #include "clang/AST/UsuallyTinyPtrVector.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/Allocator.h" @@ -78,7 +79,7 @@ namespace clang { /// ASTContext - This class holds long-lived AST nodes (such as types and /// decls) that can be referred to throughout the semantic analysis of a file. -class ASTContext { +class ASTContext : public llvm::RefCountedBase<ASTContext> { ASTContext &this_() { return *this; } mutable std::vector<Type*> Types; diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index 465f856f94..2ca344d553 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -15,6 +15,7 @@ #define LLVM_CLANG_FILEMANAGER_H #include "clang/Basic/FileSystemOptions.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" @@ -105,7 +106,7 @@ public: /// properties, such as uniquing files based on "inode", so that a file with two /// names (e.g. symlinked) will be treated as a single file. /// -class FileManager { +class FileManager : public llvm::RefCountedBase<FileManager> { FileSystemOptions FileSystemOpts; class UniqueDirContainer; diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 799ee3438f..4c8a805538 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -19,6 +19,7 @@ #include "llvm/Support/DataTypes.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/DenseMap.h" #include <vector> #include <cassert> @@ -378,7 +379,7 @@ public: /// user's view. In the case of a macro expansion, for example, the spelling /// location indicates where the expanded token came from and the instantiation /// location specifies where it was expanded. -class SourceManager { +class SourceManager : public llvm::RefCountedBase<SourceManager> { /// \brief Diagnostic object. Diagnostic &Diag; diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index fd9e373b73..af5fd5598a 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -14,7 +14,7 @@ #ifndef LLVM_CLANG_BASIC_TARGETINFO_H #define LLVM_CLANG_BASIC_TARGETINFO_H -// FIXME: Daniel isn't smart enough to use a prototype for this. +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" @@ -57,7 +57,7 @@ enum TargetCXXABI { /// TargetInfo - This class exposes information about the current target. /// -class TargetInfo { +class TargetInfo : public llvm::RefCountedBase<TargetInfo> { llvm::Triple Triple; protected: // Target values set by the ctor of the actual target implementation. Default diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index a0c99f12e9..57c59d951e 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -71,12 +71,12 @@ public: private: llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics; - llvm::OwningPtr<FileManager> FileMgr; - llvm::OwningPtr<SourceManager> SourceMgr; + llvm::IntrusiveRefCntPtr<FileManager> FileMgr; + llvm::IntrusiveRefCntPtr<SourceManager> SourceMgr; llvm::OwningPtr<HeaderSearch> HeaderInfo; - llvm::OwningPtr<TargetInfo> Target; - llvm::OwningPtr<Preprocessor> PP; - llvm::OwningPtr<ASTContext> Ctx; + llvm::IntrusiveRefCntPtr<TargetInfo> Target; + llvm::IntrusiveRefCntPtr<Preprocessor> PP; + llvm::IntrusiveRefCntPtr<ASTContext> Ctx; FileSystemOptions FileSystemOpts; @@ -90,7 +90,7 @@ private: /// Optional owned invocation, just used to make the invocation used in /// LoadFromCommandLine available. - llvm::OwningPtr<CompilerInvocation> Invocation; + llvm::IntrusiveRefCntPtr<CompilerInvocation> Invocation; /// \brief The set of target features. /// @@ -396,11 +396,11 @@ public: const SourceManager &getSourceManager() const { return *SourceMgr; } SourceManager &getSourceManager() { return *SourceMgr; } - const Preprocessor &getPreprocessor() const { return *PP.get(); } - Preprocessor &getPreprocessor() { return *PP.get(); } + const Preprocessor &getPreprocessor() const { return *PP; } + Preprocessor &getPreprocessor() { return *PP; } - const ASTContext &getASTContext() const { return *Ctx.get(); } - ASTContext &getASTContext() { return *Ctx.get(); } + const ASTContext &getASTContext() const { return *Ctx; } + ASTContext &getASTContext() { return *Ctx; } bool hasSema() const { return TheSema; } Sema &getSema() const { diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 7ea79e5599..2c37c9568e 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -59,25 +59,25 @@ class TargetInfo; /// and a long form that takes explicit instances of any required objects. class CompilerInstance { /// The options used in this compiler instance. - llvm::OwningPtr<CompilerInvocation> Invocation; + llvm::IntrusiveRefCntPtr<CompilerInvocation> Invocation; /// The diagnostics engine instance. llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics; /// The target being compiled for. - llvm::OwningPtr<TargetInfo> Target; + llvm::IntrusiveRefCntPtr<TargetInfo> Target; /// The file manager. - llvm::OwningPtr<FileManager> FileMgr; + llvm::IntrusiveRefCntPtr<FileManager> FileMgr; /// The source manager. - llvm::OwningPtr<SourceManager> SourceMgr; + llvm::IntrusiveRefCntPtr<SourceManager> SourceMgr; /// The preprocessor. - llvm::OwningPtr<Preprocessor> PP; + llvm::IntrusiveRefCntPtr<Preprocessor> PP; /// The AST context. - llvm::OwningPtr<ASTContext> Context; + llvm::IntrusiveRefCntPtr<ASTContext> Context; /// The AST consumer. llvm::OwningPtr<ASTConsumer> Consumer; @@ -161,10 +161,7 @@ public: return *Invocation; } - CompilerInvocation *takeInvocation() { return Invocation.take(); } - - /// setInvocation - Replace the current invocation; the compiler instance - /// takes ownership of \arg Value. + /// setInvocation - Replace the current invocation. void setInvocation(CompilerInvocation *Value); /// } @@ -251,13 +248,13 @@ public: bool hasDiagnostics() const { return Diagnostics != 0; } + /// Get the current diagnostics engine. Diagnostic &getDiagnostics() const { assert(Diagnostics && "Compiler instance has no diagnostics!"); return *Diagnostics; } - /// setDiagnostics - Replace the current diagnostics engine; the compiler - /// instance takes ownership of \arg Value. + /// setDiagnostics - Replace the current diagnostics engine. void setDiagnostics(Diagnostic *Value); DiagnosticClient &getDiagnosticClient() const { @@ -277,12 +274,7 @@ public: return *Target; } - /// takeTarget - Remove the current diagnostics engine and give ownership - /// to the caller. - TargetInfo *takeTarget() { return Target.take(); } - - /// setTarget - Replace the current diagnostics engine; the compiler - /// instance takes ownership of \arg Value. + /// Replace the current diagnostics engine. void setTarget(TargetInfo *Value); /// } @@ -291,17 +283,17 @@ public: bool hasFileManager() const { return FileMgr != 0; } + /// Return the current file manager to the caller. FileManager &getFileManager() const { assert(FileMgr && "Compiler instance has no file manager!"); return *FileMgr; } + + void resetAndLeakFileManager() { + FileMgr.resetWithoutRelease(); + } - /// takeFileManager - Remove the current file manager and give ownership to - /// the caller. - FileManager *takeFileManager() { return FileMgr.take(); } - - /// setFileManager - Replace the current file manager; the compiler instance - /// takes ownership of \arg Value. + /// setFileManager - Replace the current file manager. void setFileManager(FileManager *Value); /// } @@ -310,17 +302,17 @@ public: bool hasSourceManager() const { return SourceMgr != 0; } + /// Return the current source manager. SourceManager &getSourceManager() const { assert(SourceMgr && "Compiler instance has no source manager!"); return *SourceMgr; } + + void resetAndLeakSourceManager() { + SourceMgr.resetWithoutRelease(); + } - /// takeSourceManager - Remove the current source manager and give ownership - /// to the caller. - SourceManager *takeSourceManager() { return SourceMgr.take(); } - - /// setSourceManager - Replace the current source manager; the compiler - /// instance takes ownership of \arg Value. + /// setSourceManager - Replace the current source manager. void setSourceManager(SourceManager *Value); /// } @@ -329,17 +321,17 @@ public: bool hasPreprocessor() const { return PP != 0; } + /// Return the current preprocessor. Preprocessor &getPreprocessor() const { assert(PP && "Compiler instance has no preprocessor!"); return *PP; } - /// takePreprocessor - Remove the current preprocessor and give ownership to - /// the caller. - Preprocessor *takePreprocessor() { return PP.take(); } + void resetAndLeakPreprocessor() { + PP.resetWithoutRelease(); + } - /// setPreprocessor - Replace the current preprocessor; the compiler instance - /// takes ownership of \arg Value. + /// Replace the current preprocessor. void setPreprocessor(Preprocessor *Value); /// } @@ -352,13 +344,12 @@ public: assert(Context && "Compiler instance has no AST context!"); return *Context; } + + void resetAndLeakASTContext() { + Context.resetWithoutRelease(); + } - /// takeASTContext - Remove the current AST context and give ownership to the - /// caller. - ASTContext *takeASTContext() { return Context.take(); } - - /// setASTContext - Replace the current AST context; the compiler instance - /// takes ownership of \arg Value. + /// setASTContext - Replace the current AST context. void setASTContext(ASTContext *Value); /// \brief Replace the current Sema; the compiler instance takes ownership diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h index e0329dbc96..e18f3fe632 100644 --- a/include/clang/Frontend/CompilerInvocation.h +++ b/include/clang/Frontend/CompilerInvocation.h @@ -22,6 +22,7 @@ #include "clang/Frontend/LangStandard.h" #include "clang/Frontend/PreprocessorOptions.h" #include "clang/Frontend/PreprocessorOutputOptions.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringMap.h" #include <string> @@ -41,7 +42,7 @@ class Diagnostic; /// 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 { +class CompilerInvocation : public llvm::RefCountedBase<CompilerInvocation> { /// Options controlling the static analyzer. AnalyzerOptions AnalyzerOpts; diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 5dc13eb4ea..04b3e3224f 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -25,6 +25,7 @@ #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" @@ -53,7 +54,7 @@ class PreprocessingRecord; /// single source file, and don't know anything about preprocessor-level issues /// like the #include stack, token expansion, etc. /// -class Preprocessor { +class Preprocessor : public llvm::RefCountedBase<Preprocessor> { Diagnostic *Diags; LangOptions Features; const TargetInfo &Target; |