Author: dblaikie Date: Thu Jan 5 13:11:36 2017 New Revision: 291160 URL: http://llvm.org/viewvc/llvm-project?rev=291160&view=rev Log: Move PreprocessorOptions to std::shared_ptr from IntrusiveRefCntPtr
Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/include/clang/Lex/PreprocessorOptions.h cfe/trunk/lib/Frontend/ASTUnit.cpp cfe/trunk/lib/Frontend/CompilerInstance.cpp cfe/trunk/lib/Lex/Preprocessor.cpp cfe/trunk/unittests/Basic/SourceManagerTest.cpp cfe/trunk/unittests/Lex/LexerTest.cpp cfe/trunk/unittests/Lex/PPCallbacksTest.cpp cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original) +++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Thu Jan 5 13:11:36 2017 @@ -68,7 +68,7 @@ public: IntrusiveRefCntPtr<HeaderSearchOptions> HeaderSearchOpts; /// Options controlling the preprocessor (aside from \#include handling). - IntrusiveRefCntPtr<PreprocessorOptions> PreprocessorOpts; + std::shared_ptr<PreprocessorOptions> PreprocessorOpts; CompilerInvocationBase(); ~CompilerInvocationBase(); @@ -90,6 +90,9 @@ public: return *HeaderSearchOpts; } + std::shared_ptr<PreprocessorOptions> getPreprocessorOptsPtr() { + return PreprocessorOpts; + } PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; } const PreprocessorOptions &getPreprocessorOpts() const { return *PreprocessorOpts; Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Jan 5 13:11:36 2017 @@ -95,7 +95,7 @@ enum MacroUse { /// know anything about preprocessor-level issues like the \#include stack, /// token expansion, etc. class Preprocessor : public RefCountedBase<Preprocessor> { - IntrusiveRefCntPtr<PreprocessorOptions> PPOpts; + std::shared_ptr<PreprocessorOptions> PPOpts; DiagnosticsEngine *Diags; LangOptions &LangOpts; const TargetInfo *Target; @@ -650,10 +650,9 @@ class Preprocessor : public RefCountedBa void updateOutOfDateIdentifier(IdentifierInfo &II) const; public: - Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, - DiagnosticsEngine &diags, LangOptions &opts, - SourceManager &SM, HeaderSearch &Headers, - ModuleLoader &TheModuleLoader, + Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts, + DiagnosticsEngine &diags, LangOptions &opts, SourceManager &SM, + HeaderSearch &Headers, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup = nullptr, bool OwnsHeaderSearch = false, TranslationUnitKind TUKind = TU_Complete); Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original) +++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Thu Jan 5 13:11:36 2017 @@ -40,7 +40,7 @@ enum ObjCXXARCStandardLibraryKind { /// PreprocessorOptions - This class is used for passing the various options /// used in preprocessor initialization to InitializePreprocessor(). -class PreprocessorOptions : public RefCountedBase<PreprocessorOptions> { +class PreprocessorOptions { public: std::vector<std::pair<std::string, bool/*isUndef*/> > Macros; std::vector<std::string> Includes; Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original) +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jan 5 13:11:36 2017 @@ -683,7 +683,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFr AST->ASTFileLangOpts, /*Target=*/nullptr)); - PreprocessorOptions *PPOpts = new PreprocessorOptions(); + auto PPOpts = std::make_shared<PreprocessorOptions>(); for (const auto &RemappedFile : RemappedFiles) PPOpts->addRemappedFile(RemappedFile.first, RemappedFile.second); @@ -693,11 +693,11 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFr HeaderSearch &HeaderInfo = *AST->HeaderInfo; unsigned Counter; - AST->PP = - new Preprocessor(PPOpts, AST->getDiagnostics(), AST->ASTFileLangOpts, - AST->getSourceManager(), HeaderInfo, *AST, - /*IILookup=*/nullptr, - /*OwnsHeaderSearch=*/false); + AST->PP = new Preprocessor(std::move(PPOpts), AST->getDiagnostics(), + AST->ASTFileLangOpts, AST->getSourceManager(), + HeaderInfo, *AST, + /*IILookup=*/nullptr, + /*OwnsHeaderSearch=*/false); Preprocessor &PP = *AST->PP; AST->Ctx = new ASTContext(AST->ASTFileLangOpts, AST->getSourceManager(), Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Jan 5 13:11:36 2017 @@ -370,8 +370,9 @@ void CompilerInstance::createPreprocesso getDiagnostics(), getLangOpts(), &getTarget()); - PP = new Preprocessor(&getPreprocessorOpts(), getDiagnostics(), getLangOpts(), - getSourceManager(), *HeaderInfo, *this, PTHMgr, + PP = new Preprocessor(Invocation->getPreprocessorOptsPtr(), getDiagnostics(), + getLangOpts(), getSourceManager(), *HeaderInfo, *this, + PTHMgr, /*OwnsHeaderSearch=*/true, TUKind); PP->Initialize(getTarget(), getAuxTarget()); Modified: cfe/trunk/lib/Lex/Preprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/lib/Lex/Preprocessor.cpp (original) +++ cfe/trunk/lib/Lex/Preprocessor.cpp Thu Jan 5 13:11:36 2017 @@ -68,7 +68,7 @@ LLVM_INSTANTIATE_REGISTRY(PragmaHandlerR //===----------------------------------------------------------------------===// ExternalPreprocessorSource::~ExternalPreprocessorSource() { } -Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, +Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts, DiagnosticsEngine &diags, LangOptions &opts, SourceManager &SM, HeaderSearch &Headers, ModuleLoader &TheModuleLoader, Modified: cfe/trunk/unittests/Basic/SourceManagerTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/SourceManagerTest.cpp?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/unittests/Basic/SourceManagerTest.cpp (original) +++ cfe/trunk/unittests/Basic/SourceManagerTest.cpp Thu Jan 5 13:11:36 2017 @@ -80,8 +80,8 @@ TEST_F(SourceManagerTest, isBeforeInTran VoidModuleLoader ModLoader; HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, &*Target); - Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr, - HeaderInfo, ModLoader, + Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, + SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); @@ -200,8 +200,8 @@ TEST_F(SourceManagerTest, getMacroArgExp VoidModuleLoader ModLoader; HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, &*Target); - Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr, - HeaderInfo, ModLoader, + Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, + SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); @@ -300,8 +300,8 @@ TEST_F(SourceManagerTest, isBeforeInTran VoidModuleLoader ModLoader; HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, &*Target); - Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr, - HeaderInfo, ModLoader, + Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, + SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); Modified: cfe/trunk/unittests/Lex/LexerTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/unittests/Lex/LexerTest.cpp (original) +++ cfe/trunk/unittests/Lex/LexerTest.cpp Thu Jan 5 13:11:36 2017 @@ -66,8 +66,8 @@ protected: VoidModuleLoader ModLoader; HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, Target.get()); - Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr, - HeaderInfo, ModLoader, /*IILookup =*/nullptr, + Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, + SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); PP.EnterMainSourceFile(); Modified: cfe/trunk/unittests/Lex/PPCallbacksTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPCallbacksTest.cpp?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/unittests/Lex/PPCallbacksTest.cpp (original) +++ cfe/trunk/unittests/Lex/PPCallbacksTest.cpp Thu Jan 5 13:11:36 2017 @@ -167,8 +167,8 @@ protected: Target.get()); AddFakeHeader(HeaderInfo, HeaderPath, SystemHeader); - IntrusiveRefCntPtr<PreprocessorOptions> PPOpts = new PreprocessorOptions(); - Preprocessor PP(PPOpts, Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader, + Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, + SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); @@ -202,8 +202,9 @@ protected: HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, OpenCLLangOpts, Target.get()); - Preprocessor PP(new PreprocessorOptions(), Diags, OpenCLLangOpts, SourceMgr, - HeaderInfo, ModLoader, /*IILookup =*/nullptr, + Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, + OpenCLLangOpts, SourceMgr, HeaderInfo, ModLoader, + /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); Modified: cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp?rev=291160&r1=291159&r2=291160&view=diff ============================================================================== --- cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp (original) +++ cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp Thu Jan 5 13:11:36 2017 @@ -95,8 +95,8 @@ TEST_F(PPConditionalDirectiveRecordTest, VoidModuleLoader ModLoader; HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, Target.get()); - Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, SourceMgr, - HeaderInfo, ModLoader, + Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, + SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits