From f6f617aeff9ad6e394ba633a30696fa311f57827 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 5 Jan 2017 18:23:18 +0000 Subject: [PATCH] Use shared_ptr instead of IntrusiveRefCntPtr for ModuleFileExtension The intrusiveness wasn't needed here, so this simplifies/clarifies the ownership model. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291150 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Frontend/CompilerInstance.h | 2 +- include/clang/Frontend/FrontendOptions.h | 2 +- include/clang/Serialization/ASTReader.h | 4 +- include/clang/Serialization/ASTWriter.h | 13 ++--- .../clang/Serialization/ModuleFileExtension.h | 2 +- lib/Frontend/ASTUnit.cpp | 2 +- lib/Frontend/ChainedIncludesSource.cpp | 2 +- lib/Frontend/CompilerInstance.cpp | 2 +- lib/Frontend/CompilerInvocation.cpp | 4 +- lib/Serialization/ASTReader.cpp | 50 +++++++++---------- lib/Serialization/ASTWriter.cpp | 13 +++-- lib/Serialization/GeneratePCH.cpp | 2 +- 12 files changed, 45 insertions(+), 53 deletions(-) diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 3f754d9998..c77dc621b0 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -653,7 +653,7 @@ public: StringRef Path, StringRef Sysroot, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, - ArrayRef> Extensions, + ArrayRef> Extensions, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex); diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h index aad397526a..9c960bb0c3 100644 --- a/include/clang/Frontend/FrontendOptions.h +++ b/include/clang/Frontend/FrontendOptions.h @@ -243,7 +243,7 @@ public: std::vector Plugins; /// The list of module file extensions. - std::vector> ModuleFileExtensions; + std::vector> ModuleFileExtensions; /// \brief The list of module map files to load before processing the input. std::vector ModuleMapFiles; diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 5230e2ae00..7c2c8948d0 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -414,7 +414,7 @@ private: IdentifierResolver DummyIdResolver; /// A mapping from extension block names to module file extensions. - llvm::StringMap> ModuleFileExtensions; + llvm::StringMap> ModuleFileExtensions; /// \brief A timer used to track the time spent deserializing. std::unique_ptr ReadTimer; @@ -1366,7 +1366,7 @@ public: /// deserializing. ASTReader(Preprocessor &PP, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, - ArrayRef> Extensions, + ArrayRef> Extensions, StringRef isysroot = "", bool DisableValidation = false, bool AllowASTWithCompilerErrors = false, bool AllowConfigurationMismatch = false, diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index 1469555ec2..ce3178771a 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -498,7 +498,7 @@ public: /// \brief Create a new precompiled header writer that outputs to /// the given bitstream. ASTWriter(llvm::BitstreamWriter &Stream, - ArrayRef> Extensions, + ArrayRef> Extensions, bool IncludeTimestamps = true); ~ASTWriter() override; @@ -934,13 +934,10 @@ protected: SmallVectorImpl &getPCH() const { return Buffer->Data; } public: - PCHGenerator( - const Preprocessor &PP, StringRef OutputFile, - StringRef isysroot, - std::shared_ptr Buffer, - ArrayRef> Extensions, - bool AllowASTWithErrors = false, - bool IncludeTimestamps = true); + PCHGenerator(const Preprocessor &PP, StringRef OutputFile, StringRef isysroot, + std::shared_ptr Buffer, + ArrayRef> Extensions, + bool AllowASTWithErrors = false, bool IncludeTimestamps = true); ~PCHGenerator() override; void InitializeSema(Sema &S) override { SemaPtr = &S; } void HandleTranslationUnit(ASTContext &Ctx) override; diff --git a/include/clang/Serialization/ModuleFileExtension.h b/include/clang/Serialization/ModuleFileExtension.h index ba2e2fd0d9..f7bdcec598 100644 --- a/include/clang/Serialization/ModuleFileExtension.h +++ b/include/clang/Serialization/ModuleFileExtension.h @@ -60,7 +60,7 @@ class ModuleFileExtensionWriter; /// compiled module files (.pcm) and precompiled headers (.pch) via a /// custom writer that can then be accessed via a custom reader when /// the module file or precompiled header is loaded. -class ModuleFileExtension : public llvm::RefCountedBase { +class ModuleFileExtension { public: virtual ~ModuleFileExtension(); diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 32ce966f79..5a88bc4083 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -926,7 +926,7 @@ public: const Preprocessor &PP, StringRef isysroot, std::unique_ptr Out) : PCHGenerator(PP, "", isysroot, std::make_shared(), - ArrayRef>(), + ArrayRef>(), /*AllowASTWithErrors=*/true), Unit(Unit), Hash(Unit.getCurrentTopLevelHashValue()), Action(Action), Out(std::move(Out)) { diff --git a/lib/Frontend/ChainedIncludesSource.cpp b/lib/Frontend/ChainedIncludesSource.cpp index c5b77ee90e..b621facf40 100644 --- a/lib/Frontend/ChainedIncludesSource.cpp +++ b/lib/Frontend/ChainedIncludesSource.cpp @@ -159,7 +159,7 @@ IntrusiveRefCntPtr clang::createChainedIncludesSource( Clang->createASTContext(); auto Buffer = std::make_shared(); - ArrayRef> Extensions; + ArrayRef> Extensions; auto consumer = llvm::make_unique( Clang->getPreprocessor(), "-", /*isysroot=*/"", Buffer, Extensions, /*AllowASTWithErrors=*/true); diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index ccddd14f0f..fea444715d 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -498,7 +498,7 @@ IntrusiveRefCntPtr CompilerInstance::createPCHExternalASTSource( StringRef Path, StringRef Sysroot, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, - ArrayRef> Extensions, + ArrayRef> Extensions, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex) { HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts(); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index ca4a7655a3..86d58a2431 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1214,8 +1214,8 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, // Add the testing module file extension. Opts.ModuleFileExtensions.push_back( - new TestModuleFileExtension(BlockName, MajorVersion, MinorVersion, - Hashed, UserInfo)); + std::make_shared( + BlockName, MajorVersion, MinorVersion, Hashed, UserInfo)); } if (const Arg *A = Args.getLastArg(OPT_code_completion_at)) { diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index fe2c53b77e..09bf42d2ec 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -8890,37 +8890,33 @@ void ASTReader::pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name) { } } -ASTReader::ASTReader( - Preprocessor &PP, ASTContext &Context, - const PCHContainerReader &PCHContainerRdr, - ArrayRef> Extensions, - StringRef isysroot, bool DisableValidation, - bool AllowASTWithCompilerErrors, - bool AllowConfigurationMismatch, bool ValidateSystemInputs, - bool UseGlobalIndex, - std::unique_ptr ReadTimer) - : Listener(DisableValidation ? - cast(new SimpleASTReaderListener(PP)) : - cast(new PCHValidator(PP, *this))), - DeserializationListener(nullptr), - OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()), - FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr), - Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context), - Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerRdr), - DummyIdResolver(PP), - ReadTimer(std::move(ReadTimer)), - PragmaMSStructState(-1), - PragmaMSPointersToMembersState(-1), - isysroot(isysroot), DisableValidation(DisableValidation), +ASTReader::ASTReader(Preprocessor &PP, ASTContext &Context, + const PCHContainerReader &PCHContainerRdr, + ArrayRef> Extensions, + StringRef isysroot, bool DisableValidation, + bool AllowASTWithCompilerErrors, + bool AllowConfigurationMismatch, bool ValidateSystemInputs, + bool UseGlobalIndex, + std::unique_ptr ReadTimer) + : Listener(DisableValidation + ? cast(new SimpleASTReaderListener(PP)) + : cast(new PCHValidator(PP, *this))), + DeserializationListener(nullptr), OwnsDeserializationListener(false), + SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()), + PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), + SemaObj(nullptr), PP(PP), Context(Context), Consumer(nullptr), + ModuleMgr(PP.getFileManager(), PCHContainerRdr), DummyIdResolver(PP), + ReadTimer(std::move(ReadTimer)), PragmaMSStructState(-1), + PragmaMSPointersToMembersState(-1), isysroot(isysroot), + DisableValidation(DisableValidation), AllowASTWithCompilerErrors(AllowASTWithCompilerErrors), AllowConfigurationMismatch(AllowConfigurationMismatch), ValidateSystemInputs(ValidateSystemInputs), UseGlobalIndex(UseGlobalIndex), TriedLoadingGlobalIndex(false), - ProcessingUpdateRecords(false), - CurrSwitchCaseStmts(&SwitchCaseStmts), NumSLocEntriesRead(0), - TotalNumSLocEntries(0), NumStatementsRead(0), TotalNumStatements(0), - NumMacrosRead(0), TotalNumMacros(0), NumIdentifierLookups(0), - NumIdentifierLookupHits(0), NumSelectorsRead(0), + ProcessingUpdateRecords(false), CurrSwitchCaseStmts(&SwitchCaseStmts), + NumSLocEntriesRead(0), TotalNumSLocEntries(0), NumStatementsRead(0), + TotalNumStatements(0), NumMacrosRead(0), TotalNumMacros(0), + NumIdentifierLookups(0), NumIdentifierLookupHits(0), NumSelectorsRead(0), NumMethodPoolEntriesRead(0), NumMethodPoolLookups(0), NumMethodPoolHits(0), NumMethodPoolTableLookups(0), NumMethodPoolTableHits(0), TotalNumMethodPoolEntries(0), diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 708695b649..6bdb381b1e 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -4221,10 +4221,9 @@ void ASTWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) { SelectorOffsets[ID - FirstSelectorID] = Offset; } -ASTWriter::ASTWriter( - llvm::BitstreamWriter &Stream, - ArrayRef> Extensions, - bool IncludeTimestamps) +ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream, + ArrayRef> Extensions, + bool IncludeTimestamps) : Stream(Stream), Context(nullptr), PP(nullptr), Chain(nullptr), WritingModule(nullptr), IncludeTimestamps(IncludeTimestamps), WritingAST(false), DoneWritingDeclsAndTypes(false), @@ -4235,9 +4234,9 @@ ASTWriter::ASTWriter( NextMacroID(FirstMacroID), FirstSubmoduleID(NUM_PREDEF_SUBMODULE_IDS), NextSubmoduleID(FirstSubmoduleID), FirstSelectorID(NUM_PREDEF_SELECTOR_IDS), NextSelectorID(FirstSelectorID), - NumStatements(0), NumMacros(0), - NumLexicalDeclContexts(0), NumVisibleDeclContexts(0), - TypeExtQualAbbrev(0), TypeFunctionProtoAbbrev(0), DeclParmVarAbbrev(0), + NumStatements(0), NumMacros(0), NumLexicalDeclContexts(0), + NumVisibleDeclContexts(0), TypeExtQualAbbrev(0), + TypeFunctionProtoAbbrev(0), DeclParmVarAbbrev(0), DeclContextLexicalAbbrev(0), DeclContextVisibleLookupAbbrev(0), UpdateVisibleAbbrev(0), DeclRecordAbbrev(0), DeclTypedefAbbrev(0), DeclVarAbbrev(0), DeclFieldAbbrev(0), DeclEnumAbbrev(0), diff --git a/lib/Serialization/GeneratePCH.cpp b/lib/Serialization/GeneratePCH.cpp index e1765dafd9..7f1b75055b 100644 --- a/lib/Serialization/GeneratePCH.cpp +++ b/lib/Serialization/GeneratePCH.cpp @@ -24,7 +24,7 @@ using namespace clang; PCHGenerator::PCHGenerator( const Preprocessor &PP, StringRef OutputFile, StringRef isysroot, std::shared_ptr Buffer, - ArrayRef> Extensions, + ArrayRef> Extensions, bool AllowASTWithErrors, bool IncludeTimestamps) : PP(PP), OutputFile(OutputFile), isysroot(isysroot.str()), SemaPtr(nullptr), Buffer(Buffer), Stream(Buffer->Data), -- 2.40.0