diff options
author | Craig Topper <craig.topper@gmail.com> | 2014-09-12 05:19:24 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2014-09-12 05:19:24 +0000 |
commit | be25030137581596ed289dc7955f5b69dbadcf63 (patch) | |
tree | 80b6017de73ca835ae13b5b68a654681be045e37 /clang/lib/Lex/Preprocessor.cpp | |
parent | fec61ef3911abde1ee4967a8b7ebb6d9799e8742 (diff) | |
download | bcm5719-llvm-be25030137581596ed289dc7955f5b69dbadcf63.tar.gz bcm5719-llvm-be25030137581596ed289dc7955f5b69dbadcf63.zip |
Use unique_ptr for ScratchBuf and PragmaHandlers in the preprocessor.
llvm-svn: 217656
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 091a5de8c67..b2f8107ca28 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -62,9 +62,12 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, IdentifierInfoLookup *IILookup, bool OwnsHeaders, TranslationUnitKind TUKind) : PPOpts(PPOpts), Diags(&diags), LangOpts(opts), Target(nullptr), - FileMgr(Headers.getFileMgr()), SourceMgr(SM), HeaderInfo(Headers), + FileMgr(Headers.getFileMgr()), SourceMgr(SM), + ScratchBuf(new ScratchBuffer(SourceMgr)),HeaderInfo(Headers), TheModuleLoader(TheModuleLoader), ExternalSource(nullptr), - Identifiers(opts, IILookup), IncrementalProcessing(false), TUKind(TUKind), + Identifiers(opts, IILookup), + PragmaHandlers(new PragmaNamespace(StringRef())), + IncrementalProcessing(false), TUKind(TUKind), CodeComplete(nullptr), CodeCompletionFile(nullptr), CodeCompletionOffset(0), LastTokenWasAt(false), ModuleImportExpectsIdentifier(false), CodeCompletionReached(0), @@ -74,7 +77,6 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, MIChainHead(nullptr), DeserialMIChainHead(nullptr) { OwnsHeaderSearch = OwnsHeaders; - ScratchBuf = new ScratchBuffer(SourceMgr); CounterValue = 0; // __COUNTER__ starts at 0. // Clear stats. @@ -112,7 +114,6 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, SetPoisonReason(Ident__VA_ARGS__,diag::ext_pp_bad_vaargs_use); // Initialize the pragma handlers. - PragmaHandlers = new PragmaNamespace(StringRef()); RegisterBuiltinPragmas(); // Initialize builtin macros like __LINE__ and friends. @@ -163,12 +164,6 @@ Preprocessor::~Preprocessor() { for (MacroArgs *ArgList = MacroArgCache; ArgList;) ArgList = ArgList->deallocate(); - // Release pragma information. - delete PragmaHandlers; - - // Delete the scratch buffer info. - delete ScratchBuf; - // Delete the header search info, if we own it. if (OwnsHeaderSearch) delete &HeaderInfo; @@ -188,8 +183,8 @@ void Preprocessor::InitializeForModelFile() { NumEnteredSourceFiles = 0; // Reset pragmas - PragmaHandlersBackup = PragmaHandlers; - PragmaHandlers = new PragmaNamespace(StringRef()); + PragmaHandlersBackup = PragmaHandlers.release(); + PragmaHandlers = llvm::make_unique<PragmaNamespace>(StringRef()); RegisterBuiltinPragmas(); // Reset PredefinesFileID @@ -199,8 +194,7 @@ void Preprocessor::InitializeForModelFile() { void Preprocessor::FinalizeForModelFile() { NumEnteredSourceFiles = 1; - delete PragmaHandlers; - PragmaHandlers = PragmaHandlersBackup; + PragmaHandlers.reset(PragmaHandlersBackup); } void Preprocessor::setPTHManager(PTHManager* pm) { |