Use shared_ptr instead of IntrusiveRefCntPtr for ModuleFileExtension

The intrusiveness wasn't needed here, so this simplifies/clarifies the
ownership model.

llvm-svn: 291150
This commit is contained in:
David Blaikie 2017-01-05 18:23:18 +00:00
parent b01e844241
commit 61137e1a50
12 changed files with 45 additions and 53 deletions

View File

@ -653,7 +653,7 @@ public:
StringRef Path, StringRef Sysroot, bool DisablePCHValidation,
bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context,
const PCHContainerReader &PCHContainerRdr,
ArrayRef<IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
void *DeserializationListener, bool OwnDeserializationListener,
bool Preamble, bool UseGlobalModuleIndex);

View File

@ -243,7 +243,7 @@ public:
std::vector<std::string> Plugins;
/// The list of module file extensions.
std::vector<IntrusiveRefCntPtr<ModuleFileExtension>> ModuleFileExtensions;
std::vector<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
/// \brief The list of module map files to load before processing the input.
std::vector<std::string> ModuleMapFiles;

View File

@ -414,7 +414,7 @@ private:
IdentifierResolver DummyIdResolver;
/// A mapping from extension block names to module file extensions.
llvm::StringMap<IntrusiveRefCntPtr<ModuleFileExtension>> ModuleFileExtensions;
llvm::StringMap<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
/// \brief A timer used to track the time spent deserializing.
std::unique_ptr<llvm::Timer> ReadTimer;
@ -1366,7 +1366,7 @@ public:
/// deserializing.
ASTReader(Preprocessor &PP, ASTContext &Context,
const PCHContainerReader &PCHContainerRdr,
ArrayRef<IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
StringRef isysroot = "", bool DisableValidation = false,
bool AllowASTWithCompilerErrors = false,
bool AllowConfigurationMismatch = false,

View File

@ -498,7 +498,7 @@ public:
/// \brief Create a new precompiled header writer that outputs to
/// the given bitstream.
ASTWriter(llvm::BitstreamWriter &Stream,
ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
bool IncludeTimestamps = true);
~ASTWriter() override;
@ -934,13 +934,10 @@ protected:
SmallVectorImpl<char> &getPCH() const { return Buffer->Data; }
public:
PCHGenerator(
const Preprocessor &PP, StringRef OutputFile,
StringRef isysroot,
std::shared_ptr<PCHBuffer> Buffer,
ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
bool AllowASTWithErrors = false,
bool IncludeTimestamps = true);
PCHGenerator(const Preprocessor &PP, StringRef OutputFile, StringRef isysroot,
std::shared_ptr<PCHBuffer> Buffer,
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
bool AllowASTWithErrors = false, bool IncludeTimestamps = true);
~PCHGenerator() override;
void InitializeSema(Sema &S) override { SemaPtr = &S; }
void HandleTranslationUnit(ASTContext &Ctx) override;

View File

@ -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<ModuleFileExtension> {
class ModuleFileExtension {
public:
virtual ~ModuleFileExtension();

View File

@ -926,7 +926,7 @@ public:
const Preprocessor &PP, StringRef isysroot,
std::unique_ptr<raw_ostream> Out)
: PCHGenerator(PP, "", isysroot, std::make_shared<PCHBuffer>(),
ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>>(),
ArrayRef<std::shared_ptr<ModuleFileExtension>>(),
/*AllowASTWithErrors=*/true),
Unit(Unit), Hash(Unit.getCurrentTopLevelHashValue()), Action(Action),
Out(std::move(Out)) {

View File

@ -159,7 +159,7 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(
Clang->createASTContext();
auto Buffer = std::make_shared<PCHBuffer>();
ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions;
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions;
auto consumer = llvm::make_unique<PCHGenerator>(
Clang->getPreprocessor(), "-", /*isysroot=*/"", Buffer,
Extensions, /*AllowASTWithErrors=*/true);

View File

@ -498,7 +498,7 @@ IntrusiveRefCntPtr<ASTReader> CompilerInstance::createPCHExternalASTSource(
StringRef Path, StringRef Sysroot, bool DisablePCHValidation,
bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context,
const PCHContainerReader &PCHContainerRdr,
ArrayRef<IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
void *DeserializationListener, bool OwnDeserializationListener,
bool Preamble, bool UseGlobalModuleIndex) {
HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();

View File

@ -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<TestModuleFileExtension>(
BlockName, MajorVersion, MinorVersion, Hashed, UserInfo));
}
if (const Arg *A = Args.getLastArg(OPT_code_completion_at)) {

View File

@ -8890,37 +8890,33 @@ void ASTReader::pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name) {
}
}
ASTReader::ASTReader(
Preprocessor &PP, ASTContext &Context,
const PCHContainerReader &PCHContainerRdr,
ArrayRef<IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
StringRef isysroot, bool DisableValidation,
bool AllowASTWithCompilerErrors,
bool AllowConfigurationMismatch, bool ValidateSystemInputs,
bool UseGlobalIndex,
std::unique_ptr<llvm::Timer> ReadTimer)
: Listener(DisableValidation ?
cast<ASTReaderListener>(new SimpleASTReaderListener(PP)) :
cast<ASTReaderListener>(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<std::shared_ptr<ModuleFileExtension>> Extensions,
StringRef isysroot, bool DisableValidation,
bool AllowASTWithCompilerErrors,
bool AllowConfigurationMismatch, bool ValidateSystemInputs,
bool UseGlobalIndex,
std::unique_ptr<llvm::Timer> ReadTimer)
: Listener(DisableValidation
? cast<ASTReaderListener>(new SimpleASTReaderListener(PP))
: cast<ASTReaderListener>(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),

View File

@ -4221,10 +4221,9 @@ void ASTWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) {
SelectorOffsets[ID - FirstSelectorID] = Offset;
}
ASTWriter::ASTWriter(
llvm::BitstreamWriter &Stream,
ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
bool IncludeTimestamps)
ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream,
ArrayRef<std::shared_ptr<ModuleFileExtension>> 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),

View File

@ -24,7 +24,7 @@ using namespace clang;
PCHGenerator::PCHGenerator(
const Preprocessor &PP, StringRef OutputFile, StringRef isysroot,
std::shared_ptr<PCHBuffer> Buffer,
ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
bool AllowASTWithErrors, bool IncludeTimestamps)
: PP(PP), OutputFile(OutputFile), isysroot(isysroot.str()),
SemaPtr(nullptr), Buffer(Buffer), Stream(Buffer->Data),