Author: vedantk Date: Fri Apr 13 18:40:48 2018 New Revision: 330080 URL: http://llvm.org/viewvc/llvm-project?rev=330080&view=rev Log: Revert "[Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC)."
This reverts commit r330068. It breaks the lldb bots due to assertion failures (more details on cfe-commits). http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/ http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/6341/ stderr: Assertion failed: (M && "imported decl from no module file"), function loadPendingDeclChain, file /Users/vsk/src/llvm.org-lldbsan/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp, line 3861. Modified: cfe/trunk/lib/Serialization/ASTReader.cpp Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=330080&r1=330079&r2=330080&view=diff ============================================================================== --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Apr 13 18:40:48 2018 @@ -71,7 +71,6 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" #include "clang/Lex/Token.h" -#include "clang/Sema/DeclSpec.h" #include "clang/Sema/ObjCMethodList.h" #include "clang/Sema/Scope.h" #include "clang/Sema/Sema.h" @@ -98,11 +97,11 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/ADT/iterator_range.h" -#include "llvm/Bitcode/BitCodes.h" #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Compression.h" @@ -134,8 +133,8 @@ #include <vector> using namespace clang; -using namespace serialization; -using namespace reader; +using namespace clang::serialization; +using namespace clang::serialization::reader; using llvm::BitstreamCursor; //===----------------------------------------------------------------------===// @@ -464,7 +463,7 @@ static bool checkDiagnosticGroupMappings // errors because of options like -Werror. DiagnosticsEngine *MappingSources[] = { &Diags, &StoredDiags }; - for (auto *MappingSource : MappingSources) { + for (DiagnosticsEngine *MappingSource : MappingSources) { for (auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) { diag::kind DiagID = DiagIDMappingPair.first; Level CurLevel = Diags.getDiagnosticLevel(DiagID, SourceLocation()); @@ -582,9 +581,9 @@ static void collectMacroDefinitions(const PreprocessorOptions &PPOpts, MacroDefinitionsMap &Macros, SmallVectorImpl<StringRef> *MacroNames = nullptr) { - for (const auto &I : PPOpts.Macros) { - StringRef Macro = I.first; - bool IsUndef = I.second; + for (unsigned I = 0, N = PPOpts.Macros.size(); I != N; ++I) { + StringRef Macro = PPOpts.Macros[I].first; + bool IsUndef = PPOpts.Macros[I].second; std::pair<StringRef, StringRef> MacroPair = Macro.split('='); StringRef MacroName = MacroPair.first; @@ -635,8 +634,9 @@ static bool checkPreprocessorOptions(con SmallVector<StringRef, 4> ExistingMacroNames; collectMacroDefinitions(ExistingPPOpts, ExistingMacros, &ExistingMacroNames); - for (auto MacroName : ExistingMacroNames) { + for (unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) { // Dig out the macro definition in the existing preprocessor options. + StringRef MacroName = ExistingMacroNames[I]; std::pair<StringRef, bool> Existing = ExistingMacros[MacroName]; // Check whether we know anything about this macro name or not. @@ -702,7 +702,8 @@ static bool checkPreprocessorOptions(con } // Compute the #include and #include_macros lines we need. - for (const auto &File : ExistingPPOpts.Includes) { + for (unsigned I = 0, N = ExistingPPOpts.Includes.size(); I != N; ++I) { + StringRef File = ExistingPPOpts.Includes[I]; if (File == ExistingPPOpts.ImplicitPCHInclude) continue; @@ -715,7 +716,8 @@ static bool checkPreprocessorOptions(con SuggestedPredefines += "\"\n"; } - for (const auto &File : ExistingPPOpts.MacroIncludes) { + for (unsigned I = 0, N = ExistingPPOpts.MacroIncludes.size(); I != N; ++I) { + StringRef File = ExistingPPOpts.MacroIncludes[I]; if (std::find(PPOpts.MacroIncludes.begin(), PPOpts.MacroIncludes.end(), File) != PPOpts.MacroIncludes.end()) @@ -853,14 +855,14 @@ ASTSelectorLookupTrait::ReadData(Selecto // Load instance methods for (unsigned I = 0; I != NumInstanceMethods; ++I) { - if (auto *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>( + if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>( F, endian::readNext<uint32_t, little, unaligned>(d))) Result.Instance.push_back(Method); } // Load factory methods for (unsigned I = 0; I != NumFactoryMethods; ++I) { - if (auto *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>( + if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>( F, endian::readNext<uint32_t, little, unaligned>(d))) Result.Factory.push_back(Method); } @@ -1085,7 +1087,7 @@ ASTDeclContextNameLookupTrait::internal_ ASTDeclContextNameLookupTrait::ReadKey(const unsigned char *d, unsigned) { using namespace llvm::support; - auto Kind = static_cast<DeclarationName::NameKind>(*d++); + auto Kind = (DeclarationName::NameKind)*d++; uint64_t Data; switch (Kind) { case DeclarationName::Identifier: @@ -1244,7 +1246,8 @@ bool ASTReader::ParseLineTable(ModuleFil unsigned FileOffset = Record[Idx++]; unsigned LineNo = Record[Idx++]; int FilenameID = FileIDs[Record[Idx++]]; - auto FileKind = static_cast<SrcMgr::CharacteristicKind>(Record[Idx++]); + SrcMgr::CharacteristicKind FileKind + = (SrcMgr::CharacteristicKind)Record[Idx++]; unsigned IncludeOffset = Record[Idx++]; Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID, FileKind, IncludeOffset)); @@ -1424,11 +1427,12 @@ bool ASTReader::ReadSLocEntry(int ID) { // This is the module's main file. IncludeLoc = getImportLocation(F); } - auto FileCharacter = static_cast<SrcMgr::CharacteristicKind>(Record[2]); + SrcMgr::CharacteristicKind + FileCharacter = (SrcMgr::CharacteristicKind)Record[2]; FileID FID = SourceMgr.createFileID(File, IncludeLoc, FileCharacter, ID, BaseOffset + Record[0]); - auto &FileInfo = - const_cast<SrcMgr::FileInfo &>(SourceMgr.getSLocEntry(FID).getFile()); + SrcMgr::FileInfo &FileInfo = + const_cast<SrcMgr::FileInfo&>(SourceMgr.getSLocEntry(FID).getFile()); FileInfo.NumCreatedFIDs = Record[5]; if (Record[3]) FileInfo.setHasLineDirectives(); @@ -1458,7 +1462,8 @@ bool ASTReader::ReadSLocEntry(int ID) { case SM_SLOC_BUFFER_ENTRY: { const char *Name = Blob.data(); unsigned Offset = Record[0]; - auto FileCharacter = static_cast<SrcMgr::CharacteristicKind>(Record[2]); + SrcMgr::CharacteristicKind + FileCharacter = (SrcMgr::CharacteristicKind)Record[2]; SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]); if (IncludeLoc.isInvalid() && F->isModule()) { IncludeLoc = getImportLocation(F); @@ -1587,8 +1592,8 @@ MacroInfo *ASTReader::ReadMacroRecord(Mo // Read a record. Record.clear(); - auto RecType = static_cast<PreprocessorRecordTypes>( - Stream.readRecord(Entry.ID, Record)); + PreprocessorRecordTypes RecType = + (PreprocessorRecordTypes)Stream.readRecord(Entry.ID, Record); switch (RecType) { case PP_MODULE_MACRO: case PP_MACRO_DIRECTIVE_HISTORY: @@ -1639,7 +1644,7 @@ MacroInfo *ASTReader::ReadMacroRecord(Mo PreprocessingRecord &PPRec = *PP.getPreprocessingRecord(); PreprocessingRecord::PPEntityID PPID = PPRec.getPPEntityID(GlobalID - 1, /*isLoaded=*/true); - auto *PPDef = cast_or_null<MacroDefinitionRecord>( + MacroDefinitionRecord *PPDef = cast_or_null<MacroDefinitionRecord>( PPRec.getPreprocessedEntity(PPID)); if (PPDef) PPRec.RegisterMacroDefinition(Macro, PPDef); @@ -1716,9 +1721,8 @@ std::pair<unsigned, unsigned> HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) { using namespace llvm::support; - auto KeyLen = static_cast<unsigned>( - endian::readNext<uint16_t, little, unaligned>(d)); - auto DataLen = static_cast<unsigned>(*d++); + unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little, unaligned>(d); + unsigned DataLen = (unsigned) *d++; return std::make_pair(KeyLen, DataLen); } @@ -1804,7 +1808,7 @@ void ASTReader::ReadDefinedMacros() { // Note that we are loading defined macros. Deserializing Macros(this); - for (auto &I : llvm::reverse(ModuleMgr)) { + for (ModuleFile &I : llvm::reverse(ModuleMgr)) { BitstreamCursor &MacroCursor = I.MacroCursor; // If there was no preprocessor block, skip this file. @@ -1876,8 +1880,8 @@ namespace { if (M.Generation <= PriorGeneration) return true; - auto *IdTable = - static_cast<ASTIdentifierLookupTable *>(M.IdentifierLookupTable); + ASTIdentifierLookupTable *IdTable + = (ASTIdentifierLookupTable *)M.IdentifierLookupTable; if (!IdTable) return false; @@ -1998,7 +2002,7 @@ void ASTReader::resolvePendingMacro(Iden llvm::SmallVector<ModuleMacro*, 8> Overrides; for (auto &MMR : ModuleMacros) { Overrides.clear(); - for (auto ModID : MMR.Overrides) { + for (unsigned ModID : MMR.Overrides) { Module *Mod = getSubmodule(ModID); auto *Macro = PP.getModuleMacro(Mod, II); assert(Macro && "missing definition for overridden macro"); @@ -2022,7 +2026,7 @@ void ASTReader::resolvePendingMacro(Iden while (Idx < N) { MacroDirective *MD = nullptr; SourceLocation Loc = ReadSourceLocation(M, Record, Idx); - auto K = static_cast<MacroDirective::Kind>(Record[Idx++]); + MacroDirective::Kind K = (MacroDirective::Kind)Record[Idx++]; switch (K) { case MacroDirective::MD_Define: { MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++])); @@ -2078,7 +2082,6 @@ ASTReader::readInputFileInfo(ModuleFile } static unsigned moduleKindForDiagnostic(ModuleKind Kind); - InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) { // If this ID is bogus, just return an empty input file. if (ID == 0 || ID > F.InputFilesLoaded.size()) @@ -2517,14 +2520,14 @@ ASTReader::ReadControlBlock(ModuleFile & unsigned Idx = 0, N = Record.size(); while (Idx < N) { // Read information about the AST file. - auto ImportedKind = static_cast<ModuleKind>(Record[Idx++]); + ModuleKind ImportedKind = (ModuleKind)Record[Idx++]; // The import location will be the local one for now; we will adjust // all import locations of module imports after the global source // location info are setup, in ReadAST. SourceLocation ImportLoc = ReadUntranslatedSourceLocation(Record[Idx++]); - auto StoredSize = static_cast<off_t>(Record[Idx++]); - auto StoredModTime = static_cast<time_t>(Record[Idx++]); + off_t StoredSize = (off_t)Record[Idx++]; + time_t StoredModTime = (time_t)Record[Idx++]; ASTFileSignature StoredSignature = { {{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++], (uint32_t)Record[Idx++], (uint32_t)Record[Idx++], @@ -2601,6 +2604,7 @@ ASTReader::ReadControlBlock(ModuleFile & // failure. if (ASTReadResult Result = readUnhashedControlBlockOnce()) return Result; + break; case MODULE_DIRECTORY: { @@ -3481,8 +3485,7 @@ void ASTReader::ReadModuleOffsetMap(Modu assert(!F.ModuleOffsetMap.empty() && "no module offset map to read"); // Additional remapping information. - const auto *Data = - reinterpret_cast<const unsigned char *>(F.ModuleOffsetMap.data()); + const unsigned char *Data = (const unsigned char*)F.ModuleOffsetMap.data(); const unsigned char *DataEnd = Data + F.ModuleOffsetMap.size(); F.ModuleOffsetMap = StringRef(); @@ -3508,8 +3511,8 @@ void ASTReader::ReadModuleOffsetMap(Modu // start fixing this with prebuilt and explicit modules and see how it // goes... using namespace llvm::support; - auto Kind = static_cast<ModuleKind>( - endian::readNext<uint8_t, little, unaligned>(Data)); + ModuleKind Kind = static_cast<ModuleKind>( + endian::readNext<uint8_t, little, unaligned>(Data)); uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data); StringRef Name = StringRef((const char*)Data, Len); Data += Len; @@ -3637,7 +3640,7 @@ ASTReader::ReadModuleMapFileBlock(Record // Check any additional module map files (e.g. module.private.modulemap) // that are not in the pcm. if (auto *AdditionalModuleMaps = Map.getAdditionalModuleMapFiles(M)) { - for (const auto *ModMap : *AdditionalModuleMaps) { + for (const FileEntry *ModMap : *AdditionalModuleMaps) { // Remove files that match // Note: SmallPtrSet::erase is really remove if (!AdditionalStoredMaps.erase(ModMap)) { @@ -3651,7 +3654,7 @@ ASTReader::ReadModuleMapFileBlock(Record // Check any additional module map files that are in the pcm, but not // found in header search. Cases that match are already removed. - for (const auto *ModMap : AdditionalStoredMaps) { + for (const FileEntry *ModMap : AdditionalStoredMaps) { if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) Diag(diag::err_module_different_modmap) << F.ModuleName << /*not new*/1 << ModMap->getName(); @@ -3695,13 +3698,15 @@ static void moveMethodToBackOfGlobalList void ASTReader::makeNamesVisible(const HiddenNames &Names, Module *Owner) { assert(Owner->NameVisibility != Module::Hidden && "nothing to make visible?"); - for (auto *D : Names) { + for (Decl *D : Names) { bool wasHidden = D->isHidden(); D->setVisibleDespiteOwningModule(); - if (wasHidden && SemaObj) - if (auto *Method = dyn_cast<ObjCMethodDecl>(D)) + if (wasHidden && SemaObj) { + if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(D)) { moveMethodToBackOfGlobalList(*SemaObj, Method); + } + } } } @@ -3742,9 +3747,12 @@ void ASTReader::makeModuleVisible(Module // Push any exported modules onto the stack to be marked as visible. SmallVector<Module *, 16> Exports; Mod->getExportedModules(Exports); - for (auto *Exported : Exports) + for (SmallVectorImpl<Module *>::iterator + I = Exports.begin(), E = Exports.end(); I != E; ++I) { + Module *Exported = *I; if (Visited.insert(Exported).second) Stack.push_back(Exported); + } } } @@ -3871,7 +3879,7 @@ ASTReader::ASTReadResult ASTReader::Read case ConfigurationMismatch: case HadErrors: { llvm::SmallPtrSet<ModuleFile *, 4> LoadedSet; - for (const auto &IM : Loaded) + for (const ImportedModule &IM : Loaded) LoadedSet.insert(IM.Mod); ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, LoadedSet, @@ -3892,8 +3900,10 @@ ASTReader::ASTReadResult ASTReader::Read // Here comes stuff that we only do once the entire chain is loaded. // Load the AST blocks of all of the modules that we loaded. - for (auto &M : Loaded) { - ModuleFile &F = *M.Mod; + for (SmallVectorImpl<ImportedModule>::iterator M = Loaded.begin(), + MEnd = Loaded.end(); + M != MEnd; ++M) { + ModuleFile &F = *M->Mod; // Read the AST block. if (ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities)) @@ -3912,8 +3922,8 @@ ASTReader::ASTReadResult ASTReader::Read GlobalBitOffsetsMap.insert(std::make_pair(F.GlobalBitOffset, &F)); // Preload SLocEntries. - for (const auto PreloadSLocEntry : F.PreloadSLocEntries) { - int Index = int(PreloadSLocEntry - 1) + F.SLocEntryBaseID; + for (unsigned I = 0, N = F.PreloadSLocEntries.size(); I != N; ++I) { + int Index = int(F.PreloadSLocEntries[I] - 1) + F.SLocEntryBaseID; // Load it through the SourceManager and don't call ReadSLocEntry() // directly because the entry may have already been loaded in which case // calling ReadSLocEntry() directly would trigger an assertion in @@ -3931,7 +3941,7 @@ ASTReader::ASTReadResult ASTReader::Read // Preload all the pending interesting identifiers by marking them out of // date. for (auto Offset : F.PreloadIdentifierOffsets) { - const auto *Data = reinterpret_cast<const unsigned char *>( + const unsigned char *Data = reinterpret_cast<const unsigned char *>( F.IdentifierTableData + Offset); ASTIdentifierLookupTrait Trait(*this, F); @@ -3952,8 +3962,10 @@ ASTReader::ASTReadResult ASTReader::Read // Setup the import locations and notify the module manager that we've // committed to these module files. - for (auto &M : Loaded) { - ModuleFile &F = *M.Mod; + for (SmallVectorImpl<ImportedModule>::iterator M = Loaded.begin(), + MEnd = Loaded.end(); + M != MEnd; ++M) { + ModuleFile &F = *M->Mod; ModuleMgr.moduleFileAccepted(&F); @@ -3961,10 +3973,10 @@ ASTReader::ASTReadResult ASTReader::Read F.DirectImportLoc = ImportLoc; // FIXME: We assume that locations from PCH / preamble do not need // any translation. - if (!M.ImportedBy) - F.ImportLoc = M.ImportLoc; + if (!M->ImportedBy) + F.ImportLoc = M->ImportLoc; else - F.ImportLoc = TranslateSourceLocation(*M.ImportedBy, M.ImportLoc); + F.ImportLoc = TranslateSourceLocation(*M->ImportedBy, M->ImportLoc); } if (!PP.getLangOpts().CPlusPlus || @@ -3977,15 +3989,18 @@ ASTReader::ASTReadResult ASTReader::Read // For C++ modules, we don't need information on many identifiers (just // those that provide macros or are poisoned), so we mark all of // the interesting ones via PreloadIdentifierOffsets. - for (auto &Id : PP.getIdentifierTable()) - Id.second->setOutOfDate(true); + for (IdentifierTable::iterator Id = PP.getIdentifierTable().begin(), + IdEnd = PP.getIdentifierTable().end(); + Id != IdEnd; ++Id) + Id->second->setOutOfDate(true); } // Mark selectors as out of date. for (auto Sel : SelectorGeneration) SelectorOutOfDate[Sel.first] = true; // Resolve any unresolved module exports. - for (auto &Unresolved : UnresolvedModuleRefs) { + for (unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) { + UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I]; SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID); Module *ResolvedMod = getSubmodule(GlobalID); @@ -4044,10 +4059,13 @@ ASTReader::ASTReadResult ASTReader::Read // For any Objective-C class definitions we have already loaded, make sure // that we load any additional categories. - if (ContextObj) - for (auto *ObjCClassLoaded : ObjCClassesLoaded) - loadObjCCategories(ObjCClassLoaded->getGlobalID(), ObjCClassLoaded, + if (ContextObj) { + for (unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) { + loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(), + ObjCClassesLoaded[I], PreviousGeneration); + } + } if (PP.getHeaderSearchInfo() .getHeaderSearchOpts() @@ -4056,9 +4074,12 @@ ASTReader::ASTReadResult ASTReader::Read // up to date. Create or update timestamp files for modules that are // located in the module cache (not for PCH files that could be anywhere // in the filesystem). - for (auto &M : Loaded) - if (M.Mod->Kind == MK_ImplicitModule) + for (unsigned I = 0, N = Loaded.size(); I != N; ++I) { + ImportedModule &M = Loaded[I]; + if (M.Mod->Kind == MK_ImplicitModule) { updateModuleTimestamp(*M.Mod); + } + } } return Success; @@ -4441,10 +4462,10 @@ void ASTReader::InitializeContext() { } if (!Context.FILEDecl) { - if (const auto *Typedef = FileType->getAs<TypedefType>()) + if (const TypedefType *Typedef = FileType->getAs<TypedefType>()) Context.setFILEDecl(Typedef->getDecl()); else { - const auto *Tag = FileType->getAs<TagType>(); + const TagType *Tag = FileType->getAs<TagType>(); if (!Tag) { Error("Invalid FILE type in AST file"); return; @@ -4462,10 +4483,10 @@ void ASTReader::InitializeContext() { } if (!Context.jmp_bufDecl) { - if (const auto *Typedef = Jmp_bufType->getAs<TypedefType>()) + if (const TypedefType *Typedef = Jmp_bufType->getAs<TypedefType>()) Context.setjmp_bufDecl(Typedef->getDecl()); else { - const auto *Tag = Jmp_bufType->getAs<TagType>(); + const TagType *Tag = Jmp_bufType->getAs<TagType>(); if (!Tag) { Error("Invalid jmp_buf type in AST file"); return; @@ -4483,10 +4504,10 @@ void ASTReader::InitializeContext() { } if (!Context.sigjmp_bufDecl) { - if (const auto *Typedef = Sigjmp_bufType->getAs<TypedefType>()) + if (const TypedefType *Typedef = Sigjmp_bufType->getAs<TypedefType>()) Context.setsigjmp_bufDecl(Typedef->getDecl()); else { - const auto *Tag = Sigjmp_bufType->getAs<TagType>(); + const TagType *Tag = Sigjmp_bufType->getAs<TagType>(); assert(Tag && "Invalid sigjmp_buf type in AST file"); Context.setsigjmp_bufDecl(Tag->getDecl()); } @@ -4519,10 +4540,10 @@ void ASTReader::InitializeContext() { } if (!Context.ucontext_tDecl) { - if (const auto *Typedef = Ucontext_tType->getAs<TypedefType>()) + if (const TypedefType *Typedef = Ucontext_tType->getAs<TypedefType>()) Context.setucontext_tDecl(Typedef->getDecl()); else { - const auto *Tag = Ucontext_tType->getAs<TagType>(); + const TagType *Tag = Ucontext_tType->getAs<TagType>(); assert(Tag && "Invalid ucontext_t type in AST file"); Context.setucontext_tDecl(Tag->getDecl()); } @@ -4562,18 +4583,18 @@ void ASTReader::finalizeForWriting() { static ASTFileSignature readASTFileSignature(StringRef PCH) { BitstreamCursor Stream(PCH); if (!startsWithASTFileMagic(Stream)) - return {}; + return ASTFileSignature(); // Scan for the UNHASHED_CONTROL_BLOCK_ID block. if (SkipCursorToBlock(Stream, UNHASHED_CONTROL_BLOCK_ID)) - return {}; + return ASTFileSignature(); // Scan for SIGNATURE inside the diagnostic options block. ASTReader::RecordData Record; while (true) { llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); if (Entry.Kind != llvm::BitstreamEntry::Record) - return {}; + return ASTFileSignature(); Record.clear(); StringRef Blob; @@ -4594,7 +4615,7 @@ std::string ASTReader::getOriginalSource if (!Buffer) { Diags.Report(diag::err_fe_unable_to_read_pch_file) << ASTFileName << Buffer.getError().message(); - return {}; + return std::string(); } // Initialize the stream @@ -4603,13 +4624,13 @@ std::string ASTReader::getOriginalSource // Sniff for the signature. if (!startsWithASTFileMagic(Stream)) { Diags.Report(diag::err_fe_not_a_pch_file) << ASTFileName; - return {}; + return std::string(); } // Scan for the CONTROL_BLOCK_ID block. if (SkipCursorToBlock(Stream, CONTROL_BLOCK_ID)) { Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName; - return {}; + return std::string(); } // Scan for ORIGINAL_FILE inside the control block. @@ -4617,11 +4638,11 @@ std::string ASTReader::getOriginalSource while (true) { llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); if (Entry.Kind == llvm::BitstreamEntry::EndBlock) - return {}; + return std::string(); if (Entry.Kind != llvm::BitstreamEntry::Record) { Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName; - return {}; + return std::string(); } Record.clear(); @@ -4789,8 +4810,7 @@ bool ASTReader::readASTFileControlBlock( unsigned NumInputFiles = Record[0]; unsigned NumUserFiles = Record[1]; - const auto *InputFileOffs = - reinterpret_cast<const uint64_t *>(Blob.data()); + const uint64_t *InputFileOffs = (const uint64_t *)Blob.data(); for (unsigned I = 0; I != NumInputFiles; ++I) { // Go find this input file. bool isSystemFile = I >= NumUserFiles; @@ -4808,7 +4828,7 @@ bool ASTReader::readASTFileControlBlock( bool shouldContinue = false; switch ((InputFileRecordTypes)Cursor.readRecord(Code, Record, &Blob)) { case INPUT_FILE: - auto Overridden = static_cast<bool>(Record[3]); + bool Overridden = static_cast<bool>(Record[3]); std::string Filename = Blob; ResolveImportedPath(Filename, ModuleDir); shouldContinue = Listener.visitInputFile( @@ -4969,7 +4989,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile unsigned Idx = 0; SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]); SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]); - auto Kind = static_cast<Module::ModuleKind>(Record[Idx++]); + Module::ModuleKind Kind = (Module::ModuleKind)Record[Idx++]; bool IsFramework = Record[Idx++]; bool IsExplicit = Record[Idx++]; bool IsSystem = Record[Idx++]; @@ -5213,7 +5233,7 @@ bool ASTReader::ParseLanguageOptions(con for (unsigned N = Record[Idx++]; N; --N) LangOpts.ModuleFeatures.push_back(ReadString(Record, Idx)); - auto runtimeKind = static_cast<ObjCRuntime::Kind>(Record[Idx++]); + ObjCRuntime::Kind runtimeKind = (ObjCRuntime::Kind) Record[Idx++]; VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx); LangOpts.ObjCRuntime = ObjCRuntime(runtimeKind, runtimeVersion); @@ -5291,7 +5311,8 @@ bool ASTReader::ParseHeaderSearchOptions // Include entries. for (unsigned N = Record[Idx++]; N; --N) { std::string Path = ReadString(Record, Idx); - auto Group = static_cast<frontend::IncludeDirGroup>(Record[Idx++]); + frontend::IncludeDirGroup Group + = static_cast<frontend::IncludeDirGroup>(Record[Idx++]); bool IsFramework = Record[Idx++]; bool IgnoreSysRoot = Record[Idx++]; HSOpts.UserEntries.emplace_back(std::move(Path), Group, IsFramework, @@ -5425,8 +5446,9 @@ PreprocessedEntity *ASTReader::ReadPrepr PreprocessingRecord &PPRec = *PP.getPreprocessingRecord(); StringRef Blob; RecordData Record; - auto RecType = static_cast<PreprocessorDetailRecordTypes>( - M.PreprocessorDetailCursor.readRecord(Entry.ID, Record, &Blob)); + PreprocessorDetailRecordTypes RecType = + (PreprocessorDetailRecordTypes)M.PreprocessorDetailCursor.readRecord( + Entry.ID, Record, &Blob); switch (RecType) { case PPD_MACRO_EXPANSION: { bool isBuiltin = Record[0]; @@ -5454,7 +5476,7 @@ PreprocessedEntity *ASTReader::ReadPrepr // Decode the identifier info and then check again; if the macro is // still defined and associated with the identifier, IdentifierInfo *II = getLocalIdentifier(M, Record[0]); - auto *MD = new (PPRec) MacroDefinitionRecord(II, Range); + MacroDefinitionRecord *MD = new (PPRec) MacroDefinitionRecord(II, Range); if (DeserializationListener) DeserializationListener->MacroDefinitionRead(PPID, MD); @@ -5470,9 +5492,10 @@ PreprocessedEntity *ASTReader::ReadPrepr File = PP.getFileManager().getFile(FullFileName); // FIXME: Stable encoding - auto Kind = static_cast<InclusionDirective::InclusionKind>(Record[2]); - auto *ID = - new (PPRec) InclusionDirective(PPRec, Kind, + InclusionDirective::InclusionKind Kind + = static_cast<InclusionDirective::InclusionKind>(Record[2]); + InclusionDirective *ID + = new (PPRec) InclusionDirective(PPRec, Kind, StringRef(Blob.data(), Record[0]), Record[1], Record[3], File, @@ -5634,8 +5657,8 @@ namespace { explicit HeaderFileInfoVisitor(const FileEntry *FE) : FE(FE) {} bool operator()(ModuleFile &M) { - auto *Table = - static_cast<HeaderFileInfoLookupTable *>(M.HeaderFileInfoTable); + HeaderFileInfoLookupTable *Table + = static_cast<HeaderFileInfoLookupTable *>(M.HeaderFileInfoTable); if (!Table) return false; @@ -5666,7 +5689,7 @@ void ASTReader::ReadPragmaDiagnosticMapp using DiagState = DiagnosticsEngine::DiagState; SmallVector<DiagState *, 32> DiagStates; - for (auto &F : ModuleMgr) { + for (ModuleFile &F : ModuleMgr) { unsigned Idx = 0; auto &Record = F.PragmaDiagMappings; if (Record.empty()) @@ -5842,7 +5865,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_EXT_QUAL: { if (Record.size() != 2) { Error("Incorrect encoding of extended qualifier type"); - return {}; + return QualType(); } QualType Base = readType(*Loc.F, Record, Idx); Qualifiers Quals = Qualifiers::fromOpaqueValue(Record[Idx++]); @@ -5852,7 +5875,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_COMPLEX: { if (Record.size() != 1) { Error("Incorrect encoding of complex type"); - return {}; + return QualType(); } QualType ElemType = readType(*Loc.F, Record, Idx); return Context.getComplexType(ElemType); @@ -5861,7 +5884,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_POINTER: { if (Record.size() != 1) { Error("Incorrect encoding of pointer type"); - return {}; + return QualType(); } QualType PointeeType = readType(*Loc.F, Record, Idx); return Context.getPointerType(PointeeType); @@ -5870,7 +5893,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_DECAYED: { if (Record.size() != 1) { Error("Incorrect encoding of decayed type"); - return {}; + return QualType(); } QualType OriginalType = readType(*Loc.F, Record, Idx); QualType DT = Context.getAdjustedParameterType(OriginalType); @@ -5882,7 +5905,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_ADJUSTED: { if (Record.size() != 2) { Error("Incorrect encoding of adjusted type"); - return {}; + return QualType(); } QualType OriginalTy = readType(*Loc.F, Record, Idx); QualType AdjustedTy = readType(*Loc.F, Record, Idx); @@ -5892,7 +5915,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_BLOCK_POINTER: { if (Record.size() != 1) { Error("Incorrect encoding of block pointer type"); - return {}; + return QualType(); } QualType PointeeType = readType(*Loc.F, Record, Idx); return Context.getBlockPointerType(PointeeType); @@ -5901,7 +5924,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_LVALUE_REFERENCE: { if (Record.size() != 2) { Error("Incorrect encoding of lvalue reference type"); - return {}; + return QualType(); } QualType PointeeType = readType(*Loc.F, Record, Idx); return Context.getLValueReferenceType(PointeeType, Record[1]); @@ -5910,7 +5933,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_RVALUE_REFERENCE: { if (Record.size() != 1) { Error("Incorrect encoding of rvalue reference type"); - return {}; + return QualType(); } QualType PointeeType = readType(*Loc.F, Record, Idx); return Context.getRValueReferenceType(PointeeType); @@ -5919,19 +5942,19 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_MEMBER_POINTER: { if (Record.size() != 2) { Error("Incorrect encoding of member pointer type"); - return {}; + return QualType(); } QualType PointeeType = readType(*Loc.F, Record, Idx); QualType ClassType = readType(*Loc.F, Record, Idx); if (PointeeType.isNull() || ClassType.isNull()) - return {}; + return QualType(); return Context.getMemberPointerType(PointeeType, ClassType.getTypePtr()); } case TYPE_CONSTANT_ARRAY: { QualType ElementType = readType(*Loc.F, Record, Idx); - auto ASM = static_cast<ArrayType::ArraySizeModifier>(Record[1]); + ArrayType::ArraySizeModifier ASM = (ArrayType::ArraySizeModifier)Record[1]; unsigned IndexTypeQuals = Record[2]; unsigned Idx = 3; llvm::APInt Size = ReadAPInt(Record, Idx); @@ -5941,14 +5964,14 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_INCOMPLETE_ARRAY: { QualType ElementType = readType(*Loc.F, Record, Idx); - auto ASM = static_cast<ArrayType::ArraySizeModifier>(Record[1]); + ArrayType::ArraySizeModifier ASM = (ArrayType::ArraySizeModifier)Record[1]; unsigned IndexTypeQuals = Record[2]; return Context.getIncompleteArrayType(ElementType, ASM, IndexTypeQuals); } case TYPE_VARIABLE_ARRAY: { QualType ElementType = readType(*Loc.F, Record, Idx); - auto ASM = static_cast<ArrayType::ArraySizeModifier>(Record[1]); + ArrayType::ArraySizeModifier ASM = (ArrayType::ArraySizeModifier)Record[1]; unsigned IndexTypeQuals = Record[2]; SourceLocation LBLoc = ReadSourceLocation(*Loc.F, Record[3]); SourceLocation RBLoc = ReadSourceLocation(*Loc.F, Record[4]); @@ -5960,7 +5983,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_VECTOR: { if (Record.size() != 3) { Error("incorrect encoding of vector type in AST file"); - return {}; + return QualType(); } QualType ElementType = readType(*Loc.F, Record, Idx); @@ -5973,7 +5996,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_EXT_VECTOR: { if (Record.size() != 3) { Error("incorrect encoding of extended vector type in AST file"); - return {}; + return QualType(); } QualType ElementType = readType(*Loc.F, Record, Idx); @@ -5984,7 +6007,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_FUNCTION_NO_PROTO: { if (Record.size() != 8) { Error("incorrect encoding of no-proto function type"); - return {}; + return QualType(); } QualType ResultType = readType(*Loc.F, Record, Idx); FunctionType::ExtInfo Info(Record[1], Record[2], Record[3], @@ -6042,10 +6065,10 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_TYPEDEF: { if (Record.size() != 2) { Error("incorrect encoding of typedef type"); - return {}; + return QualType(); } unsigned Idx = 0; - auto *Decl = ReadDeclAs<TypedefNameDecl>(*Loc.F, Record, Idx); + TypedefNameDecl *Decl = ReadDeclAs<TypedefNameDecl>(*Loc.F, Record, Idx); QualType Canonical = readType(*Loc.F, Record, Idx); if (!Canonical.isNull()) Canonical = Context.getCanonicalType(Canonical); @@ -6058,7 +6081,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_TYPEOF: { if (Record.size() != 1) { Error("incorrect encoding of typeof(type) in AST file"); - return {}; + return QualType(); } QualType UnderlyingType = readType(*Loc.F, Record, Idx); return Context.getTypeOfType(UnderlyingType); @@ -6072,13 +6095,13 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_UNARY_TRANSFORM: { QualType BaseType = readType(*Loc.F, Record, Idx); QualType UnderlyingType = readType(*Loc.F, Record, Idx); - auto UKind = static_cast<UnaryTransformType::UTTKind>(Record[2]); + UnaryTransformType::UTTKind UKind = (UnaryTransformType::UTTKind)Record[2]; return Context.getUnaryTransformType(BaseType, UnderlyingType, UKind); } case TYPE_AUTO: { QualType Deduced = readType(*Loc.F, Record, Idx); - auto Keyword = static_cast<AutoTypeKeyword>(Record[Idx++]); + AutoTypeKeyword Keyword = (AutoTypeKeyword)Record[Idx++]; bool IsDependent = Deduced.isNull() ? Record[Idx++] : false; return Context.getAutoType(Deduced, Keyword, IsDependent); } @@ -6094,11 +6117,11 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_RECORD: { if (Record.size() != 2) { Error("incorrect encoding of record type"); - return {}; + return QualType(); } unsigned Idx = 0; bool IsDependent = Record[Idx++]; - auto *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx); + RecordDecl *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx); RD = cast_or_null<RecordDecl>(RD->getCanonicalDecl()); QualType T = Context.getRecordType(RD); const_cast<Type*>(T.getTypePtr())->setDependent(IsDependent); @@ -6108,7 +6131,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_ENUM: { if (Record.size() != 2) { Error("incorrect encoding of enum type"); - return {}; + return QualType(); } unsigned Idx = 0; bool IsDependent = Record[Idx++]; @@ -6121,18 +6144,18 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_ATTRIBUTED: { if (Record.size() != 3) { Error("incorrect encoding of attributed type"); - return {}; + return QualType(); } QualType modifiedType = readType(*Loc.F, Record, Idx); QualType equivalentType = readType(*Loc.F, Record, Idx); - auto kind = static_cast<AttributedType::Kind>(Record[2]); + AttributedType::Kind kind = static_cast<AttributedType::Kind>(Record[2]); return Context.getAttributedType(kind, modifiedType, equivalentType); } case TYPE_PAREN: { if (Record.size() != 1) { Error("incorrect encoding of paren type"); - return {}; + return QualType(); } QualType InnerType = readType(*Loc.F, Record, Idx); return Context.getParenType(InnerType); @@ -6141,11 +6164,11 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_PACK_EXPANSION: { if (Record.size() != 2) { Error("incorrect encoding of pack expansion type"); - return {}; + return QualType(); } QualType Pattern = readType(*Loc.F, Record, Idx); if (Pattern.isNull()) - return {}; + return QualType(); Optional<unsigned> NumExpansions; if (Record[1]) NumExpansions = Record[1] - 1; @@ -6154,7 +6177,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_ELABORATED: { unsigned Idx = 0; - auto Keyword = static_cast<ElaboratedTypeKeyword>(Record[Idx++]); + ElaboratedTypeKeyword Keyword = (ElaboratedTypeKeyword)Record[Idx++]; NestedNameSpecifier *NNS = ReadNestedNameSpecifier(*Loc.F, Record, Idx); QualType NamedType = readType(*Loc.F, Record, Idx); return Context.getElaboratedType(Keyword, NNS, NamedType); @@ -6162,13 +6185,15 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_OBJC_INTERFACE: { unsigned Idx = 0; - auto *ItfD = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx); + ObjCInterfaceDecl *ItfD + = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx); return Context.getObjCInterfaceType(ItfD->getCanonicalDecl()); } case TYPE_OBJC_TYPE_PARAM: { unsigned Idx = 0; - auto *Decl = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx); + ObjCTypeParamDecl *Decl + = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx); unsigned NumProtos = Record[Idx++]; SmallVector<ObjCProtocolDecl*, 4> Protos; for (unsigned I = 0; I != NumProtos; ++I) @@ -6216,7 +6241,7 @@ QualType ASTReader::readTypeRecord(unsig } case TYPE_INJECTED_CLASS_NAME: { - auto *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record, Idx); + CXXRecordDecl *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record, Idx); QualType TST = readType(*Loc.F, Record, Idx); // probably derivable // FIXME: ASTContext::getInjectedClassNameType is not currently suitable // for AST reading, too much interdependencies. @@ -6240,13 +6265,14 @@ QualType ASTReader::readTypeRecord(unsig unsigned Depth = Record[Idx++]; unsigned Index = Record[Idx++]; bool Pack = Record[Idx++]; - auto *D = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx); + TemplateTypeParmDecl *D + = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx); return Context.getTemplateTypeParmType(Depth, Index, Pack, D); } case TYPE_DEPENDENT_NAME: { unsigned Idx = 0; - auto Keyword = static_cast<ElaboratedTypeKeyword>(Record[Idx++]); + ElaboratedTypeKeyword Keyword = (ElaboratedTypeKeyword)Record[Idx++]; NestedNameSpecifier *NNS = ReadNestedNameSpecifier(*Loc.F, Record, Idx); const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx); QualType Canon = readType(*Loc.F, Record, Idx); @@ -6257,7 +6283,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION: { unsigned Idx = 0; - auto Keyword = static_cast<ElaboratedTypeKeyword>(Record[Idx++]); + ElaboratedTypeKeyword Keyword = (ElaboratedTypeKeyword)Record[Idx++]; NestedNameSpecifier *NNS = ReadNestedNameSpecifier(*Loc.F, Record, Idx); const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record, Idx); unsigned NumArgs = Record[Idx++]; @@ -6274,7 +6300,8 @@ QualType ASTReader::readTypeRecord(unsig // ArrayType QualType ElementType = readType(*Loc.F, Record, Idx); - auto ASM = static_cast<ArrayType::ArraySizeModifier>(Record[Idx++]); + ArrayType::ArraySizeModifier ASM + = (ArrayType::ArraySizeModifier)Record[Idx++]; unsigned IndexTypeQuals = Record[Idx++]; // DependentSizedArrayType @@ -6304,7 +6331,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_ATOMIC: { if (Record.size() != 1) { Error("Incorrect encoding of atomic type"); - return {}; + return QualType(); } QualType ValueType = readType(*Loc.F, Record, Idx); return Context.getAtomicType(ValueType); @@ -6313,7 +6340,7 @@ QualType ASTReader::readTypeRecord(unsig case TYPE_PIPE: { if (Record.size() != 2) { Error("Incorrect encoding of pipe type"); - return {}; + return QualType(); } // Reading the pipe element type. @@ -6353,7 +6380,8 @@ void ASTReader::readExceptionSpec(Module SmallVectorImpl<QualType> &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI, const RecordData &Record, unsigned &Idx) { - auto EST = static_cast<ExceptionSpecificationType>(Record[Idx++]); + ExceptionSpecificationType EST = + static_cast<ExceptionSpecificationType>(Record[Idx++]); ESI.Type = EST; if (EST == EST_Dynamic) { for (unsigned I = 0, N = Record[Idx++]; I != N; ++I) @@ -6721,7 +6749,7 @@ QualType ASTReader::GetType(TypeID ID) { QualType T; switch ((PredefinedTypeIDs)Index) { case PREDEF_TYPE_NULL_ID: - return {}; + return QualType(); case PREDEF_TYPE_VOID_ID: T = Context.VoidTy; break; @@ -6869,7 +6897,7 @@ QualType ASTReader::GetType(TypeID ID) { if (TypesLoaded[Index].isNull()) { TypesLoaded[Index] = readTypeRecord(Index); if (TypesLoaded[Index].isNull()) - return {}; + return QualType(); TypesLoaded[Index]->setFromAST(); if (DeserializationListener) @@ -6934,7 +6962,7 @@ ASTReader::GetTemplateArgumentLocInfo(Mo case TemplateArgument::NullPtr: case TemplateArgument::Pack: // FIXME: Is this right? - return {}; + return TemplateArgumentLocInfo(); } llvm_unreachable("unexpected template argument loc"); } @@ -7061,7 +7089,7 @@ CXXBaseSpecifier *ASTReader::GetExternal unsigned Idx = 0; unsigned NumBases = Record[Idx++]; void *Mem = Context.Allocate(sizeof(CXXBaseSpecifier) * NumBases); - auto *Bases = new (Mem) CXXBaseSpecifier [NumBases]; + CXXBaseSpecifier *Bases = new (Mem) CXXBaseSpecifier [NumBases]; for (unsigned I = 0; I != NumBases; ++I) Bases[I] = ReadCXXBaseSpecifier(*Loc.F, Record, Idx); return Bases; @@ -7102,13 +7130,13 @@ ModuleFile *ASTReader::getOwningModuleFi SourceLocation ASTReader::getSourceLocationForDeclID(GlobalDeclID ID) { if (ID < NUM_PREDEF_DECL_IDS) - return {}; + return SourceLocation(); unsigned Index = ID - NUM_PREDEF_DECL_IDS; if (Index > DeclsLoaded.size()) { Error("declaration ID out-of-range for AST file"); - return {}; + return SourceLocation(); } if (Decl *D = DeclsLoaded[Index]) @@ -7402,8 +7430,8 @@ ASTReader::FindExternalVisibleDeclsByNam // Load the list of declarations. SmallVector<NamedDecl *, 64> Decls; - for (auto ID : It->second.Table.find(Name)) { - auto *ND = cast<NamedDecl>(GetDecl(ID)); + for (DeclID ID : It->second.Table.find(Name)) { + NamedDecl *ND = cast<NamedDecl>(GetDecl(ID)); if (ND->getDeclName() == Name) Decls.push_back(ND); } @@ -7423,15 +7451,16 @@ void ASTReader::completeVisibleDeclsMap( DeclsMap Decls; - for (auto ID : It->second.Table.findAll()) { - auto *ND = cast<NamedDecl>(GetDecl(ID)); + for (DeclID ID : It->second.Table.findAll()) { + NamedDecl *ND = cast<NamedDecl>(GetDecl(ID)); Decls[ND->getDeclName()].push_back(ND); } ++NumVisibleDeclContextsRead; - for (auto &I : Decls) - SetExternalVisibleDeclsForName(DC, I.first, I.second); + for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) { + SetExternalVisibleDeclsForName(DC, I->first, I->second); + } const_cast<DeclContext *>(DC)->setHasExternalVisibleStorage(false); } @@ -7456,7 +7485,7 @@ static void PassObjCImplDeclToConsumer(O } void ASTReader::PassInterestingDeclToConsumer(Decl *D) { - if (auto *ImplD = dyn_cast<ObjCImplDecl>(D)) + if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D)) PassObjCImplDeclToConsumer(ImplD, Consumer); else Consumer->HandleInterestingDecl(DeclGroupRef(D)); @@ -7574,9 +7603,14 @@ dumpModuleIDMap(StringRef Name, if (Map.begin() == Map.end()) return; + using MapType = ContinuousRangeMap<Key, ModuleFile *, InitialCapacity>; + llvm::errs() << Name << ":\n"; - for (const auto &I : Map) - llvm::errs() << " " << I.first << " -> " << I.second->FileName << "\n"; + for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end(); + I != IEnd; ++I) { + llvm::errs() << " " << I->first << " -> " << I->second->FileName + << "\n"; + } } LLVM_DUMP_METHOD void ASTReader::dump() { @@ -7593,14 +7627,14 @@ LLVM_DUMP_METHOD void ASTReader::dump() GlobalPreprocessedEntityMap); llvm::errs() << "\n*** PCH/Modules Loaded:"; - for (auto &M : ModuleMgr) + for (ModuleFile &M : ModuleMgr) M.dump(); } /// Return the amount of memory used by memory buffers, breaking down /// by heap-backed versus mmap'ed memory. void ASTReader::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { - for (auto &I : ModuleMgr) { + for (ModuleFile &I : ModuleMgr) { if (llvm::MemoryBuffer *buf = I.Buffer) { size_t bytes = buf->getBufferSize(); switch (buf->getBufferKind()) { @@ -7621,8 +7655,8 @@ void ASTReader::InitializeSema(Sema &S) // Makes sure any declarations that were deserialized "too early" // still get added to the identifier's declaration chains. - for (auto ID : PreloadedDeclIDs) { - auto *D = cast<NamedDecl>(GetDecl(ID)); + for (uint64_t ID : PreloadedDeclIDs) { + NamedDecl *D = cast<NamedDecl>(GetDecl(ID)); pushExternalDeclIntoScope(D, D->getDeclName()); } PreloadedDeclIDs.clear(); @@ -7778,15 +7812,15 @@ StringRef ASTIdentifierIterator::Next() while (Current == End) { // If we have exhausted all of our AST files, we're done. if (Index == 0) - return {}; + return StringRef(); --Index; ModuleFile &F = Reader.ModuleMgr[Index]; if (SkipModules && F.isModule()) continue; - auto *IdTable = - static_cast<ASTIdentifierLookupTable *>(F.IdentifierLookupTable); + ASTIdentifierLookupTable *IdTable = + (ASTIdentifierLookupTable *)F.IdentifierLookupTable; Current = IdTable->key_begin(); End = IdTable->key_end(); } @@ -7812,7 +7846,7 @@ public: StringRef Next() override { if (!Current) - return {}; + return StringRef(); StringRef result = Current->Next(); if (!result.empty()) @@ -7868,8 +7902,8 @@ namespace serialization { return true; ++Reader.NumMethodPoolTableLookups; - auto *PoolTable = - static_cast<ASTSelectorLookupTable *>(M.SelectorLookupTable); + ASTSelectorLookupTable *PoolTable + = (ASTSelectorLookupTable*)M.SelectorLookupTable; ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel); if (Pos == PoolTable->end()) return false; @@ -7919,8 +7953,9 @@ namespace serialization { /// \brief Add the given set of methods to the method list. static void addMethodsToPool(Sema &S, ArrayRef<ObjCMethodDecl *> Methods, ObjCMethodList &List) { - for (auto *Method : Methods) - S.addMethodToGlobalList(&List, Method); + for (unsigned I = 0, N = Methods.size(); I != N; ++I) { + S.addMethodToGlobalList(&List, Methods[I]); + } } void ASTReader::ReadMethodPool(Selector Sel) { @@ -7969,16 +8004,17 @@ void ASTReader::ReadKnownNamespaces( SmallVectorImpl<NamespaceDecl *> &Namespaces) { Namespaces.clear(); - for (auto KnownNamespace : KnownNamespaces) - if (auto *Namespace = - dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespace))) + for (unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) { + if (NamespaceDecl *Namespace + = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I]))) Namespaces.push_back(Namespace); + } } void ASTReader::ReadUndefinedButUsed( llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) { for (unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) { - auto *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++])); + NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++])); SourceLocation Loc = SourceLocation::getFromRawEncoding(UndefinedButUsed[Idx++]); Undefined.insert(std::make_pair(D, Loc)); @@ -7989,7 +8025,7 @@ void ASTReader::ReadMismatchingDeleteExp FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> & Exprs) { for (unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) { - auto *FD = cast<FieldDecl>(GetDecl(DelayedDeleteExprs[Idx++])); + FieldDecl *FD = cast<FieldDecl>(GetDecl(DelayedDeleteExprs[Idx++])); uint64_t Count = DelayedDeleteExprs[Idx++]; for (uint64_t C = 0; C < Count; ++C) { SourceLocation DeleteLoc = @@ -8002,8 +8038,8 @@ void ASTReader::ReadMismatchingDeleteExp void ASTReader::ReadTentativeDefinitions( SmallVectorImpl<VarDecl *> &TentativeDefs) { - for (auto TentativeDefinition : TentativeDefinitions) { - auto *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinition)); + for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) { + VarDecl *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinitions[I])); if (Var) TentativeDefs.push_back(Var); } @@ -8012,8 +8048,9 @@ void ASTReader::ReadTentativeDefinitions void ASTReader::ReadUnusedFileScopedDecls( SmallVectorImpl<const DeclaratorDecl *> &Decls) { - for (auto UnusedFileScopedDecl : UnusedFileScopedDecls) { - auto *D = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecl)); + for (unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) { + DeclaratorDecl *D + = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I])); if (D) Decls.push_back(D); } @@ -8022,8 +8059,9 @@ void ASTReader::ReadUnusedFileScopedDecl void ASTReader::ReadDelegatingConstructors( SmallVectorImpl<CXXConstructorDecl *> &Decls) { - for (auto DelegatingCtorDecl : DelegatingCtorDecls) { - auto *D = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecl)); + for (unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) { + CXXConstructorDecl *D + = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I])); if (D) Decls.push_back(D); } @@ -8031,8 +8069,9 @@ void ASTReader::ReadDelegatingConstructo } void ASTReader::ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) { - for (auto ExtVectorDecl : ExtVectorDecls) { - auto *D = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecl)); + for (unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) { + TypedefNameDecl *D + = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I])); if (D) Decls.push_back(D); } @@ -8041,10 +8080,10 @@ void ASTReader::ReadExtVectorDecls(Small void ASTReader::ReadUnusedLocalTypedefNameCandidates( llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) { - for (auto UnusedLocalTypedefNameCandidate : UnusedLocalTypedefNameCandidates) - { - auto *D = dyn_cast_or_null<TypedefNameDecl>( - GetDecl(UnusedLocalTypedefNameCandidate)); + for (unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N; + ++I) { + TypedefNameDecl *D = dyn_cast_or_null<TypedefNameDecl>( + GetDecl(UnusedLocalTypedefNameCandidates[I])); if (D) Decls.insert(D); } @@ -8104,7 +8143,7 @@ void ASTReader::ReadUsedVTables(SmallVec void ASTReader::ReadPendingInstantiations( SmallVectorImpl<std::pair<ValueDecl *, SourceLocation>> &Pending) { for (unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) { - auto *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++])); + ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++])); SourceLocation Loc = SourceLocation::getFromRawEncoding(PendingInstantiations[Idx++]); @@ -8118,7 +8157,7 @@ void ASTReader::ReadLateParsedTemplates( &LPTMap) { for (unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N; /* In loop */) { - auto *FD = cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++])); + FunctionDecl *FD = cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++])); auto LT = llvm::make_unique<LateParsedTemplate>(); LT->D = GetDecl(LateParsedTemplates[Idx++]); @@ -8175,16 +8214,16 @@ ASTReader::SetGloballyVisibleDecls(Ident return; } - for (auto DeclID : DeclIDs) { + for (unsigned I = 0, N = DeclIDs.size(); I != N; ++I) { if (!SemaObj) { // Queue this declaration so that it will be added to the // translation unit scope and identifier's declaration chain // once a Sema object is known. - PreloadedDeclIDs.push_back(DeclID); + PreloadedDeclIDs.push_back(DeclIDs[I]); continue; } - auto *D = cast<NamedDecl>(GetDecl(DeclID)); + NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I])); // If we're simply supposed to record the declarations, do so now. if (Decls) { @@ -8388,11 +8427,11 @@ Selector ASTReader::getLocalSelector(Mod Selector ASTReader::DecodeSelector(serialization::SelectorID ID) { if (ID == 0) - return {}; + return Selector(); if (ID > SelectorsLoaded.size()) { Error("selector ID out of range in AST file"); - return {}; + return Selector(); } if (SelectorsLoaded[ID - 1].getAsOpaquePtr() == nullptr) { @@ -8440,7 +8479,7 @@ DeclarationName ASTReader::ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx) { ASTContext &Context = getContext(); - auto Kind = static_cast<DeclarationName::NameKind>(Record[Idx++]); + DeclarationName::NameKind Kind = (DeclarationName::NameKind)Record[Idx++]; switch (Kind) { case DeclarationName::Identifier: return DeclarationName(GetIdentifierInfo(F, Record, Idx)); @@ -8541,7 +8580,7 @@ TemplateName ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx) { ASTContext &Context = getContext(); - auto Kind = static_cast<TemplateName::NameKind>(Record[Idx++]); + TemplateName::NameKind Kind = (TemplateName::NameKind)Record[Idx++]; switch (Kind) { case TemplateName::Template: return TemplateName(ReadDeclAs<TemplateDecl>(F, Record, Idx)); @@ -8558,7 +8597,7 @@ ASTReader::ReadTemplateName(ModuleFile & case TemplateName::QualifiedTemplate: { NestedNameSpecifier *NNS = ReadNestedNameSpecifier(F, Record, Idx); bool hasTemplKeyword = Record[Idx++]; - auto *Template = ReadDeclAs<TemplateDecl>(F, Record, Idx); + TemplateDecl *Template = ReadDeclAs<TemplateDecl>(F, Record, Idx); return Context.getQualifiedTemplateName(NNS, hasTemplKeyword, Template); } @@ -8573,21 +8612,22 @@ ASTReader::ReadTemplateName(ModuleFile & } case TemplateName::SubstTemplateTemplateParm: { - auto *Param = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx); - if (!Param) - return {}; - TemplateName Replacement = ReadTemplateName(F, Record, Idx); - return Context.getSubstTemplateTemplateParm(Param, Replacement); + TemplateTemplateParmDecl *param + = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx); + if (!param) return TemplateName(); + TemplateName replacement = ReadTemplateName(F, Record, Idx); + return Context.getSubstTemplateTemplateParm(param, replacement); } case TemplateName::SubstTemplateTemplateParmPack: { - auto *Param = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx); + TemplateTemplateParmDecl *Param + = ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx); if (!Param) - return {}; + return TemplateName(); TemplateArgument ArgPack = ReadTemplateArgument(F, Record, Idx); if (ArgPack.getKind() != TemplateArgument::Pack) - return {}; + return TemplateName(); return Context.getSubstTemplateTemplateParmPack(Param, ArgPack); } @@ -8610,14 +8650,14 @@ TemplateArgument ASTReader::ReadTemplate return Context.getCanonicalTemplateArgument(Arg); } - auto Kind = static_cast<TemplateArgument::ArgKind>(Record[Idx++]); + TemplateArgument::ArgKind Kind = (TemplateArgument::ArgKind)Record[Idx++]; switch (Kind) { case TemplateArgument::Null: - return {}; + return TemplateArgument(); case TemplateArgument::Type: return TemplateArgument(readType(F, Record, Idx)); case TemplateArgument::Declaration: { - auto *D = ReadDeclAs<ValueDecl>(F, Record, Idx); + ValueDecl *D = ReadDeclAs<ValueDecl>(F, Record, Idx); return TemplateArgument(D, readType(F, Record, Idx)); } case TemplateArgument::NullPtr: @@ -8640,7 +8680,7 @@ TemplateArgument ASTReader::ReadTemplate return TemplateArgument(ReadExpr(F)); case TemplateArgument::Pack: { unsigned NumArgs = Record[Idx++]; - auto *Args = new (Context) TemplateArgument[NumArgs]; + TemplateArgument *Args = new (Context) TemplateArgument[NumArgs]; for (unsigned I = 0; I != NumArgs; ++I) Args[I] = ReadTemplateArgument(F, Record, Idx); return TemplateArgument(llvm::makeArrayRef(Args, NumArgs)); @@ -8687,7 +8727,7 @@ void ASTReader::ReadUnresolvedSet(Module Set.reserve(getContext(), NumDecls); while (NumDecls--) { DeclID ID = ReadDeclID(F, Record, Idx); - auto AS = static_cast<AccessSpecifier>(Record[Idx++]); + AccessSpecifier AS = (AccessSpecifier)Record[Idx++]; Set.addLazyDecl(getContext(), ID, AS); } } @@ -8695,10 +8735,10 @@ void ASTReader::ReadUnresolvedSet(Module CXXBaseSpecifier ASTReader::ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx) { - auto isVirtual = static_cast<bool>(Record[Idx++]); - auto isBaseOfClass = static_cast<bool>(Record[Idx++]); - auto AS = static_cast<AccessSpecifier>(Record[Idx++]); - auto inheritConstructors = static_cast<bool>(Record[Idx++]); + bool isVirtual = static_cast<bool>(Record[Idx++]); + bool isBaseOfClass = static_cast<bool>(Record[Idx++]); + AccessSpecifier AS = static_cast<AccessSpecifier>(Record[Idx++]); + bool inheritConstructors = static_cast<bool>(Record[Idx++]); TypeSourceInfo *TInfo = GetTypeSourceInfo(F, Record, Idx); SourceRange Range = ReadSourceRange(F, Record, Idx); SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Idx); @@ -8714,14 +8754,14 @@ ASTReader::ReadCXXCtorInitializers(Modul ASTContext &Context = getContext(); unsigned NumInitializers = Record[Idx++]; assert(NumInitializers && "wrote ctor initializers but have no inits"); - auto **CtorInitializers = new (Context) CXXCtorInitializer *[NumInitializers]; + auto **CtorInitializers = new (Context) CXXCtorInitializer*[NumInitializers]; for (unsigned i = 0; i != NumInitializers; ++i) { TypeSourceInfo *TInfo = nullptr; bool IsBaseVirtual = false; FieldDecl *Member = nullptr; IndirectFieldDecl *IndirectMember = nullptr; - auto Type = static_cast<CtorInitializerType>(Record[Idx++]); + CtorInitializerType Type = (CtorInitializerType)Record[Idx++]; switch (Type) { case CTOR_INITIALIZER_BASE: TInfo = GetTypeSourceInfo(F, Record, Idx); @@ -8781,7 +8821,8 @@ ASTReader::ReadNestedNameSpecifier(Modul unsigned N = Record[Idx++]; NestedNameSpecifier *NNS = nullptr, *Prev = nullptr; for (unsigned I = 0; I != N; ++I) { - auto Kind = static_cast<NestedNameSpecifier::SpecifierKind>(Record[Idx++]); + NestedNameSpecifier::SpecifierKind Kind + = (NestedNameSpecifier::SpecifierKind)Record[Idx++]; switch (Kind) { case NestedNameSpecifier::Identifier: { IdentifierInfo *II = GetIdentifierInfo(F, Record, Idx); @@ -8790,13 +8831,13 @@ ASTReader::ReadNestedNameSpecifier(Modul } case NestedNameSpecifier::Namespace: { - auto *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx); + NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx); NNS = NestedNameSpecifier::Create(Context, Prev, NS); break; } case NestedNameSpecifier::NamespaceAlias: { - auto *Alias = ReadDeclAs<NamespaceAliasDecl>(F, Record, Idx); + NamespaceAliasDecl *Alias =ReadDeclAs<NamespaceAliasDecl>(F, Record, Idx); NNS = NestedNameSpecifier::Create(Context, Prev, Alias); break; } @@ -8818,7 +8859,7 @@ ASTReader::ReadNestedNameSpecifier(Modul break; case NestedNameSpecifier::Super: { - auto *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx); + CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx); NNS = NestedNameSpecifier::SuperSpecifier(Context, RD); break; } @@ -8835,7 +8876,8 @@ ASTReader::ReadNestedNameSpecifierLoc(Mo unsigned N = Record[Idx++]; NestedNameSpecifierLocBuilder Builder; for (unsigned I = 0; I != N; ++I) { - auto Kind = static_cast<NestedNameSpecifier::SpecifierKind>(Record[Idx++]); + NestedNameSpecifier::SpecifierKind Kind + = (NestedNameSpecifier::SpecifierKind)Record[Idx++]; switch (Kind) { case NestedNameSpecifier::Identifier: { IdentifierInfo *II = GetIdentifierInfo(F, Record, Idx); @@ -8845,14 +8887,14 @@ ASTReader::ReadNestedNameSpecifierLoc(Mo } case NestedNameSpecifier::Namespace: { - auto *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx); + NamespaceDecl *NS = ReadDeclAs<NamespaceDecl>(F, Record, Idx); SourceRange Range = ReadSourceRange(F, Record, Idx); Builder.Extend(Context, NS, Range.getBegin(), Range.getEnd()); break; } case NestedNameSpecifier::NamespaceAlias: { - auto *Alias = ReadDeclAs<NamespaceAliasDecl>(F, Record, Idx); + NamespaceAliasDecl *Alias =ReadDeclAs<NamespaceAliasDecl>(F, Record, Idx); SourceRange Range = ReadSourceRange(F, Record, Idx); Builder.Extend(Context, Alias, Range.getBegin(), Range.getEnd()); break; @@ -8863,7 +8905,7 @@ ASTReader::ReadNestedNameSpecifierLoc(Mo bool Template = Record[Idx++]; TypeSourceInfo *T = GetTypeSourceInfo(F, Record, Idx); if (!T) - return {}; + return NestedNameSpecifierLoc(); SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx); // FIXME: 'template' keyword location not saved anywhere, so we fake it. @@ -8880,7 +8922,7 @@ ASTReader::ReadNestedNameSpecifierLoc(Mo } case NestedNameSpecifier::Super: { - auto *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx); + CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx); SourceRange Range = ReadSourceRange(F, Record, Idx); Builder.MakeSuper(Context, RD, Range.getBegin(), Range.getEnd()); break; @@ -8951,7 +8993,7 @@ VersionTuple ASTReader::ReadVersionTuple CXXTemporary *ASTReader::ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx) { - auto *Decl = ReadDeclAs<CXXDestructorDecl>(F, Record, Idx); + CXXDestructorDecl *Decl = ReadDeclAs<CXXDestructorDecl>(F, Record, Idx); return CXXTemporary::Create(getContext(), Decl); } @@ -8990,10 +9032,14 @@ void ASTReader::ClearSwitchCaseIDs() { void ASTReader::ReadComments() { ASTContext &Context = getContext(); std::vector<RawComment *> Comments; - for (auto &I : CommentsCursors) { + for (SmallVectorImpl<std::pair<BitstreamCursor, + serialization::ModuleFile *>>::iterator + I = CommentsCursors.begin(), + E = CommentsCursors.end(); + I != E; ++I) { Comments.clear(); - BitstreamCursor &Cursor = I.first; - serialization::ModuleFile &F = *I.second; + BitstreamCursor &Cursor = I->first; + serialization::ModuleFile &F = *I->second; SavedStreamPosition SavedPosition(Cursor); RecordData Record; @@ -9019,7 +9065,8 @@ void ASTReader::ReadComments() { case COMMENTS_RAW_COMMENT: { unsigned Idx = 0; SourceRange SR = ReadSourceRange(F, Record, Idx); - auto Kind = static_cast<RawComment::CommentKind>(Record[Idx++]); + RawComment::CommentKind Kind = + (RawComment::CommentKind) Record[Idx++]; bool IsTrailingComment = Record[Idx++]; bool IsAlmostTrailingComment = Record[Idx++]; Comments.push_back(new (Context) RawComment( @@ -9100,20 +9147,22 @@ void ASTReader::finishPendingActions() { // For each decl chain that we wanted to complete while deserializing, mark // it as "still needs to be completed". - for (auto *PendingIncompleteDeclChain : PendingIncompleteDeclChains) - markIncompleteDeclChain(PendingIncompleteDeclChain); + for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) { + markIncompleteDeclChain(PendingIncompleteDeclChains[I]); + } PendingIncompleteDeclChains.clear(); // Load pending declaration chains. - for (const auto &I : PendingDeclChains) - loadPendingDeclChain(I.first, I.second); + for (unsigned I = 0; I != PendingDeclChains.size(); ++I) + loadPendingDeclChain(PendingDeclChains[I].first, PendingDeclChains[I].second); PendingDeclChains.clear(); // Make the most recent of the top-level declarations visible. - for (auto &TLD : TopLevelDecls) { - IdentifierInfo *II = TLD.first; - for (unsigned I = 0, N = TLD.second.size(); I != N; ++I) { - pushExternalDeclIntoScope(cast<NamedDecl>(TLD.second[I]), II); + for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(), + TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) { + IdentifierInfo *II = TLD->first; + for (unsigned I = 0, N = TLD->second.size(); I != N; ++I) { + pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II); } } @@ -9144,8 +9193,8 @@ void ASTReader::finishPendingActions() { while (!PendingDeclContextInfos.empty()) { PendingDeclContextInfo Info = PendingDeclContextInfos.front(); PendingDeclContextInfos.pop_front(); - auto *SemaDC = cast<DeclContext>(GetDecl(Info.SemaDC)); - auto *LexicalDC = cast<DeclContext>(GetDecl(Info.LexicalDC)); + DeclContext *SemaDC = cast<DeclContext>(GetDecl(Info.SemaDC)); + DeclContext *LexicalDC = cast<DeclContext>(GetDecl(Info.LexicalDC)); Info.D->setDeclContextsImpl(SemaDC, LexicalDC, getContext()); } @@ -9166,14 +9215,14 @@ void ASTReader::finishPendingActions() { // Objective-C protocol definitions, or any redeclarable templates, make sure // that all redeclarations point to the definitions. Note that this can only // happen now, after the redeclaration chains have been fully wired. - for (auto *D : PendingDefinitions) { - if (auto *TD = dyn_cast<TagDecl>(D)) { - if (const auto *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) { + for (Decl *D : PendingDefinitions) { + if (TagDecl *TD = dyn_cast<TagDecl>(D)) { + if (const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) { // Make sure that the TagType points at the definition. const_cast<TagType*>(TagT)->decl = TD; } - if (auto *RD = dyn_cast<CXXRecordDecl>(D)) { + if (auto RD = dyn_cast<CXXRecordDecl>(D)) { for (auto *R = getMostRecentExistingDecl(RD); R; R = R->getPreviousDecl()) { assert((R == D) == @@ -9186,7 +9235,7 @@ void ASTReader::finishPendingActions() { continue; } - if (auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) { + if (auto ID = dyn_cast<ObjCInterfaceDecl>(D)) { // Make sure that the ObjCInterfaceType points at the definition. const_cast<ObjCInterfaceType *>(cast<ObjCInterfaceType>(ID->TypeForDecl)) ->Decl = ID; @@ -9197,14 +9246,14 @@ void ASTReader::finishPendingActions() { continue; } - if (auto *PD = dyn_cast<ObjCProtocolDecl>(D)) { + if (auto PD = dyn_cast<ObjCProtocolDecl>(D)) { for (auto *R = getMostRecentExistingDecl(PD); R; R = R->getPreviousDecl()) cast<ObjCProtocolDecl>(R)->Data = PD->Data; continue; } - auto *RTD = cast<RedeclarableTemplateDecl>(D)->getCanonicalDecl(); + auto RTD = cast<RedeclarableTemplateDecl>(D)->getCanonicalDecl(); for (auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl()) cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common; } @@ -9214,15 +9263,17 @@ void ASTReader::finishPendingActions() { // this now (delayed) so that we can be sure that the declaration chains // have been fully wired up (hasBody relies on this). // FIXME: We shouldn't require complete redeclaration chains here. - for (auto &PB : PendingBodies) { - if (auto *FD = dyn_cast<FunctionDecl>(PB.first)) { + for (PendingBodiesMap::iterator PB = PendingBodies.begin(), + PBEnd = PendingBodies.end(); + PB != PBEnd; ++PB) { + if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) { // FIXME: Check for =delete/=default? // FIXME: Complain about ODR violations here? const FunctionDecl *Defn = nullptr; if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) { - FD->setLazyBody(PB.second); + FD->setLazyBody(PB->second); } else { - auto *NonConstDefn = const_cast<FunctionDecl *>(Defn); + auto *NonConstDefn = const_cast<FunctionDecl*>(Defn); mergeDefinitionVisibility(NonConstDefn, FD); if (!FD->isLateTemplateParsed() && @@ -9234,9 +9285,9 @@ void ASTReader::finishPendingActions() { continue; } - auto *MD = cast<ObjCMethodDecl>(PB.first); + ObjCMethodDecl *MD = cast<ObjCMethodDecl>(PB->first); if (!getContext().getLangOpts().Modules || !MD->hasBody()) - MD->setLazyBody(PB.second); + MD->setLazyBody(PB->second); } PendingBodies.clear(); @@ -9356,10 +9407,10 @@ void ASTReader::diagnoseOdrViolations() Diag(cast<Decl>(CanonDef)->getLocation(), diag::note_module_odr_violation_no_possible_decls) << D; else { - for (auto *Candidate : Candidates) - Diag(Candidate->getLocation(), + for (unsigned I = 0, N = Candidates.size(); I != N; ++I) + Diag(Candidates[I]->getLocation(), diag::note_module_odr_violation_possible_decl) - << Candidate; + << Candidates[I]; } DiagnosedOdrMergeFailures.insert(CanonDef); @@ -9580,8 +9631,8 @@ void ASTReader::diagnoseOdrViolations() << SecondModule << Range << DiffType; }; - const auto *FirstDecl = cast<NamedDecl>(FirstIt->first); - const auto *SecondDecl = cast<NamedDecl>(SecondIt->first); + const NamedDecl* FirstDecl = cast<NamedDecl>(FirstIt->first); + const NamedDecl* SecondDecl = cast<NamedDecl>(SecondIt->first); assert(FirstDecl->getKind() == SecondDecl->getKind() && "Parameter Decl's should be the same kind."); @@ -9929,8 +9980,8 @@ void ASTReader::diagnoseOdrViolations() llvm_unreachable("Invalid diff type"); case StaticAssert: { - auto *FirstSA = cast<StaticAssertDecl>(FirstDecl); - auto *SecondSA = cast<StaticAssertDecl>(SecondDecl); + StaticAssertDecl *FirstSA = cast<StaticAssertDecl>(FirstDecl); + StaticAssertDecl *SecondSA = cast<StaticAssertDecl>(SecondDecl); Expr *FirstExpr = FirstSA->getAssertExpr(); Expr *SecondExpr = SecondSA->getAssertExpr(); @@ -9985,8 +10036,8 @@ void ASTReader::diagnoseOdrViolations() break; } case Field: { - auto *FirstField = cast<FieldDecl>(FirstDecl); - auto *SecondField = cast<FieldDecl>(SecondDecl); + FieldDecl *FirstField = cast<FieldDecl>(FirstDecl); + FieldDecl *SecondField = cast<FieldDecl>(SecondDecl); IdentifierInfo *FirstII = FirstField->getIdentifier(); IdentifierInfo *SecondII = SecondField->getIdentifier(); if (FirstII->getName() != SecondII->getName()) { @@ -10101,8 +10152,8 @@ void ASTReader::diagnoseOdrViolations() if (isa<CXXDestructorDecl>(D)) return DiagDestructor; return DiagMethod; }; - const auto *FirstMethod = cast<CXXMethodDecl>(FirstDecl); - const auto *SecondMethod = cast<CXXMethodDecl>(SecondDecl); + const CXXMethodDecl *FirstMethod = cast<CXXMethodDecl>(FirstDecl); + const CXXMethodDecl *SecondMethod = cast<CXXMethodDecl>(SecondDecl); FirstMethodType = GetMethodTypeForDiagnostics(FirstMethod); SecondMethodType = GetMethodTypeForDiagnostics(SecondMethod); auto FirstName = FirstMethod->getDeclName(); @@ -10230,7 +10281,7 @@ void ASTReader::diagnoseOdrViolations() if (FirstParamType != SecondParamType && ComputeQualTypeODRHash(FirstParamType) != ComputeQualTypeODRHash(SecondParamType)) { - if (const auto *ParamDecayedType = + if (const DecayedType *ParamDecayedType = FirstParamType->getAs<DecayedType>()) { ODRDiagError(FirstMethod->getLocation(), FirstMethod->getSourceRange(), MethodParameterType) @@ -10243,7 +10294,7 @@ void ASTReader::diagnoseOdrViolations() << false; } - if (const auto *ParamDecayedType = + if (const DecayedType *ParamDecayedType = SecondParamType->getAs<DecayedType>()) { ODRDiagNote(SecondMethod->getLocation(), SecondMethod->getSourceRange(), MethodParameterType) @@ -10319,8 +10370,8 @@ void ASTReader::diagnoseOdrViolations() } case TypeAlias: case TypeDef: { - auto *FirstTD = cast<TypedefNameDecl>(FirstDecl); - auto *SecondTD = cast<TypedefNameDecl>(SecondDecl); + TypedefNameDecl *FirstTD = cast<TypedefNameDecl>(FirstDecl); + TypedefNameDecl *SecondTD = cast<TypedefNameDecl>(SecondDecl); auto FirstName = FirstTD->getDeclName(); auto SecondName = SecondTD->getDeclName(); if (FirstName != SecondName) { @@ -10350,8 +10401,8 @@ void ASTReader::diagnoseOdrViolations() break; } case Var: { - auto *FirstVD = cast<VarDecl>(FirstDecl); - auto *SecondVD = cast<VarDecl>(SecondDecl); + VarDecl *FirstVD = cast<VarDecl>(FirstDecl); + VarDecl *SecondVD = cast<VarDecl>(SecondDecl); auto FirstName = FirstVD->getDeclName(); auto SecondName = SecondVD->getDeclName(); if (FirstName != SecondName) { @@ -10421,8 +10472,8 @@ void ASTReader::diagnoseOdrViolations() break; } case Friend: { - auto *FirstFriend = cast<FriendDecl>(FirstDecl); - auto *SecondFriend = cast<FriendDecl>(SecondDecl); + FriendDecl *FirstFriend = cast<FriendDecl>(FirstDecl); + FriendDecl *SecondFriend = cast<FriendDecl>(SecondDecl); NamedDecl *FirstND = FirstFriend->getFriendDecl(); NamedDecl *SecondND = SecondFriend->getFriendDecl(); @@ -10511,6 +10562,7 @@ void ASTReader::diagnoseOdrViolations() bool Diagnosed = false; for (auto &SecondFunction : Merge.second) { + if (FirstFunction == SecondFunction) continue; @@ -10572,7 +10624,7 @@ void ASTReader::diagnoseOdrViolations() if (FirstParamType != SecondParamType && ComputeQualTypeODRHash(FirstParamType) != ComputeQualTypeODRHash(SecondParamType)) { - if (const auto *ParamDecayedType = + if (const DecayedType *ParamDecayedType = FirstParamType->getAs<DecayedType>()) { ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(), ParameterType) @@ -10584,7 +10636,7 @@ void ASTReader::diagnoseOdrViolations() << (I + 1) << FirstParamType << false; } - if (const auto *ParamDecayedType = + if (const DecayedType *ParamDecayedType = SecondParamType->getAs<DecayedType>()) { ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(), ParameterType) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits