Simplify ASTReader ctor by using in-class initializers (NSDMIs to the rest of you) for many member variables

llvm-svn: 291154
This commit is contained in:
David Blaikie 2017-01-05 18:45:43 +00:00
parent 430d34fc14
commit 9d7c1ba5cf
2 changed files with 33 additions and 47 deletions

View File

@ -384,8 +384,8 @@ private:
std::unique_ptr<ASTReaderListener> Listener; std::unique_ptr<ASTReaderListener> Listener;
/// \brief The receiver of deserialization events. /// \brief The receiver of deserialization events.
ASTDeserializationListener *DeserializationListener; ASTDeserializationListener *DeserializationListener = nullptr;
bool OwnsDeserializationListener; bool OwnsDeserializationListener = false;
SourceManager &SourceMgr; SourceManager &SourceMgr;
FileManager &FileMgr; FileManager &FileMgr;
@ -394,7 +394,7 @@ private:
/// \brief The semantic analysis object that will be processing the /// \brief The semantic analysis object that will be processing the
/// AST files and the translation unit that uses it. /// AST files and the translation unit that uses it.
Sema *SemaObj; Sema *SemaObj = nullptr;
/// \brief The preprocessor that will be loading the source file. /// \brief The preprocessor that will be loading the source file.
Preprocessor &PP; Preprocessor &PP;
@ -403,7 +403,7 @@ private:
ASTContext &Context; ASTContext &Context;
/// \brief The AST consumer. /// \brief The AST consumer.
ASTConsumer *Consumer; ASTConsumer *Consumer = nullptr;
/// \brief The module manager which manages modules and their dependencies /// \brief The module manager which manages modules and their dependencies
ModuleManager ModuleMgr; ModuleManager ModuleMgr;
@ -802,10 +802,10 @@ private:
SourceLocation OptimizeOffPragmaLocation; SourceLocation OptimizeOffPragmaLocation;
/// \brief The PragmaMSStructKind pragma ms_struct state if set, or -1. /// \brief The PragmaMSStructKind pragma ms_struct state if set, or -1.
int PragmaMSStructState; int PragmaMSStructState = -1;
/// \brief The PragmaMSPointersToMembersKind pragma pointers_to_members state. /// \brief The PragmaMSPointersToMembersKind pragma pointers_to_members state.
int PragmaMSPointersToMembersState; int PragmaMSPointersToMembersState = -1;
SourceLocation PointersToMembersPragmaLocation; SourceLocation PointersToMembersPragmaLocation;
/// \brief The OpenCL extension settings. /// \brief The OpenCL extension settings.
@ -870,10 +870,10 @@ private:
bool UseGlobalIndex; bool UseGlobalIndex;
/// \brief Whether we have tried loading the global module index yet. /// \brief Whether we have tried loading the global module index yet.
bool TriedLoadingGlobalIndex; bool TriedLoadingGlobalIndex = false;
///\brief Whether we are currently processing update records. ///\brief Whether we are currently processing update records.
bool ProcessingUpdateRecords; bool ProcessingUpdateRecords = false;
typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy; typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy;
/// \brief Mapping from switch-case IDs in the chain to switch-case statements /// \brief Mapping from switch-case IDs in the chain to switch-case statements
@ -886,73 +886,73 @@ private:
/// \brief The number of source location entries de-serialized from /// \brief The number of source location entries de-serialized from
/// the PCH file. /// the PCH file.
unsigned NumSLocEntriesRead; unsigned NumSLocEntriesRead = 0;
/// \brief The number of source location entries in the chain. /// \brief The number of source location entries in the chain.
unsigned TotalNumSLocEntries; unsigned TotalNumSLocEntries = 0;
/// \brief The number of statements (and expressions) de-serialized /// \brief The number of statements (and expressions) de-serialized
/// from the chain. /// from the chain.
unsigned NumStatementsRead; unsigned NumStatementsRead = 0;
/// \brief The total number of statements (and expressions) stored /// \brief The total number of statements (and expressions) stored
/// in the chain. /// in the chain.
unsigned TotalNumStatements; unsigned TotalNumStatements = 0;
/// \brief The number of macros de-serialized from the chain. /// \brief The number of macros de-serialized from the chain.
unsigned NumMacrosRead; unsigned NumMacrosRead = 0;
/// \brief The total number of macros stored in the chain. /// \brief The total number of macros stored in the chain.
unsigned TotalNumMacros; unsigned TotalNumMacros = 0;
/// \brief The number of lookups into identifier tables. /// \brief The number of lookups into identifier tables.
unsigned NumIdentifierLookups; unsigned NumIdentifierLookups = 0;
/// \brief The number of lookups into identifier tables that succeed. /// \brief The number of lookups into identifier tables that succeed.
unsigned NumIdentifierLookupHits; unsigned NumIdentifierLookupHits = 0;
/// \brief The number of selectors that have been read. /// \brief The number of selectors that have been read.
unsigned NumSelectorsRead; unsigned NumSelectorsRead = 0;
/// \brief The number of method pool entries that have been read. /// \brief The number of method pool entries that have been read.
unsigned NumMethodPoolEntriesRead; unsigned NumMethodPoolEntriesRead = 0;
/// \brief The number of times we have looked up a selector in the method /// \brief The number of times we have looked up a selector in the method
/// pool. /// pool.
unsigned NumMethodPoolLookups; unsigned NumMethodPoolLookups = 0;
/// \brief The number of times we have looked up a selector in the method /// \brief The number of times we have looked up a selector in the method
/// pool and found something. /// pool and found something.
unsigned NumMethodPoolHits; unsigned NumMethodPoolHits = 0;
/// \brief The number of times we have looked up a selector in the method /// \brief The number of times we have looked up a selector in the method
/// pool within a specific module. /// pool within a specific module.
unsigned NumMethodPoolTableLookups; unsigned NumMethodPoolTableLookups = 0;
/// \brief The number of times we have looked up a selector in the method /// \brief The number of times we have looked up a selector in the method
/// pool within a specific module and found something. /// pool within a specific module and found something.
unsigned NumMethodPoolTableHits; unsigned NumMethodPoolTableHits = 0;
/// \brief The total number of method pool entries in the selector table. /// \brief The total number of method pool entries in the selector table.
unsigned TotalNumMethodPoolEntries; unsigned TotalNumMethodPoolEntries = 0;
/// Number of lexical decl contexts read/total. /// Number of lexical decl contexts read/total.
unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts; unsigned NumLexicalDeclContextsRead = 0, TotalLexicalDeclContexts = 0;
/// Number of visible decl contexts read/total. /// Number of visible decl contexts read/total.
unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts; unsigned NumVisibleDeclContextsRead = 0, TotalVisibleDeclContexts = 0;
/// Total size of modules, in bits, currently loaded /// Total size of modules, in bits, currently loaded
uint64_t TotalModulesSizeInBits; uint64_t TotalModulesSizeInBits = 0;
/// \brief Number of Decl/types that are currently deserializing. /// \brief Number of Decl/types that are currently deserializing.
unsigned NumCurrentElementsDeserializing; unsigned NumCurrentElementsDeserializing = 0;
/// \brief Set true while we are in the process of passing deserialized /// \brief Set true while we are in the process of passing deserialized
/// "interesting" decls to consumer inside FinishedDeserializing(). /// "interesting" decls to consumer inside FinishedDeserializing().
/// This is used as a guard to avoid recursively repeating the process of /// This is used as a guard to avoid recursively repeating the process of
/// passing decls to consumer. /// passing decls to consumer.
bool PassingDeclsToConsumer; bool PassingDeclsToConsumer = false;
/// \brief The set of identifiers that were read while the AST reader was /// \brief The set of identifiers that were read while the AST reader was
/// (recursively) loading declarations. /// (recursively) loading declarations.
@ -1055,7 +1055,7 @@ private:
}; };
/// \brief What kind of records we are reading. /// \brief What kind of records we are reading.
ReadingKind ReadingKind; ReadingKind ReadingKind = Read_None;
/// \brief RAII object to change the reading kind. /// \brief RAII object to change the reading kind.
class ReadingKindTracker { class ReadingKindTracker {

View File

@ -8901,29 +8901,15 @@ ASTReader::ASTReader(Preprocessor &PP, ASTContext &Context,
: Listener(DisableValidation : Listener(DisableValidation
? cast<ASTReaderListener>(new SimpleASTReaderListener(PP)) ? cast<ASTReaderListener>(new SimpleASTReaderListener(PP))
: cast<ASTReaderListener>(new PCHValidator(PP, *this))), : cast<ASTReaderListener>(new PCHValidator(PP, *this))),
DeserializationListener(nullptr), OwnsDeserializationListener(false),
SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()), SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PP(PP),
SemaObj(nullptr), PP(PP), Context(Context), Consumer(nullptr), Context(Context), ModuleMgr(PP.getFileManager(), PCHContainerRdr),
ModuleMgr(PP.getFileManager(), PCHContainerRdr), DummyIdResolver(PP), DummyIdResolver(PP), ReadTimer(std::move(ReadTimer)), isysroot(isysroot),
ReadTimer(std::move(ReadTimer)), PragmaMSStructState(-1),
PragmaMSPointersToMembersState(-1), isysroot(isysroot),
DisableValidation(DisableValidation), DisableValidation(DisableValidation),
AllowASTWithCompilerErrors(AllowASTWithCompilerErrors), AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
AllowConfigurationMismatch(AllowConfigurationMismatch), AllowConfigurationMismatch(AllowConfigurationMismatch),
ValidateSystemInputs(ValidateSystemInputs), ValidateSystemInputs(ValidateSystemInputs),
UseGlobalIndex(UseGlobalIndex), TriedLoadingGlobalIndex(false), UseGlobalIndex(UseGlobalIndex), CurrSwitchCaseStmts(&SwitchCaseStmts) {
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),
NumLexicalDeclContextsRead(0), TotalLexicalDeclContexts(0),
NumVisibleDeclContextsRead(0), TotalVisibleDeclContexts(0),
TotalModulesSizeInBits(0), NumCurrentElementsDeserializing(0),
PassingDeclsToConsumer(false), ReadingKind(Read_None) {
SourceMgr.setExternalSLocEntrySource(this); SourceMgr.setExternalSLocEntrySource(this);
for (const auto &Ext : Extensions) { for (const auto &Ext : Extensions) {