r330068 - [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
Richard Trieu via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 13 20:22:02 PDT 2018
I was tracking down a similar issue to the lldb issue before noticing the
change was reverted. The bad change that lead to it is:
// Load pending declaration chains.
- for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
- loadPendingDeclChain(PendingDeclChains[I].first,
PendingDeclChains[I].second);
+ for (const auto &I : PendingDeclChains)
+ loadPendingDeclChain(I.first, I.second);
PendingDeclChains.clear();
Although the two looks like similar, the vector PendingDeclChains is a
class member and gets new elements during loop runs. Once enough elements
are added to the vector, it get reallocated to a larger memory, but the
loop is still trying to process the old, now freed, memory. Using an index
and checking the size every loop is the right way to process this vector.
On Fri, Apr 13, 2018 at 6:47 PM Vedant Kumar via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> I've gone ahead and reverted this in r330080.
>
> I tested this with "./bin/lldb-dotest -p TestForwardDecl", and it no
> longer asserts, etc.
>
> @Eugene, regarding the specifics of this commit, there are a number of
> refactors here that don't make sense. E.g there's no need to create a
> reference to a StringRef, it's already an immutable reference :).
>
> Stepping back a bit, I'm asking you to please stop committing large
> refactors of code you don't have a deep familiarity with, or plans to work
> on. I've asked you this before, when changes you made in lib/ProfileData
> caused downstream breakage. I'm repeating the request now. These sorts of
> changes carry more risk than I'm comfortable with, without offering up much
> reward in return. Please, enough.
>
> thanks,
> vedant
>
> > On Apr 13, 2018, at 6:42 PM, Davide Italiano <ditaliano at apple.com>
> wrote:
> >
> > The amount of churn this patches introduces is very large for a very
> small gain.
> > Other than basically causing to every downstream consumer with private
> clang changes a large amount of pain, it also introduced a bug (which shows
> up only on lldb bots).
> > I really think we should have a policy that these commits shouldn’t be
> encouraged. At some point I and Chandler discussed this on IRC, but I’m not
> sure this went anywhere.
> >
> > In general, large refactoring of code not properly understood is causing
> more harm to the project than good. We’re going to revert this now, and I
> would like to kick off a discussion about this in the future.
> >
> > Thanks,
> >
> > —
> > Davide
> >
> >> On Apr 13, 2018, at 18:36, Vedant Kumar <vsk at apple.com> wrote:
> >>
> >> + Davide
> >>
> >>> On Apr 13, 2018, at 6:36 PM, Vedant Kumar via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
> >>>
> >>> This is breaking the lldb bots with assertion failures:
> >>>
> >>> 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.
> >>> Stack dump:
> >>> 0. Program arguments:
> /Users/vsk/src/builds/llvm.org-lldbsan-RA/bin/clang-7 -cc1 -triple
> x86_64-apple-macosx10.13.0 -Wdeprecated-objc-isa-usage
> -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
> -main-file-name main.m -mrelocation-model pic -pic-level 2 -mthread-model
> posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn
> -dwarf-column-info -dwarf-ext-refs -fmodule-format=obj
> -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb
> -target-linker-version 405.15 -coverage-notes-file
> /Users/vsk/src/builds/llvm.org-lldbsan-RA/lldb-test-build.noindex/lang/objc/forward-decl/TestForwardDecl.test_expr_gmodules/main.gcno
> -resource-dir /Users/vsk/src/builds/llvm.org-lldbsan-RA/lib/clang/7.0.0
> -include
> /Users/vsk/src/llvm.org-lldbsan/llvm/tools/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/../../../make/test_common.h
> -isysroot
> /Volumes/Xcode10A144_m18A232_i16A233_t16J228_w16R229_XcodeInternals_ASan_30GB/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
> -I
> /Users/vsk/src/llvm.org-lldbsan/llvm/tools/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/../../../make/../../../../../include
> -I
> /Users/vsk/src/llvm.org-lldbsan/llvm/tools/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/
> -I
> /Users/vsk/src/llvm.org-lldbsan/llvm/tools/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/../../../make/
> -O0 -fdebug-compilation-dir
> /Users/vsk/src/builds/llvm.org-lldbsan-RA/lldb-test-build.noindex/lang/objc/forward-decl/TestForwardDecl.test_expr_gmodules
> -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fno-builtin
> -fblocks -fencode-extended-block-signature -fmodules -fimplicit-module-maps
> -fmodules-cache-path=module-cache -fobjc-runtime=macosx-10.13.0
> -fobjc-exceptions -fexceptions -fmax-type-align=16
> -fdiagnostics-show-option -o main.o -x objective-c
> /Users/vsk/src/llvm.org-lldbsan/llvm/tools/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/main.m
>
> >>> 1.
> /Users/vsk/src/llvm.org-lldbsan/llvm/tools/lldb/packages/Python/lldbsuite/test/lang/objc/forward-decl/Container.h:10:10:
> current parser token ';'
> >>> 0 clang-7 0x000000010f38bf18
> llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
> >>> 1 clang-7 0x000000010f38c5a6 SignalHandler(int) + 422
> >>> 2 libsystem_platform.dylib 0x00007fff72cc6f5a _sigtramp + 26
> >>> 3 libsystem_platform.dylib 000000000000000000 _sigtramp + 2368966848
> >>> 4 libsystem_c.dylib 0x00007fff72af1312 abort + 127
> >>> 5 libsystem_c.dylib 0x00007fff72ab9368 basename_r + 0
> >>> 6 clang-7 0x000000011005cfe1
> clang::ASTReader::loadPendingDeclChain(clang::Decl*, unsigned long long) +
> 817
> >>> 7 clang-7 0x0000000110012bcf
> clang::ASTReader::finishPendingActions() + 831
> >>> 8 clang-7 0x000000011001f2b9
> clang::ASTReader::FinishedDeserializing() + 1097
> >>> 9 clang-7 0x0000000110059f96
> clang::ASTReader::ReadDeclRecord(unsigned int) + 4230
> >>> 10 clang-7 0x0000000110023cbe
> clang::ASTReader::GetLocalDecl(clang::serialization::ModuleFile&, unsigned
> int) + 238
> >>> 11 clang-7 0x000000010ffd20c4
> clang::serialization::reader::ASTSelectorLookupTrait::ReadData(clang::Selector,
> unsigned char const*, unsigned int) + 372
> >>> 12 clang-7 0x000000011002cd5c
> clang::serialization::ReadMethodPoolVisitor::operator()(clang::serialization::ModuleFile&)
> + 348
> >>> 13 clang-7 0x00000001101403bb
> clang::serialization::ModuleManager::visit(llvm::function_ref<bool
> (clang::serialization::ModuleFile&)>,
> llvm::SmallPtrSetImpl<clang::serialization::ModuleFile*>*) + 1627
> >>> 14 clang-7 0x000000011000d5f5
> clang::ASTReader::ReadMethodPool(clang::Selector) + 229
> >>> 15 clang-7 0x000000011040a99b (anonymous
> namespace)::OverrideSearch::OverrideSearch(clang::Sema&,
> clang::ObjCMethodDecl*) + 411
> >>> 16 clang-7 0x0000000110409f6a
> clang::Sema::CheckObjCMethodOverrides(clang::ObjCMethodDecl*,
> clang::ObjCInterfaceDecl*, clang::Sema::ResultTypeCompatibilityKind) + 74
> >>> 17 clang-7 0x000000011040bfef
> clang::Sema::ActOnMethodDeclaration(clang::Scope*, clang::SourceLocation,
> clang::SourceLocation, clang::tok::TokenKind, clang::ObjCDeclSpec&,
> clang::OpaquePtr<clang::QualType>, llvm::ArrayRef<clang::SourceLocation>,
> clang::Selector, clang::Sema::ObjCArgInfo*,
> clang::DeclaratorChunk::ParamInfo*, unsigned int, clang::AttributeList*,
> clang::tok::ObjCKeywordKind, bool, bool) + 5311
> >>> 18 clang-7 0x000000010ff7b8f9
> clang::Parser::ParseObjCMethodDecl(clang::SourceLocation,
> clang::tok::TokenKind, clang::tok::ObjCKeywordKind, bool) + 1465
> >>> 19 clang-7 0x000000010ff792e2
> clang::Parser::ParseObjCInterfaceDeclList(clang::tok::ObjCKeywordKind,
> clang::Decl*) + 258
> >>> 20 clang-7 0x000000010ff7588b
> clang::Parser::ParseObjCAtInterfaceDeclaration(clang::SourceLocation,
> clang::ParsedAttributes&) + 2587
> >>> 21 clang-7 0x000000010ff747d8
> clang::Parser::ParseObjCAtDirectives(clang::Parser::ParsedAttributesWithRange&)
> + 312
> >>> 22 clang-7 0x000000010ffbd4a7
> clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
> clang::ParsingDeclSpec*) + 967
> >>> 23 clang-7 0x000000010ffbc9e2
> clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) +
> 626
> >>> 24 clang-7 0x000000010ff18c76
> clang::ParseAST(clang::Sema&, bool, bool) + 438
> >>> 25 clang-7 0x000000010fa402dc
> clang::FrontendAction::Execute() + 76
> >>> 26 clang-7 0x000000010f9e3521
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1345
> >>> 27 clang-7 0x000000010fa8f411
> clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1441
> >>> 28 clang-7 0x000000010e16466d
> cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1437
> >>> 29 clang-7 0x000000010e162552 main + 10882
> >>> 30 libdyld.dylib 0x00007fff72a45115 start + 1
> >>> 31 libdyld.dylib 0x0000000000000045 start + 2371596081
> >>> clang-7: error: unable to execute command: Abort trap: 6
> >>> clang-7: error: clang frontend command failed due to signal (use -v to
> see invocation)
> >>> clang version 7.0.0 (trunk 330077) (llvm/trunk 330079)
> >>> Target: x86_64-apple-darwin17.4.0
> >>> Thread model: posix
> >>> InstalledDir: /Users/vsk/src/builds/llvm.org-lldbsan-RA/bin
> >>> clang-7: note: diagnostic msg: PLEASE submit a bug report to
> https://bugs.llvm.org/ and include the crash backtrace, preprocessed
> source, and associated run script.
> >>> clang-7: note: diagnostic msg:
> >>> ********************
> >>>
> >>> vedant
> >>>
> >>>> On Apr 13, 2018, at 2:12 PM, Eugene Zelenko via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
> >>>>
> >>>> Author: eugenezelenko
> >>>> Date: Fri Apr 13 14:12:33 2018
> >>>> New Revision: 330068
> >>>>
> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=330068&view=rev
> >>>> Log:
> >>>> [Serialization] Fix some Clang-tidy modernize and Include What You
> Use warnings; other minor fixes (NFC).
> >>>>
> >>>> 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=330068&r1=330067&r2=330068&view=diff
> >>>>
> ==============================================================================
> >>>> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> >>>> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Apr 13 14:12:33 2018
> >>>> @@ -71,6 +71,7 @@
> >>>> #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"
> >>>> @@ -97,11 +98,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"
> >>>> @@ -133,8 +134,8 @@
> >>>> #include <vector>
> >>>>
> >>>> using namespace clang;
> >>>> -using namespace clang::serialization;
> >>>> -using namespace clang::serialization::reader;
> >>>> +using namespace serialization;
> >>>> +using namespace reader;
> >>>> using llvm::BitstreamCursor;
> >>>>
> >>>>
> //===----------------------------------------------------------------------===//
> >>>> @@ -463,7 +464,7 @@ static bool checkDiagnosticGroupMappings
> >>>> // errors because of options like -Werror.
> >>>> DiagnosticsEngine *MappingSources[] = { &Diags, &StoredDiags };
> >>>>
> >>>> - for (DiagnosticsEngine *MappingSource : MappingSources) {
> >>>> + for (auto *MappingSource : MappingSources) {
> >>>> for (auto DiagIDMappingPair :
> MappingSource->getDiagnosticMappings()) {
> >>>> diag::kind DiagID = DiagIDMappingPair.first;
> >>>> Level CurLevel = Diags.getDiagnosticLevel(DiagID,
> SourceLocation());
> >>>> @@ -581,9 +582,9 @@ static void
> >>>> collectMacroDefinitions(const PreprocessorOptions &PPOpts,
> >>>> MacroDefinitionsMap &Macros,
> >>>> SmallVectorImpl<StringRef> *MacroNames =
> nullptr) {
> >>>> - for (unsigned I = 0, N = PPOpts.Macros.size(); I != N; ++I) {
> >>>> - StringRef Macro = PPOpts.Macros[I].first;
> >>>> - bool IsUndef = PPOpts.Macros[I].second;
> >>>> + for (const auto &I : PPOpts.Macros) {
> >>>> + StringRef Macro = I.first;
> >>>> + bool IsUndef = I.second;
> >>>>
> >>>> std::pair<StringRef, StringRef> MacroPair = Macro.split('=');
> >>>> StringRef MacroName = MacroPair.first;
> >>>> @@ -634,9 +635,8 @@ static bool checkPreprocessorOptions(con
> >>>> SmallVector<StringRef, 4> ExistingMacroNames;
> >>>> collectMacroDefinitions(ExistingPPOpts, ExistingMacros,
> &ExistingMacroNames);
> >>>>
> >>>> - for (unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
> >>>> + for (auto MacroName : ExistingMacroNames) {
> >>>> // 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,8 +702,7 @@ static bool checkPreprocessorOptions(con
> >>>> }
> >>>>
> >>>> // Compute the #include and #include_macros lines we need.
> >>>> - for (unsigned I = 0, N = ExistingPPOpts.Includes.size(); I != N;
> ++I) {
> >>>> - StringRef File = ExistingPPOpts.Includes[I];
> >>>> + for (const auto &File : ExistingPPOpts.Includes) {
> >>>> if (File == ExistingPPOpts.ImplicitPCHInclude)
> >>>> continue;
> >>>>
> >>>> @@ -716,8 +715,7 @@ static bool checkPreprocessorOptions(con
> >>>> SuggestedPredefines += "\"\n";
> >>>> }
> >>>>
> >>>> - for (unsigned I = 0, N = ExistingPPOpts.MacroIncludes.size(); I !=
> N; ++I) {
> >>>> - StringRef File = ExistingPPOpts.MacroIncludes[I];
> >>>> + for (const auto &File : ExistingPPOpts.MacroIncludes) {
> >>>> if (std::find(PPOpts.MacroIncludes.begin(),
> PPOpts.MacroIncludes.end(),
> >>>> File)
> >>>> != PPOpts.MacroIncludes.end())
> >>>> @@ -855,14 +853,14 @@ ASTSelectorLookupTrait::ReadData(Selecto
> >>>>
> >>>> // Load instance methods
> >>>> for (unsigned I = 0; I != NumInstanceMethods; ++I) {
> >>>> - if (ObjCMethodDecl *Method =
> Reader.GetLocalDeclAs<ObjCMethodDecl>(
> >>>> + if (auto *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 (ObjCMethodDecl *Method =
> Reader.GetLocalDeclAs<ObjCMethodDecl>(
> >>>> + if (auto *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>(
> >>>> F, endian::readNext<uint32_t, little, unaligned>(d)))
> >>>> Result.Factory.push_back(Method);
> >>>> }
> >>>> @@ -1087,7 +1085,7 @@ ASTDeclContextNameLookupTrait::internal_
> >>>> ASTDeclContextNameLookupTrait::ReadKey(const unsigned char *d,
> unsigned) {
> >>>> using namespace llvm::support;
> >>>>
> >>>> - auto Kind = (DeclarationName::NameKind)*d++;
> >>>> + auto Kind = static_cast<DeclarationName::NameKind>(*d++);
> >>>> uint64_t Data;
> >>>> switch (Kind) {
> >>>> case DeclarationName::Identifier:
> >>>> @@ -1246,8 +1244,7 @@ bool ASTReader::ParseLineTable(ModuleFil
> >>>> unsigned FileOffset = Record[Idx++];
> >>>> unsigned LineNo = Record[Idx++];
> >>>> int FilenameID = FileIDs[Record[Idx++]];
> >>>> - SrcMgr::CharacteristicKind FileKind
> >>>> - = (SrcMgr::CharacteristicKind)Record[Idx++];
> >>>> + auto FileKind =
> static_cast<SrcMgr::CharacteristicKind>(Record[Idx++]);
> >>>> unsigned IncludeOffset = Record[Idx++];
> >>>> Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID,
> >>>> FileKind, IncludeOffset));
> >>>> @@ -1427,12 +1424,11 @@ bool ASTReader::ReadSLocEntry(int ID) {
> >>>> // This is the module's main file.
> >>>> IncludeLoc = getImportLocation(F);
> >>>> }
> >>>> - SrcMgr::CharacteristicKind
> >>>> - FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
> >>>> + auto FileCharacter =
> static_cast<SrcMgr::CharacteristicKind>(Record[2]);
> >>>> FileID FID = SourceMgr.createFileID(File, IncludeLoc,
> FileCharacter,
> >>>> ID, BaseOffset + Record[0]);
> >>>> - SrcMgr::FileInfo &FileInfo =
> >>>> -
> const_cast<SrcMgr::FileInfo&>(SourceMgr.getSLocEntry(FID).getFile());
> >>>> + auto &FileInfo =
> >>>> + const_cast<SrcMgr::FileInfo
> &>(SourceMgr.getSLocEntry(FID).getFile());
> >>>> FileInfo.NumCreatedFIDs = Record[5];
> >>>> if (Record[3])
> >>>> FileInfo.setHasLineDirectives();
> >>>> @@ -1462,8 +1458,7 @@ bool ASTReader::ReadSLocEntry(int ID) {
> >>>> case SM_SLOC_BUFFER_ENTRY: {
> >>>> const char *Name = Blob.data();
> >>>> unsigned Offset = Record[0];
> >>>> - SrcMgr::CharacteristicKind
> >>>> - FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
> >>>> + auto FileCharacter =
> static_cast<SrcMgr::CharacteristicKind>(Record[2]);
> >>>> SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
> >>>> if (IncludeLoc.isInvalid() && F->isModule()) {
> >>>> IncludeLoc = getImportLocation(F);
> >>>> @@ -1592,8 +1587,8 @@ MacroInfo *ASTReader::ReadMacroRecord(Mo
> >>>>
> >>>> // Read a record.
> >>>> Record.clear();
> >>>> - PreprocessorRecordTypes RecType =
> >>>> - (PreprocessorRecordTypes)Stream.readRecord(Entry.ID, Record);
> >>>> + auto RecType = static_cast<PreprocessorRecordTypes>(
> >>>> + Stream.readRecord(Entry.ID, Record));
> >>>> switch (RecType) {
> >>>> case PP_MODULE_MACRO:
> >>>> case PP_MACRO_DIRECTIVE_HISTORY:
> >>>> @@ -1644,7 +1639,7 @@ MacroInfo *ASTReader::ReadMacroRecord(Mo
> >>>> PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
> >>>> PreprocessingRecord::PPEntityID PPID =
> >>>> PPRec.getPPEntityID(GlobalID - 1, /*isLoaded=*/true);
> >>>> - MacroDefinitionRecord *PPDef =
> cast_or_null<MacroDefinitionRecord>(
> >>>> + auto *PPDef = cast_or_null<MacroDefinitionRecord>(
> >>>> PPRec.getPreprocessedEntity(PPID));
> >>>> if (PPDef)
> >>>> PPRec.RegisterMacroDefinition(Macro, PPDef);
> >>>> @@ -1721,8 +1716,9 @@ std::pair<unsigned, unsigned>
> >>>> HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) {
> >>>> using namespace llvm::support;
> >>>>
> >>>> - unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little,
> unaligned>(d);
> >>>> - unsigned DataLen = (unsigned) *d++;
> >>>> + auto KeyLen = static_cast<unsigned>(
> >>>> + endian::readNext<uint16_t, little, unaligned>(d));
> >>>> + auto DataLen = static_cast<unsigned>(*d++);
> >>>> return std::make_pair(KeyLen, DataLen);
> >>>> }
> >>>>
> >>>> @@ -1808,7 +1804,7 @@ void ASTReader::ReadDefinedMacros() {
> >>>> // Note that we are loading defined macros.
> >>>> Deserializing Macros(this);
> >>>>
> >>>> - for (ModuleFile &I : llvm::reverse(ModuleMgr)) {
> >>>> + for (auto &I : llvm::reverse(ModuleMgr)) {
> >>>> BitstreamCursor &MacroCursor = I.MacroCursor;
> >>>>
> >>>> // If there was no preprocessor block, skip this file.
> >>>> @@ -1880,8 +1876,8 @@ namespace {
> >>>> if (M.Generation <= PriorGeneration)
> >>>> return true;
> >>>>
> >>>> - ASTIdentifierLookupTable *IdTable
> >>>> - = (ASTIdentifierLookupTable *)M.IdentifierLookupTable;
> >>>> + auto *IdTable =
> >>>> + static_cast<ASTIdentifierLookupTable
> *>(M.IdentifierLookupTable);
> >>>> if (!IdTable)
> >>>> return false;
> >>>>
> >>>> @@ -2002,7 +1998,7 @@ void ASTReader::resolvePendingMacro(Iden
> >>>> llvm::SmallVector<ModuleMacro*, 8> Overrides;
> >>>> for (auto &MMR : ModuleMacros) {
> >>>> Overrides.clear();
> >>>> - for (unsigned ModID : MMR.Overrides) {
> >>>> + for (auto ModID : MMR.Overrides) {
> >>>> Module *Mod = getSubmodule(ModID);
> >>>> auto *Macro = PP.getModuleMacro(Mod, II);
> >>>> assert(Macro && "missing definition for overridden macro");
> >>>> @@ -2026,7 +2022,7 @@ void ASTReader::resolvePendingMacro(Iden
> >>>> while (Idx < N) {
> >>>> MacroDirective *MD = nullptr;
> >>>> SourceLocation Loc = ReadSourceLocation(M, Record, Idx);
> >>>> - MacroDirective::Kind K = (MacroDirective::Kind)Record[Idx++];
> >>>> + auto K = static_cast<MacroDirective::Kind>(Record[Idx++]);
> >>>> switch (K) {
> >>>> case MacroDirective::MD_Define: {
> >>>> MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++]));
> >>>> @@ -2082,6 +2078,7 @@ 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())
> >>>> @@ -2520,14 +2517,14 @@ ASTReader::ReadControlBlock(ModuleFile &
> >>>> unsigned Idx = 0, N = Record.size();
> >>>> while (Idx < N) {
> >>>> // Read information about the AST file.
> >>>> - ModuleKind ImportedKind = (ModuleKind)Record[Idx++];
> >>>> + auto ImportedKind = static_cast<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++]);
> >>>> - off_t StoredSize = (off_t)Record[Idx++];
> >>>> - time_t StoredModTime = (time_t)Record[Idx++];
> >>>> + auto StoredSize = static_cast<off_t>(Record[Idx++]);
> >>>> + auto StoredModTime = static_cast<time_t>(Record[Idx++]);
> >>>> ASTFileSignature StoredSignature = {
> >>>> {{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
> >>>> (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
> >>>> @@ -2604,7 +2601,6 @@ ASTReader::ReadControlBlock(ModuleFile &
> >>>> // failure.
> >>>> if (ASTReadResult Result = readUnhashedControlBlockOnce())
> >>>> return Result;
> >>>> -
> >>>> break;
> >>>>
> >>>> case MODULE_DIRECTORY: {
> >>>> @@ -3485,7 +3481,8 @@ void ASTReader::ReadModuleOffsetMap(Modu
> >>>> assert(!F.ModuleOffsetMap.empty() && "no module offset map to
> read");
> >>>>
> >>>> // Additional remapping information.
> >>>> - const unsigned char *Data = (const unsigned
> char*)F.ModuleOffsetMap.data();
> >>>> + const auto *Data =
> >>>> + reinterpret_cast<const unsigned char
> *>(F.ModuleOffsetMap.data());
> >>>> const unsigned char *DataEnd = Data + F.ModuleOffsetMap.size();
> >>>> F.ModuleOffsetMap = StringRef();
> >>>>
> >>>> @@ -3511,8 +3508,8 @@ void ASTReader::ReadModuleOffsetMap(Modu
> >>>> // start fixing this with prebuilt and explicit modules and see
> how it
> >>>> // goes...
> >>>> using namespace llvm::support;
> >>>> - ModuleKind Kind = static_cast<ModuleKind>(
> >>>> - endian::readNext<uint8_t, little, unaligned>(Data));
> >>>> + auto 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;
> >>>> @@ -3640,7 +3637,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 FileEntry *ModMap : *AdditionalModuleMaps) {
> >>>> + for (const auto *ModMap : *AdditionalModuleMaps) {
> >>>> // Remove files that match
> >>>> // Note: SmallPtrSet::erase is really remove
> >>>> if (!AdditionalStoredMaps.erase(ModMap)) {
> >>>> @@ -3654,7 +3651,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 FileEntry *ModMap : AdditionalStoredMaps) {
> >>>> + for (const auto *ModMap : AdditionalStoredMaps) {
> >>>> if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
> >>>> Diag(diag::err_module_different_modmap)
> >>>> << F.ModuleName << /*not new*/1 << ModMap->getName();
> >>>> @@ -3698,15 +3695,13 @@ static void moveMethodToBackOfGlobalList
> >>>>
> >>>> void ASTReader::makeNamesVisible(const HiddenNames &Names, Module
> *Owner) {
> >>>> assert(Owner->NameVisibility != Module::Hidden && "nothing to make
> visible?");
> >>>> - for (Decl *D : Names) {
> >>>> + for (auto *D : Names) {
> >>>> bool wasHidden = D->isHidden();
> >>>> D->setVisibleDespiteOwningModule();
> >>>>
> >>>> - if (wasHidden && SemaObj) {
> >>>> - if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(D)) {
> >>>> + if (wasHidden && SemaObj)
> >>>> + if (auto *Method = dyn_cast<ObjCMethodDecl>(D))
> >>>> moveMethodToBackOfGlobalList(*SemaObj, Method);
> >>>> - }
> >>>> - }
> >>>> }
> >>>> }
> >>>>
> >>>> @@ -3747,12 +3742,9 @@ void ASTReader::makeModuleVisible(Module
> >>>> // Push any exported modules onto the stack to be marked as
> visible.
> >>>> SmallVector<Module *, 16> Exports;
> >>>> Mod->getExportedModules(Exports);
> >>>> - for (SmallVectorImpl<Module *>::iterator
> >>>> - I = Exports.begin(), E = Exports.end(); I != E; ++I) {
> >>>> - Module *Exported = *I;
> >>>> + for (auto *Exported : Exports)
> >>>> if (Visited.insert(Exported).second)
> >>>> Stack.push_back(Exported);
> >>>> - }
> >>>> }
> >>>> }
> >>>>
> >>>> @@ -3879,7 +3871,7 @@ ASTReader::ASTReadResult ASTReader::Read
> >>>> case ConfigurationMismatch:
> >>>> case HadErrors: {
> >>>> llvm::SmallPtrSet<ModuleFile *, 4> LoadedSet;
> >>>> - for (const ImportedModule &IM : Loaded)
> >>>> + for (const auto &IM : Loaded)
> >>>> LoadedSet.insert(IM.Mod);
> >>>>
> >>>> ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, LoadedSet,
> >>>> @@ -3900,10 +3892,8 @@ 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 (SmallVectorImpl<ImportedModule>::iterator M = Loaded.begin(),
> >>>> - MEnd = Loaded.end();
> >>>> - M != MEnd; ++M) {
> >>>> - ModuleFile &F = *M->Mod;
> >>>> + for (auto &M : Loaded) {
> >>>> + ModuleFile &F = *M.Mod;
> >>>>
> >>>> // Read the AST block.
> >>>> if (ASTReadResult Result = ReadASTBlock(F,
> ClientLoadCapabilities))
> >>>> @@ -3922,8 +3912,8 @@ ASTReader::ASTReadResult ASTReader::Read
> >>>> GlobalBitOffsetsMap.insert(std::make_pair(F.GlobalBitOffset, &F));
> >>>>
> >>>> // Preload SLocEntries.
> >>>> - for (unsigned I = 0, N = F.PreloadSLocEntries.size(); I != N;
> ++I) {
> >>>> - int Index = int(F.PreloadSLocEntries[I] - 1) +
> F.SLocEntryBaseID;
> >>>> + for (const auto PreloadSLocEntry : F.PreloadSLocEntries) {
> >>>> + int Index = int(PreloadSLocEntry - 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
> >>>> @@ -3941,7 +3931,7 @@ ASTReader::ASTReadResult ASTReader::Read
> >>>> // Preload all the pending interesting identifiers by marking
> them out of
> >>>> // date.
> >>>> for (auto Offset : F.PreloadIdentifierOffsets) {
> >>>> - const unsigned char *Data = reinterpret_cast<const unsigned
> char *>(
> >>>> + const auto *Data = reinterpret_cast<const unsigned char *>(
> >>>> F.IdentifierTableData + Offset);
> >>>>
> >>>> ASTIdentifierLookupTrait Trait(*this, F);
> >>>> @@ -3962,10 +3952,8 @@ ASTReader::ASTReadResult ASTReader::Read
> >>>>
> >>>> // Setup the import locations and notify the module manager that
> we've
> >>>> // committed to these module files.
> >>>> - for (SmallVectorImpl<ImportedModule>::iterator M = Loaded.begin(),
> >>>> - MEnd = Loaded.end();
> >>>> - M != MEnd; ++M) {
> >>>> - ModuleFile &F = *M->Mod;
> >>>> + for (auto &M : Loaded) {
> >>>> + ModuleFile &F = *M.Mod;
> >>>>
> >>>> ModuleMgr.moduleFileAccepted(&F);
> >>>>
> >>>> @@ -3973,10 +3961,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 ||
> >>>> @@ -3989,18 +3977,15 @@ 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 (IdentifierTable::iterator Id =
> PP.getIdentifierTable().begin(),
> >>>> - IdEnd =
> PP.getIdentifierTable().end();
> >>>> - Id != IdEnd; ++Id)
> >>>> - Id->second->setOutOfDate(true);
> >>>> + for (auto &Id : PP.getIdentifierTable())
> >>>> + Id.second->setOutOfDate(true);
> >>>> }
> >>>> // Mark selectors as out of date.
> >>>> for (auto Sel : SelectorGeneration)
> >>>> SelectorOutOfDate[Sel.first] = true;
> >>>>
> >>>> // Resolve any unresolved module exports.
> >>>> - for (unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I)
> {
> >>>> - UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I];
> >>>> + for (auto &Unresolved : UnresolvedModuleRefs) {
> >>>> SubmoduleID GlobalID =
> getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
> >>>> Module *ResolvedMod = getSubmodule(GlobalID);
> >>>>
> >>>> @@ -4059,13 +4044,10 @@ 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 (unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
> >>>> - loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
> >>>> - ObjCClassesLoaded[I],
> >>>> + if (ContextObj)
> >>>> + for (auto *ObjCClassLoaded : ObjCClassesLoaded)
> >>>> + loadObjCCategories(ObjCClassLoaded->getGlobalID(),
> ObjCClassLoaded,
> >>>> PreviousGeneration);
> >>>> - }
> >>>> - }
> >>>>
> >>>> if (PP.getHeaderSearchInfo()
> >>>> .getHeaderSearchOpts()
> >>>> @@ -4074,12 +4056,9 @@ 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 (unsigned I = 0, N = Loaded.size(); I != N; ++I) {
> >>>> - ImportedModule &M = Loaded[I];
> >>>> - if (M.Mod->Kind == MK_ImplicitModule) {
> >>>> + for (auto &M : Loaded)
> >>>> + if (M.Mod->Kind == MK_ImplicitModule)
> >>>> updateModuleTimestamp(*M.Mod);
> >>>> - }
> >>>> - }
> >>>> }
> >>>>
> >>>> return Success;
> >>>> @@ -4462,10 +4441,10 @@ void ASTReader::InitializeContext() {
> >>>> }
> >>>>
> >>>> if (!Context.FILEDecl) {
> >>>> - if (const TypedefType *Typedef =
> FileType->getAs<TypedefType>())
> >>>> + if (const auto *Typedef = FileType->getAs<TypedefType>())
> >>>> Context.setFILEDecl(Typedef->getDecl());
> >>>> else {
> >>>> - const TagType *Tag = FileType->getAs<TagType>();
> >>>> + const auto *Tag = FileType->getAs<TagType>();
> >>>> if (!Tag) {
> >>>> Error("Invalid FILE type in AST file");
> >>>> return;
> >>>> @@ -4483,10 +4462,10 @@ void ASTReader::InitializeContext() {
> >>>> }
> >>>>
> >>>> if (!Context.jmp_bufDecl) {
> >>>> - if (const TypedefType *Typedef =
> Jmp_bufType->getAs<TypedefType>())
> >>>> + if (const auto *Typedef = Jmp_bufType->getAs<TypedefType>())
> >>>> Context.setjmp_bufDecl(Typedef->getDecl());
> >>>> else {
> >>>> - const TagType *Tag = Jmp_bufType->getAs<TagType>();
> >>>> + const auto *Tag = Jmp_bufType->getAs<TagType>();
> >>>> if (!Tag) {
> >>>> Error("Invalid jmp_buf type in AST file");
> >>>> return;
> >>>> @@ -4504,10 +4483,10 @@ void ASTReader::InitializeContext() {
> >>>> }
> >>>>
> >>>> if (!Context.sigjmp_bufDecl) {
> >>>> - if (const TypedefType *Typedef =
> Sigjmp_bufType->getAs<TypedefType>())
> >>>> + if (const auto *Typedef =
> Sigjmp_bufType->getAs<TypedefType>())
> >>>> Context.setsigjmp_bufDecl(Typedef->getDecl());
> >>>> else {
> >>>> - const TagType *Tag = Sigjmp_bufType->getAs<TagType>();
> >>>> + const auto *Tag = Sigjmp_bufType->getAs<TagType>();
> >>>> assert(Tag && "Invalid sigjmp_buf type in AST file");
> >>>> Context.setsigjmp_bufDecl(Tag->getDecl());
> >>>> }
> >>>> @@ -4540,10 +4519,10 @@ void ASTReader::InitializeContext() {
> >>>> }
> >>>>
> >>>> if (!Context.ucontext_tDecl) {
> >>>> - if (const TypedefType *Typedef =
> Ucontext_tType->getAs<TypedefType>())
> >>>> + if (const auto *Typedef =
> Ucontext_tType->getAs<TypedefType>())
> >>>> Context.setucontext_tDecl(Typedef->getDecl());
> >>>> else {
> >>>> - const TagType *Tag = Ucontext_tType->getAs<TagType>();
> >>>> + const auto *Tag = Ucontext_tType->getAs<TagType>();
> >>>> assert(Tag && "Invalid ucontext_t type in AST file");
> >>>> Context.setucontext_tDecl(Tag->getDecl());
> >>>> }
> >>>> @@ -4583,18 +4562,18 @@ void ASTReader::finalizeForWriting() {
> >>>> static ASTFileSignature readASTFileSignature(StringRef PCH) {
> >>>> BitstreamCursor Stream(PCH);
> >>>> if (!startsWithASTFileMagic(Stream))
> >>>> - return ASTFileSignature();
> >>>> + return {};
> >>>>
> >>>> // Scan for the UNHASHED_CONTROL_BLOCK_ID block.
> >>>> if (SkipCursorToBlock(Stream, UNHASHED_CONTROL_BLOCK_ID))
> >>>> - return ASTFileSignature();
> >>>> + return {};
> >>>>
> >>>> // 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 ASTFileSignature();
> >>>> + return {};
> >>>>
> >>>> Record.clear();
> >>>> StringRef Blob;
> >>>> @@ -4615,7 +4594,7 @@ std::string ASTReader::getOriginalSource
> >>>> if (!Buffer) {
> >>>> Diags.Report(diag::err_fe_unable_to_read_pch_file)
> >>>> << ASTFileName << Buffer.getError().message();
> >>>> - return std::string();
> >>>> + return {};
> >>>> }
> >>>>
> >>>> // Initialize the stream
> >>>> @@ -4624,13 +4603,13 @@ std::string ASTReader::getOriginalSource
> >>>> // Sniff for the signature.
> >>>> if (!startsWithASTFileMagic(Stream)) {
> >>>> Diags.Report(diag::err_fe_not_a_pch_file) << ASTFileName;
> >>>> - return std::string();
> >>>> + return {};
> >>>> }
> >>>>
> >>>> // Scan for the CONTROL_BLOCK_ID block.
> >>>> if (SkipCursorToBlock(Stream, CONTROL_BLOCK_ID)) {
> >>>> Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName;
> >>>> - return std::string();
> >>>> + return {};
> >>>> }
> >>>>
> >>>> // Scan for ORIGINAL_FILE inside the control block.
> >>>> @@ -4638,11 +4617,11 @@ std::string ASTReader::getOriginalSource
> >>>> while (true) {
> >>>> llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
> >>>> if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
> >>>> - return std::string();
> >>>> + return {};
> >>>>
> >>>> if (Entry.Kind != llvm::BitstreamEntry::Record) {
> >>>> Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName;
> >>>> - return std::string();
> >>>> + return {};
> >>>> }
> >>>>
> >>>> Record.clear();
> >>>> @@ -4810,7 +4789,8 @@ bool ASTReader::readASTFileControlBlock(
> >>>>
> >>>> unsigned NumInputFiles = Record[0];
> >>>> unsigned NumUserFiles = Record[1];
> >>>> - const uint64_t *InputFileOffs = (const uint64_t *)Blob.data();
> >>>> + const auto *InputFileOffs =
> >>>> + reinterpret_cast<const uint64_t *>(Blob.data());
> >>>> for (unsigned I = 0; I != NumInputFiles; ++I) {
> >>>> // Go find this input file.
> >>>> bool isSystemFile = I >= NumUserFiles;
> >>>> @@ -4828,7 +4808,7 @@ bool ASTReader::readASTFileControlBlock(
> >>>> bool shouldContinue = false;
> >>>> switch ((InputFileRecordTypes)Cursor.readRecord(Code, Record,
> &Blob)) {
> >>>> case INPUT_FILE:
> >>>> - bool Overridden = static_cast<bool>(Record[3]);
> >>>> + auto Overridden = static_cast<bool>(Record[3]);
> >>>> std::string Filename = Blob;
> >>>> ResolveImportedPath(Filename, ModuleDir);
> >>>> shouldContinue = Listener.visitInputFile(
> >>>> @@ -4989,7 +4969,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
> >>>> unsigned Idx = 0;
> >>>> SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
> >>>> SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);
> >>>> - Module::ModuleKind Kind = (Module::ModuleKind)Record[Idx++];
> >>>> + auto Kind = static_cast<Module::ModuleKind>(Record[Idx++]);
> >>>> bool IsFramework = Record[Idx++];
> >>>> bool IsExplicit = Record[Idx++];
> >>>> bool IsSystem = Record[Idx++];
> >>>> @@ -5233,7 +5213,7 @@ bool ASTReader::ParseLanguageOptions(con
> >>>> for (unsigned N = Record[Idx++]; N; --N)
> >>>> LangOpts.ModuleFeatures.push_back(ReadString(Record, Idx));
> >>>>
> >>>> - ObjCRuntime::Kind runtimeKind = (ObjCRuntime::Kind) Record[Idx++];
> >>>> + auto runtimeKind = static_cast<ObjCRuntime::Kind>(Record[Idx++]);
> >>>> VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
> >>>> LangOpts.ObjCRuntime = ObjCRuntime(runtimeKind, runtimeVersion);
> >>>>
> >>>> @@ -5311,8 +5291,7 @@ bool ASTReader::ParseHeaderSearchOptions
> >>>> // Include entries.
> >>>> for (unsigned N = Record[Idx++]; N; --N) {
> >>>> std::string Path = ReadString(Record, Idx);
> >>>> - frontend::IncludeDirGroup Group
> >>>> - = static_cast<frontend::IncludeDirGroup>(Record[Idx++]);
> >>>> + auto Group =
> static_cast<frontend::IncludeDirGroup>(Record[Idx++]);
> >>>> bool IsFramework = Record[Idx++];
> >>>> bool IgnoreSysRoot = Record[Idx++];
> >>>> HSOpts.UserEntries.emplace_back(std::move(Path), Group,
> IsFramework,
> >>>> @@ -5446,9 +5425,8 @@ PreprocessedEntity *ASTReader::ReadPrepr
> >>>> PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
> >>>> StringRef Blob;
> >>>> RecordData Record;
> >>>> - PreprocessorDetailRecordTypes RecType =
> >>>> -
> (PreprocessorDetailRecordTypes)M.PreprocessorDetailCursor.readRecord(
> >>>> - Entry.ID, Record, &Blob);
> >>>> + auto RecType = static_cast<PreprocessorDetailRecordTypes>(
> >>>> + M.PreprocessorDetailCursor.readRecord(Entry.ID, Record,
> &Blob));
> >>>> switch (RecType) {
> >>>> case PPD_MACRO_EXPANSION: {
> >>>> bool isBuiltin = Record[0];
> >>>> @@ -5476,7 +5454,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]);
> >>>> - MacroDefinitionRecord *MD = new (PPRec)
> MacroDefinitionRecord(II, Range);
> >>>> + auto *MD = new (PPRec) MacroDefinitionRecord(II, Range);
> >>>>
> >>>> if (DeserializationListener)
> >>>> DeserializationListener->MacroDefinitionRead(PPID, MD);
> >>>> @@ -5492,10 +5470,9 @@ PreprocessedEntity *ASTReader::ReadPrepr
> >>>> File = PP.getFileManager().getFile(FullFileName);
> >>>>
> >>>> // FIXME: Stable encoding
> >>>> - InclusionDirective::InclusionKind Kind
> >>>> - = static_cast<InclusionDirective::InclusionKind>(Record[2]);
> >>>> - InclusionDirective *ID
> >>>> - = new (PPRec) InclusionDirective(PPRec, Kind,
> >>>> + auto Kind =
> static_cast<InclusionDirective::InclusionKind>(Record[2]);
> >>>> + auto *ID =
> >>>> + new (PPRec) InclusionDirective(PPRec, Kind,
> >>>> StringRef(Blob.data(),
> Record[0]),
> >>>> Record[1], Record[3],
> >>>> File,
> >>>> @@ -5657,8 +5634,8 @@ namespace {
> >>>> explicit HeaderFileInfoVisitor(const FileEntry *FE) : FE(FE) {}
> >>>>
> >>>> bool operator()(ModuleFile &M) {
> >>>> - HeaderFileInfoLookupTable *Table
> >>>> - = static_cast<HeaderFileInfoLookupTable
> *>(M.HeaderFileInfoTable);
> >>>> + auto *Table =
> >>>> + static_cast<HeaderFileInfoLookupTable
> *>(M.HeaderFileInfoTable);
> >>>> if (!Table)
> >>>> return false;
> >>>>
> >>>> @@ -5689,7 +5666,7 @@ void ASTReader::ReadPragmaDiagnosticMapp
> >>>> using DiagState = DiagnosticsEngine::DiagState;
> >>>> SmallVector<DiagState *, 32> DiagStates;
> >>>>
> >>>> - for (ModuleFile &F : ModuleMgr) {
> >>>> + for (auto &F : ModuleMgr) {
> >>>> unsigned Idx = 0;
> >>>> auto &Record = F.PragmaDiagMappings;
> >>>> if (Record.empty())
> >>>> @@ -5865,7 +5842,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_EXT_QUAL: {
> >>>> if (Record.size() != 2) {
> >>>> Error("Incorrect encoding of extended qualifier type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType Base = readType(*Loc.F, Record, Idx);
> >>>> Qualifiers Quals = Qualifiers::fromOpaqueValue(Record[Idx++]);
> >>>> @@ -5875,7 +5852,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_COMPLEX: {
> >>>> if (Record.size() != 1) {
> >>>> Error("Incorrect encoding of complex type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType ElemType = readType(*Loc.F, Record, Idx);
> >>>> return Context.getComplexType(ElemType);
> >>>> @@ -5884,7 +5861,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_POINTER: {
> >>>> if (Record.size() != 1) {
> >>>> Error("Incorrect encoding of pointer type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType PointeeType = readType(*Loc.F, Record, Idx);
> >>>> return Context.getPointerType(PointeeType);
> >>>> @@ -5893,7 +5870,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_DECAYED: {
> >>>> if (Record.size() != 1) {
> >>>> Error("Incorrect encoding of decayed type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType OriginalType = readType(*Loc.F, Record, Idx);
> >>>> QualType DT = Context.getAdjustedParameterType(OriginalType);
> >>>> @@ -5905,7 +5882,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_ADJUSTED: {
> >>>> if (Record.size() != 2) {
> >>>> Error("Incorrect encoding of adjusted type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType OriginalTy = readType(*Loc.F, Record, Idx);
> >>>> QualType AdjustedTy = readType(*Loc.F, Record, Idx);
> >>>> @@ -5915,7 +5892,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_BLOCK_POINTER: {
> >>>> if (Record.size() != 1) {
> >>>> Error("Incorrect encoding of block pointer type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType PointeeType = readType(*Loc.F, Record, Idx);
> >>>> return Context.getBlockPointerType(PointeeType);
> >>>> @@ -5924,7 +5901,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_LVALUE_REFERENCE: {
> >>>> if (Record.size() != 2) {
> >>>> Error("Incorrect encoding of lvalue reference type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType PointeeType = readType(*Loc.F, Record, Idx);
> >>>> return Context.getLValueReferenceType(PointeeType, Record[1]);
> >>>> @@ -5933,7 +5910,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_RVALUE_REFERENCE: {
> >>>> if (Record.size() != 1) {
> >>>> Error("Incorrect encoding of rvalue reference type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType PointeeType = readType(*Loc.F, Record, Idx);
> >>>> return Context.getRValueReferenceType(PointeeType);
> >>>> @@ -5942,19 +5919,19 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_MEMBER_POINTER: {
> >>>> if (Record.size() != 2) {
> >>>> Error("Incorrect encoding of member pointer type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType PointeeType = readType(*Loc.F, Record, Idx);
> >>>> QualType ClassType = readType(*Loc.F, Record, Idx);
> >>>> if (PointeeType.isNull() || ClassType.isNull())
> >>>> - return QualType();
> >>>> + return {};
> >>>>
> >>>> return Context.getMemberPointerType(PointeeType,
> ClassType.getTypePtr());
> >>>> }
> >>>>
> >>>> case TYPE_CONSTANT_ARRAY: {
> >>>> QualType ElementType = readType(*Loc.F, Record, Idx);
> >>>> - ArrayType::ArraySizeModifier ASM =
> (ArrayType::ArraySizeModifier)Record[1];
> >>>> + auto ASM = static_cast<ArrayType::ArraySizeModifier>(Record[1]);
> >>>> unsigned IndexTypeQuals = Record[2];
> >>>> unsigned Idx = 3;
> >>>> llvm::APInt Size = ReadAPInt(Record, Idx);
> >>>> @@ -5964,14 +5941,14 @@ QualType ASTReader::readTypeRecord(unsig
> >>>>
> >>>> case TYPE_INCOMPLETE_ARRAY: {
> >>>> QualType ElementType = readType(*Loc.F, Record, Idx);
> >>>> - ArrayType::ArraySizeModifier ASM =
> (ArrayType::ArraySizeModifier)Record[1];
> >>>> + auto ASM = static_cast<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);
> >>>> - ArrayType::ArraySizeModifier ASM =
> (ArrayType::ArraySizeModifier)Record[1];
> >>>> + auto ASM = static_cast<ArrayType::ArraySizeModifier>(Record[1]);
> >>>> unsigned IndexTypeQuals = Record[2];
> >>>> SourceLocation LBLoc = ReadSourceLocation(*Loc.F, Record[3]);
> >>>> SourceLocation RBLoc = ReadSourceLocation(*Loc.F, Record[4]);
> >>>> @@ -5983,7 +5960,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_VECTOR: {
> >>>> if (Record.size() != 3) {
> >>>> Error("incorrect encoding of vector type in AST file");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>>
> >>>> QualType ElementType = readType(*Loc.F, Record, Idx);
> >>>> @@ -5996,7 +5973,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_EXT_VECTOR: {
> >>>> if (Record.size() != 3) {
> >>>> Error("incorrect encoding of extended vector type in AST file");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>>
> >>>> QualType ElementType = readType(*Loc.F, Record, Idx);
> >>>> @@ -6007,7 +5984,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_FUNCTION_NO_PROTO: {
> >>>> if (Record.size() != 8) {
> >>>> Error("incorrect encoding of no-proto function type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType ResultType = readType(*Loc.F, Record, Idx);
> >>>> FunctionType::ExtInfo Info(Record[1], Record[2], Record[3],
> >>>> @@ -6065,10 +6042,10 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_TYPEDEF: {
> >>>> if (Record.size() != 2) {
> >>>> Error("incorrect encoding of typedef type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> unsigned Idx = 0;
> >>>> - TypedefNameDecl *Decl = ReadDeclAs<TypedefNameDecl>(*Loc.F,
> Record, Idx);
> >>>> + auto *Decl = ReadDeclAs<TypedefNameDecl>(*Loc.F, Record, Idx);
> >>>> QualType Canonical = readType(*Loc.F, Record, Idx);
> >>>> if (!Canonical.isNull())
> >>>> Canonical = Context.getCanonicalType(Canonical);
> >>>> @@ -6081,7 +6058,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_TYPEOF: {
> >>>> if (Record.size() != 1) {
> >>>> Error("incorrect encoding of typeof(type) in AST file");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType UnderlyingType = readType(*Loc.F, Record, Idx);
> >>>> return Context.getTypeOfType(UnderlyingType);
> >>>> @@ -6095,13 +6072,13 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_UNARY_TRANSFORM: {
> >>>> QualType BaseType = readType(*Loc.F, Record, Idx);
> >>>> QualType UnderlyingType = readType(*Loc.F, Record, Idx);
> >>>> - UnaryTransformType::UTTKind UKind =
> (UnaryTransformType::UTTKind)Record[2];
> >>>> + auto UKind = static_cast<UnaryTransformType::UTTKind>(Record[2]);
> >>>> return Context.getUnaryTransformType(BaseType, UnderlyingType,
> UKind);
> >>>> }
> >>>>
> >>>> case TYPE_AUTO: {
> >>>> QualType Deduced = readType(*Loc.F, Record, Idx);
> >>>> - AutoTypeKeyword Keyword = (AutoTypeKeyword)Record[Idx++];
> >>>> + auto Keyword = static_cast<AutoTypeKeyword>(Record[Idx++]);
> >>>> bool IsDependent = Deduced.isNull() ? Record[Idx++] : false;
> >>>> return Context.getAutoType(Deduced, Keyword, IsDependent);
> >>>> }
> >>>> @@ -6117,11 +6094,11 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_RECORD: {
> >>>> if (Record.size() != 2) {
> >>>> Error("incorrect encoding of record type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> unsigned Idx = 0;
> >>>> bool IsDependent = Record[Idx++];
> >>>> - RecordDecl *RD = ReadDeclAs<RecordDecl>(*Loc.F, Record, Idx);
> >>>> + auto *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);
> >>>> @@ -6131,7 +6108,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_ENUM: {
> >>>> if (Record.size() != 2) {
> >>>> Error("incorrect encoding of enum type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> unsigned Idx = 0;
> >>>> bool IsDependent = Record[Idx++];
> >>>> @@ -6144,18 +6121,18 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_ATTRIBUTED: {
> >>>> if (Record.size() != 3) {
> >>>> Error("incorrect encoding of attributed type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType modifiedType = readType(*Loc.F, Record, Idx);
> >>>> QualType equivalentType = readType(*Loc.F, Record, Idx);
> >>>> - AttributedType::Kind kind =
> static_cast<AttributedType::Kind>(Record[2]);
> >>>> + auto 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 QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType InnerType = readType(*Loc.F, Record, Idx);
> >>>> return Context.getParenType(InnerType);
> >>>> @@ -6164,11 +6141,11 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_PACK_EXPANSION: {
> >>>> if (Record.size() != 2) {
> >>>> Error("incorrect encoding of pack expansion type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType Pattern = readType(*Loc.F, Record, Idx);
> >>>> if (Pattern.isNull())
> >>>> - return QualType();
> >>>> + return {};
> >>>> Optional<unsigned> NumExpansions;
> >>>> if (Record[1])
> >>>> NumExpansions = Record[1] - 1;
> >>>> @@ -6177,7 +6154,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>>
> >>>> case TYPE_ELABORATED: {
> >>>> unsigned Idx = 0;
> >>>> - ElaboratedTypeKeyword Keyword =
> (ElaboratedTypeKeyword)Record[Idx++];
> >>>> + auto Keyword = static_cast<ElaboratedTypeKeyword>(Record[Idx++]);
> >>>> NestedNameSpecifier *NNS = ReadNestedNameSpecifier(*Loc.F,
> Record, Idx);
> >>>> QualType NamedType = readType(*Loc.F, Record, Idx);
> >>>> return Context.getElaboratedType(Keyword, NNS, NamedType);
> >>>> @@ -6185,15 +6162,13 @@ QualType ASTReader::readTypeRecord(unsig
> >>>>
> >>>> case TYPE_OBJC_INTERFACE: {
> >>>> unsigned Idx = 0;
> >>>> - ObjCInterfaceDecl *ItfD
> >>>> - = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx);
> >>>> + auto *ItfD = ReadDeclAs<ObjCInterfaceDecl>(*Loc.F, Record, Idx);
> >>>> return Context.getObjCInterfaceType(ItfD->getCanonicalDecl());
> >>>> }
> >>>>
> >>>> case TYPE_OBJC_TYPE_PARAM: {
> >>>> unsigned Idx = 0;
> >>>> - ObjCTypeParamDecl *Decl
> >>>> - = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx);
> >>>> + auto *Decl = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx);
> >>>> unsigned NumProtos = Record[Idx++];
> >>>> SmallVector<ObjCProtocolDecl*, 4> Protos;
> >>>> for (unsigned I = 0; I != NumProtos; ++I)
> >>>> @@ -6241,7 +6216,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> }
> >>>>
> >>>> case TYPE_INJECTED_CLASS_NAME: {
> >>>> - CXXRecordDecl *D = ReadDeclAs<CXXRecordDecl>(*Loc.F, Record,
> Idx);
> >>>> + auto *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.
> >>>> @@ -6265,14 +6240,13 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> unsigned Depth = Record[Idx++];
> >>>> unsigned Index = Record[Idx++];
> >>>> bool Pack = Record[Idx++];
> >>>> - TemplateTypeParmDecl *D
> >>>> - = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx);
> >>>> + auto *D = ReadDeclAs<TemplateTypeParmDecl>(*Loc.F, Record, Idx);
> >>>> return Context.getTemplateTypeParmType(Depth, Index, Pack, D);
> >>>> }
> >>>>
> >>>> case TYPE_DEPENDENT_NAME: {
> >>>> unsigned Idx = 0;
> >>>> - ElaboratedTypeKeyword Keyword =
> (ElaboratedTypeKeyword)Record[Idx++];
> >>>> + auto Keyword = static_cast<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);
> >>>> @@ -6283,7 +6257,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>>
> >>>> case TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION: {
> >>>> unsigned Idx = 0;
> >>>> - ElaboratedTypeKeyword Keyword =
> (ElaboratedTypeKeyword)Record[Idx++];
> >>>> + auto Keyword = static_cast<ElaboratedTypeKeyword>(Record[Idx++]);
> >>>> NestedNameSpecifier *NNS = ReadNestedNameSpecifier(*Loc.F,
> Record, Idx);
> >>>> const IdentifierInfo *Name = GetIdentifierInfo(*Loc.F, Record,
> Idx);
> >>>> unsigned NumArgs = Record[Idx++];
> >>>> @@ -6300,8 +6274,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>>
> >>>> // ArrayType
> >>>> QualType ElementType = readType(*Loc.F, Record, Idx);
> >>>> - ArrayType::ArraySizeModifier ASM
> >>>> - = (ArrayType::ArraySizeModifier)Record[Idx++];
> >>>> + auto ASM =
> static_cast<ArrayType::ArraySizeModifier>(Record[Idx++]);
> >>>> unsigned IndexTypeQuals = Record[Idx++];
> >>>>
> >>>> // DependentSizedArrayType
> >>>> @@ -6331,7 +6304,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_ATOMIC: {
> >>>> if (Record.size() != 1) {
> >>>> Error("Incorrect encoding of atomic type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>> QualType ValueType = readType(*Loc.F, Record, Idx);
> >>>> return Context.getAtomicType(ValueType);
> >>>> @@ -6340,7 +6313,7 @@ QualType ASTReader::readTypeRecord(unsig
> >>>> case TYPE_PIPE: {
> >>>> if (Record.size() != 2) {
> >>>> Error("Incorrect encoding of pipe type");
> >>>> - return QualType();
> >>>> + return {};
> >>>> }
> >>>>
> >>>> // Reading the pipe element type.
> >>>> @@ -6380,8 +6353,7 @@ void ASTReader::readExceptionSpec(Module
> >>>> SmallVectorImpl<QualType>
> &Exceptions,
> >>>>
> FunctionProtoType::ExceptionSpecInfo &ESI,
> >>>> const RecordData &Record, unsigned
> &Idx) {
> >>>> - ExceptionSpecificationType EST =
> >>>> - static_cast<ExceptionSpecificationType>(Record[Idx++]);
> >>>> + auto EST = static_cast<ExceptionSpecificationType>(Record[Idx++]);
> >>>> ESI.Type = EST;
> >>>> if (EST == EST_Dynamic) {
> >>>> for (unsigned I = 0, N = Record[Idx++]; I != N; ++I)
> >>>> @@ -6749,7 +6721,7 @@ QualType ASTReader::GetType(TypeID ID) {
> >>>> QualType T;
> >>>> switch ((PredefinedTypeIDs)Index) {
> >>>> case PREDEF_TYPE_NULL_ID:
> >>>> - return QualType();
> >>>> + return {};
> >>>> case PREDEF_TYPE_VOID_ID:
> >>>> T = Context.VoidTy;
> >>>> break;
> >>>> @@ -6897,7 +6869,7 @@ QualType ASTReader::GetType(TypeID ID) {
> >>>> if (TypesLoaded[Index].isNull()) {
> >>>> TypesLoaded[Index] = readTypeRecord(Index);
> >>>> if (TypesLoaded[Index].isNull())
> >>>> - return QualType();
> >>>> + return {};
> >>>>
> >>>> TypesLoaded[Index]->setFromAST();
> >>>> if (DeserializationListener)
> >>>> @@ -6962,7 +6934,7 @@ ASTReader::GetTemplateArgumentLocInfo(Mo
> >>>> case TemplateArgument::NullPtr:
> >>>> case TemplateArgument::Pack:
> >>>> // FIXME: Is this right?
> >>>> - return TemplateArgumentLocInfo();
> >>>> + return {};
> >>>> }
> >>>> llvm_unreachable("unexpected template argument loc");
> >>>> }
> >>>> @@ -7089,7 +7061,7 @@ CXXBaseSpecifier *ASTReader::GetExternal
> >>>> unsigned Idx = 0;
> >>>> unsigned NumBases = Record[Idx++];
> >>>> void *Mem = Context.Allocate(sizeof(CXXBaseSpecifier) * NumBases);
> >>>> - CXXBaseSpecifier *Bases = new (Mem) CXXBaseSpecifier [NumBases];
> >>>> + auto *Bases = new (Mem) CXXBaseSpecifier [NumBases];
> >>>> for (unsigned I = 0; I != NumBases; ++I)
> >>>> Bases[I] = ReadCXXBaseSpecifier(*Loc.F, Record, Idx);
> >>>> return Bases;
> >>>> @@ -7130,13 +7102,13 @@ ModuleFile *ASTReader::getOwningModuleFi
> >>>>
> >>>> SourceLocation ASTReader::getSourceLocationForDeclID(GlobalDeclID ID)
> {
> >>>> if (ID < NUM_PREDEF_DECL_IDS)
> >>>> - return SourceLocation();
> >>>> + return {};
> >>>>
> >>>> unsigned Index = ID - NUM_PREDEF_DECL_IDS;
> >>>>
> >>>> if (Index > DeclsLoaded.size()) {
> >>>> Error("declaration ID out-of-range for AST file");
> >>>> - return SourceLocation();
> >>>> + return {};
> >>>> }
> >>>>
> >>>> if (Decl *D = DeclsLoaded[Index])
> >>>> @@ -7430,8 +7402,8 @@ ASTReader::FindExternalVisibleDeclsByNam
> >>>>
> >>>> // Load the list of declarations.
> >>>> SmallVector<NamedDecl *, 64> Decls;
> >>>> - for (DeclID ID : It->second.Table.find(Name)) {
> >>>> - NamedDecl *ND = cast<NamedDecl>(GetDecl(ID));
> >>>> + for (auto ID : It->second.Table.find(Name)) {
> >>>> + auto *ND = cast<NamedDecl>(GetDecl(ID));
> >>>> if (ND->getDeclName() == Name)
> >>>> Decls.push_back(ND);
> >>>> }
> >>>> @@ -7451,16 +7423,15 @@ void ASTReader::completeVisibleDeclsMap(
> >>>>
> >>>> DeclsMap Decls;
> >>>>
> >>>> - for (DeclID ID : It->second.Table.findAll()) {
> >>>> - NamedDecl *ND = cast<NamedDecl>(GetDecl(ID));
> >>>> + for (auto ID : It->second.Table.findAll()) {
> >>>> + auto *ND = cast<NamedDecl>(GetDecl(ID));
> >>>> Decls[ND->getDeclName()].push_back(ND);
> >>>> }
> >>>>
> >>>> ++NumVisibleDeclContextsRead;
> >>>>
> >>>> - for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I !=
> E; ++I) {
> >>>> - SetExternalVisibleDeclsForName(DC, I->first, I->second);
> >>>> - }
> >>>> + for (auto &I : Decls)
> >>>> + SetExternalVisibleDeclsForName(DC, I.first, I.second);
> >>>> const_cast<DeclContext *>(DC)->setHasExternalVisibleStorage(false);
> >>>> }
> >>>>
> >>>> @@ -7485,7 +7456,7 @@ static void PassObjCImplDeclToConsumer(O
> >>>> }
> >>>>
> >>>> void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
> >>>> - if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D))
> >>>> + if (auto *ImplD = dyn_cast<ObjCImplDecl>(D))
> >>>> PassObjCImplDeclToConsumer(ImplD, Consumer);
> >>>> else
> >>>> Consumer->HandleInterestingDecl(DeclGroupRef(D));
> >>>> @@ -7603,14 +7574,9 @@ dumpModuleIDMap(StringRef Name,
> >>>> if (Map.begin() == Map.end())
> >>>> return;
> >>>>
> >>>> - using MapType = ContinuousRangeMap<Key, ModuleFile *,
> InitialCapacity>;
> >>>> -
> >>>> llvm::errs() << Name << ":\n";
> >>>> - for (typename MapType::const_iterator I = Map.begin(), IEnd =
> Map.end();
> >>>> - I != IEnd; ++I) {
> >>>> - llvm::errs() << " " << I->first << " -> " << I->second->FileName
> >>>> - << "\n";
> >>>> - }
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180414/e8bdf7f8/attachment-0001.html>
More information about the cfe-commits
mailing list