Move PreprocessorOptions to std::shared_ptr from IntrusiveRefCntPtr

llvm-svn: 291160
This commit is contained in:
David Blaikie 2017-01-05 19:11:36 +00:00
parent f95113dacf
commit e304168853
10 changed files with 34 additions and 30 deletions

View File

@ -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;

View File

@ -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 RefCountedBase<Preprocessor> {
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);

View File

@ -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;

View File

@ -683,7 +683,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
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::LoadFromASTFile(
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(),

View File

@ -370,8 +370,9 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
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());

View File

@ -68,7 +68,7 @@ LLVM_INSTANTIATE_REGISTRY(PragmaHandlerRegistry)
//===----------------------------------------------------------------------===//
ExternalPreprocessorSource::~ExternalPreprocessorSource() { }
Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts,
Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
DiagnosticsEngine &diags, LangOptions &opts,
SourceManager &SM, HeaderSearch &Headers,
ModuleLoader &TheModuleLoader,

View File

@ -80,8 +80,8 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
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, getMacroArgExpandedLocation) {
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, isBeforeInTranslationUnitWithMacroInInclude) {
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);

View File

@ -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();

View File

@ -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);

View File

@ -95,8 +95,8 @@ TEST_F(PPConditionalDirectiveRecordTest, PPRecAPI) {
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);