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);
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;
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;
/// 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,
/// \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;
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;
/// 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();
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)) {
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);
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();
// 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)) {
}
}
-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),
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),
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),
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),