diff options
-rw-r--r-- | clang/include/clang/Frontend/ASTUnit.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Frontend/CompilerInstance.h | 3 | ||||
-rw-r--r-- | clang/include/clang/Frontend/CompilerInvocation.h | 5 | ||||
-rw-r--r-- | clang/include/clang/Lex/HeaderSearch.h | 4 | ||||
-rw-r--r-- | clang/include/clang/Lex/HeaderSearchOptions.h | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Basic/SourceManagerTest.cpp | 12 | ||||
-rw-r--r-- | clang/unittests/Lex/LexerTest.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Lex/PPCallbacksTest.cpp | 9 | ||||
-rw-r--r-- | clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp | 4 |
12 files changed, 30 insertions, 27 deletions
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index 8823db65eec..b1cdb46d505 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -89,7 +89,7 @@ private: std::shared_ptr<Preprocessor> PP; IntrusiveRefCntPtr<ASTContext> Ctx; std::shared_ptr<TargetOptions> TargetOpts; - IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts; + std::shared_ptr<HeaderSearchOptions> HSOpts; IntrusiveRefCntPtr<ASTReader> Reader; bool HadModuleLoaderFatalFailure; diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 1d80c30e628..3ebbc61515c 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -288,6 +288,9 @@ public: const HeaderSearchOptions &getHeaderSearchOpts() const { return Invocation->getHeaderSearchOpts(); } + std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() const { + return Invocation->getHeaderSearchOptsPtr(); + } LangOptions &getLangOpts() { return *Invocation->getLangOpts(); diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h index 15a31327c56..cef7f73ecaa 100644 --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -65,7 +65,7 @@ public: IntrusiveRefCntPtr<DiagnosticOptions> DiagnosticOpts; /// Options controlling the \#include directive. - IntrusiveRefCntPtr<HeaderSearchOptions> HeaderSearchOpts; + std::shared_ptr<HeaderSearchOptions> HeaderSearchOpts; /// Options controlling the preprocessor (aside from \#include handling). std::shared_ptr<PreprocessorOptions> PreprocessorOpts; @@ -89,6 +89,9 @@ public: const HeaderSearchOptions &getHeaderSearchOpts() const { return *HeaderSearchOpts; } + std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() const { + return HeaderSearchOpts; + } std::shared_ptr<PreprocessorOptions> getPreprocessorOptsPtr() { return PreprocessorOpts; diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h index b145d7bae15..4df3e783117 100644 --- a/clang/include/clang/Lex/HeaderSearch.h +++ b/clang/include/clang/Lex/HeaderSearch.h @@ -147,7 +147,7 @@ class HeaderSearch { }; /// \brief Header-search options used to initialize this header search. - IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts; + std::shared_ptr<HeaderSearchOptions> HSOpts; DiagnosticsEngine &Diags; FileManager &FileMgr; @@ -248,7 +248,7 @@ class HeaderSearch { friend class DirectoryLookup; public: - HeaderSearch(IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts, + HeaderSearch(std::shared_ptr<HeaderSearchOptions> HSOpts, SourceManager &SourceMgr, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const TargetInfo *Target); ~HeaderSearch(); diff --git a/clang/include/clang/Lex/HeaderSearchOptions.h b/clang/include/clang/Lex/HeaderSearchOptions.h index 815b68c60e8..e9998053734 100644 --- a/clang/include/clang/Lex/HeaderSearchOptions.h +++ b/clang/include/clang/Lex/HeaderSearchOptions.h @@ -44,7 +44,7 @@ namespace frontend { /// HeaderSearchOptions - Helper class for storing options related to the /// initialization of the HeaderSearch object. -class HeaderSearchOptions : public RefCountedBase<HeaderSearchOptions> { +class HeaderSearchOptions { public: struct Entry { std::string Path; diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index ba61593a56d..d8929969e6c 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -677,7 +677,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile( AST->SourceMgr = new SourceManager(AST->getDiagnostics(), AST->getFileManager(), UserFilesAreVolatile); - AST->HSOpts = new HeaderSearchOptions(); + AST->HSOpts = std::make_shared<HeaderSearchOptions>(); AST->HSOpts->ModuleFormat = PCHContainerRdr.getFormat(); AST->HeaderInfo.reset(new HeaderSearch(AST->HSOpts, AST->getSourceManager(), diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index baf59748a3c..afcaa6e8787 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -368,11 +368,9 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { PTHMgr = PTHManager::Create(PPOpts.TokenCache, getDiagnostics()); // Create the Preprocessor. - HeaderSearch *HeaderInfo = new HeaderSearch(&getHeaderSearchOpts(), - getSourceManager(), - getDiagnostics(), - getLangOpts(), - &getTarget()); + HeaderSearch *HeaderInfo = + new HeaderSearch(getHeaderSearchOptsPtr(), getSourceManager(), + getDiagnostics(), getLangOpts(), &getTarget()); PP = std::make_shared<Preprocessor>( Invocation->getPreprocessorOptsPtr(), getDiagnostics(), getLangOpts(), getSourceManager(), *HeaderInfo, *this, PTHMgr, diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index b5228fc6c8c..fa2a76ef47c 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -54,7 +54,7 @@ HeaderFileInfo::getControllingMacro(ExternalPreprocessorSource *External) { ExternalHeaderFileInfoSource::~ExternalHeaderFileInfoSource() {} -HeaderSearch::HeaderSearch(IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts, +HeaderSearch::HeaderSearch(std::shared_ptr<HeaderSearchOptions> HSOpts, SourceManager &SourceMgr, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const TargetInfo *Target) diff --git a/clang/unittests/Basic/SourceManagerTest.cpp b/clang/unittests/Basic/SourceManagerTest.cpp index 8b7725d0981..a967b0ec7c2 100644 --- a/clang/unittests/Basic/SourceManagerTest.cpp +++ b/clang/unittests/Basic/SourceManagerTest.cpp @@ -78,8 +78,8 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnit) { SourceMgr.setMainFileID(mainFileID); VoidModuleLoader ModLoader; - HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, - &*Target); + HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr, + Diags, LangOpts, &*Target); Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, @@ -198,8 +198,8 @@ TEST_F(SourceManagerTest, getMacroArgExpandedLocation) { SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf)); VoidModuleLoader ModLoader; - HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, - &*Target); + HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr, + Diags, LangOpts, &*Target); Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, @@ -298,8 +298,8 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithMacroInInclude) { SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf)); VoidModuleLoader ModLoader; - HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, - &*Target); + HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr, + Diags, LangOpts, &*Target); Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, diff --git a/clang/unittests/Lex/LexerTest.cpp b/clang/unittests/Lex/LexerTest.cpp index 9ae1ffad371..918167bf43c 100644 --- a/clang/unittests/Lex/LexerTest.cpp +++ b/clang/unittests/Lex/LexerTest.cpp @@ -64,8 +64,8 @@ protected: SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); VoidModuleLoader ModLoader; - HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, - Target.get()); + HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr, + Diags, LangOpts, Target.get()); Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); diff --git a/clang/unittests/Lex/PPCallbacksTest.cpp b/clang/unittests/Lex/PPCallbacksTest.cpp index 34893b71f08..064abafc4a8 100644 --- a/clang/unittests/Lex/PPCallbacksTest.cpp +++ b/clang/unittests/Lex/PPCallbacksTest.cpp @@ -162,9 +162,8 @@ protected: VoidModuleLoader ModLoader; - IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts = new HeaderSearchOptions(); - HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, - Target.get()); + HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr, + Diags, LangOpts, Target.get()); AddFakeHeader(HeaderInfo, HeaderPath, SystemHeader); Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, @@ -199,8 +198,8 @@ protected: SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf))); VoidModuleLoader ModLoader; - HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, - OpenCLLangOpts, Target.get()); + HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr, + Diags, OpenCLLangOpts, Target.get()); Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, OpenCLLangOpts, SourceMgr, HeaderInfo, ModLoader, diff --git a/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp b/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp index 81cb488d63d..dccfffdb2c1 100644 --- a/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp +++ b/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp @@ -93,8 +93,8 @@ TEST_F(PPConditionalDirectiveRecordTest, PPRecAPI) { SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); VoidModuleLoader ModLoader; - HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, - Target.get()); + HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr, + Diags, LangOpts, Target.get()); Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/nullptr, |