r317648 - [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

Eugene Zelenko via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 7 17:03:16 PST 2017


Author: eugenezelenko
Date: Tue Nov  7 17:03:16 2017
New Revision: 317648

URL: http://llvm.org/viewvc/llvm-project?rev=317648&view=rev
Log:
[Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

Modified:
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=317648&r1=317647&r2=317648&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Nov  7 17:03:16 2017
@@ -1,4 +1,4 @@
-//===--- ASTReader.h - AST File Reader --------------------------*- C++ -*-===//
+//===- ASTReader.h - AST File Reader ----------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -17,13 +17,21 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/TemplateBase.h"
+#include "clang/AST/TemplateName.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/Module.h"
+#include "clang/Basic/OpenCLOptions.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Version.h"
+#include "clang/Basic/VersionTuple.h"
 #include "clang/Lex/ExternalPreprocessorSource.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PreprocessingRecord.h"
+#include "clang/Lex/Token.h"
 #include "clang/Sema/ExternalSemaSource.h"
 #include "clang/Sema/IdentifierResolver.h"
 #include "clang/Serialization/ASTBitCodes.h"
@@ -31,70 +39,86 @@
 #include "clang/Serialization/Module.h"
 #include "clang/Serialization/ModuleFileExtension.h"
 #include "clang/Serialization/ModuleManager.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/TinyPtrVector.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Timer.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <ctime>
 #include <deque>
 #include <memory>
+#include <set>
 #include <string>
 #include <utility>
 #include <vector>
 
-namespace llvm {
-  class BitstreamCursor;
-  class MemoryBuffer;
-  class APInt;
-  class APSInt;
-  class APFloat;
-}
-
 namespace clang {
 
-class SourceManager;
-class HeaderSearchOptions;
-class FileManager;
-class AddrLabelExpr;
 class ASTConsumer;
 class ASTContext;
-class ASTIdentifierIterator;
-class ASTUnit; // FIXME: Layering violation and egregious hack.
-class Attr;
-class Decl;
-class DeclContext;
-class DefMacroDirective;
-class DiagnosticOptions;
-class NestedNameSpecifier;
+class ASTDeserializationListener;
+class ASTReader;
+class ASTRecordReader;
 class CXXBaseSpecifier;
 class CXXConstructorDecl;
 class CXXCtorInitializer;
+class CXXTemporary;
+class Decl;
+class DeclaratorDecl;
+class DeclContext;
+class EnumDecl;
+class Expr;
+class FieldDecl;
+class FileEntry;
+class FileManager;
+class FileSystemOptions;
+class FunctionDecl;
 class GlobalModuleIndex;
-class GotoStmt;
-class MacroDefinition;
-class MacroDirective;
-class ModuleMacro;
+struct HeaderFileInfo;
+class HeaderSearchOptions;
+class LangOptions;
+class LazyASTUnresolvedSet;
+class MacroInfo;
+class MemoryBufferCache;
 class NamedDecl;
-class OpaqueValueExpr;
+class NamespaceDecl;
+class NestedNameSpecifier;
+class ObjCCategoryDecl;
+class ObjCInterfaceDecl;
+class PCHContainerReader;
 class Preprocessor;
 class PreprocessorOptions;
+struct QualifierInfo;
 class Sema;
+class SourceManager;
+class Stmt;
 class SwitchCase;
-class ASTDeserializationListener;
-class ASTWriter;
-class ASTReader;
-class ASTDeclReader;
-class ASTStmtReader;
-class ASTRecordReader;
-class TypeLocReader;
-struct HeaderFileInfo;
-class VersionTuple;
 class TargetOptions;
-class LazyASTUnresolvedSet;
+class TemplateParameterList;
+class TypedefNameDecl;
+class TypeSourceInfo;
+class ValueDecl;
+class VarDecl;
 
 /// \brief Abstract interface for callback invocations by the ASTReader.
 ///
@@ -189,9 +213,11 @@ public:
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// input files of the AST file via \c visitInputFile, false otherwise.
   virtual bool needsInputFileVisitation() { return false; }
+
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// system input files of the AST file via \c visitInputFile, false otherwise.
   virtual bool needsSystemInputFileVisitation() { return false; }
+
   /// \brief if \c needsInputFileVisitation returns true, this is called for
   /// each non-system input file of the AST File. If
   /// \c needsSystemInputFileVisitation is true, then it is called for all
@@ -206,6 +232,7 @@ public:
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// imports of the AST file via \c visitImport, false otherwise.
   virtual bool needsImportVisitation() const { return false; }
+
   /// \brief If needsImportVisitation returns \c true, this is called for each
   /// AST file imported by this AST file.
   virtual void visitImport(StringRef Filename) {}
@@ -306,12 +333,15 @@ namespace serialization {
 class ReadMethodPoolVisitor;
 
 namespace reader {
-  class ASTIdentifierLookupTrait;
-  /// \brief The on-disk hash table(s) used for DeclContext name lookup.
-  struct DeclContextLookupTable;
-}
 
-} // end namespace serialization
+class ASTIdentifierLookupTrait;
+
+/// \brief The on-disk hash table(s) used for DeclContext name lookup.
+struct DeclContextLookupTable;
+
+} // namespace reader
+
+} // namespace serialization
 
 /// \brief Reads an AST files chain containing the contents of a translation
 /// unit.
@@ -334,8 +364,20 @@ class ASTReader
     public ExternalSLocEntrySource
 {
 public:
-  typedef SmallVector<uint64_t, 64> RecordData;
-  typedef SmallVectorImpl<uint64_t> RecordDataImpl;
+  /// \brief Types of AST files.
+  friend class ASTDeclReader;
+  friend class ASTIdentifierIterator;
+  friend class ASTRecordReader;
+  friend class ASTStmtReader;
+  friend class ASTUnit; // ASTUnit needs to remap source locations.
+  friend class ASTWriter;
+  friend class PCHValidator;
+  friend class serialization::reader::ASTIdentifierLookupTrait;
+  friend class serialization::ReadMethodPoolVisitor;
+  friend class TypeLocReader;
+
+  using RecordData = SmallVector<uint64_t, 64>;
+  using RecordDataImpl = SmallVectorImpl<uint64_t>;
 
   /// \brief The result of reading the control block of an AST file, which
   /// can fail for various reasons.
@@ -343,41 +385,34 @@ public:
     /// \brief The control block was read successfully. Aside from failures,
     /// the AST file is safe to read into the current context.
     Success,
+
     /// \brief The AST file itself appears corrupted.
     Failure,
+
     /// \brief The AST file was missing.
     Missing,
+
     /// \brief The AST file is out-of-date relative to its input files,
     /// and needs to be regenerated.
     OutOfDate,
+
     /// \brief The AST file was written by a different version of Clang.
     VersionMismatch,
+
     /// \brief The AST file was writtten with a different language/target
     /// configuration.
     ConfigurationMismatch,
+
     /// \brief The AST file has errors.
     HadErrors
   };
 
-  /// \brief Types of AST files.
-  friend class PCHValidator;
-  friend class ASTDeclReader;
-  friend class ASTStmtReader;
-  friend class ASTIdentifierIterator;
-  friend class serialization::reader::ASTIdentifierLookupTrait;
-  friend class TypeLocReader;
-  friend class ASTRecordReader;
-  friend class ASTWriter;
-  friend class ASTUnit; // ASTUnit needs to remap source locations.
-  friend class serialization::ReadMethodPoolVisitor;
-
-  typedef serialization::ModuleFile ModuleFile;
-  typedef serialization::ModuleKind ModuleKind;
-  typedef serialization::ModuleManager ModuleManager;
-
-  typedef ModuleManager::ModuleIterator ModuleIterator;
-  typedef ModuleManager::ModuleConstIterator ModuleConstIterator;
-  typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator;
+  using ModuleFile = serialization::ModuleFile;
+  using ModuleKind = serialization::ModuleKind;
+  using ModuleManager = serialization::ModuleManager;
+  using ModuleIterator = ModuleManager::ModuleIterator;
+  using ModuleConstIterator = ModuleManager::ModuleConstIterator;
+  using ModuleReverseIterator = ModuleManager::ModuleReverseIterator;
 
 private:
   /// \brief The receiver of some callbacks invoked by ASTReader.
@@ -385,6 +420,7 @@ private:
 
   /// \brief The receiver of deserialization events.
   ASTDeserializationListener *DeserializationListener = nullptr;
+
   bool OwnsDeserializationListener = false;
 
   SourceManager &SourceMgr;
@@ -436,7 +472,8 @@ private:
   /// \brief A map of negated SLocEntryIDs to the modules containing them.
   ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap;
 
-  typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType;
+  using GlobalSLocOffsetMapType =
+      ContinuousRangeMap<unsigned, ModuleFile *, 64>;
 
   /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
   /// SourceLocation offsets to the modules containing them.
@@ -448,8 +485,8 @@ private:
   /// ID = (I + 1) << FastQual::Width has already been loaded
   std::vector<QualType> TypesLoaded;
 
-  typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4>
-    GlobalTypeMapType;
+  using GlobalTypeMapType =
+      ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4>;
 
   /// \brief Mapping from global type IDs to the module in which the
   /// type resides along with the offset that should be added to the
@@ -462,17 +499,17 @@ private:
   /// = I + 1 has already been loaded.
   std::vector<Decl *> DeclsLoaded;
 
-  typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4>
-    GlobalDeclMapType;
+  using GlobalDeclMapType =
+      ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4>;
 
   /// \brief Mapping from global declaration IDs to the module in which the
   /// declaration resides.
   GlobalDeclMapType GlobalDeclMap;
 
-  typedef std::pair<ModuleFile *, uint64_t> FileOffset;
-  typedef SmallVector<FileOffset, 2> FileOffsetsTy;
-  typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
-      DeclUpdateOffsetsMap;
+  using FileOffset = std::pair<ModuleFile *, uint64_t>;
+  using FileOffsetsTy = SmallVector<FileOffset, 2>;
+  using DeclUpdateOffsetsMap =
+      llvm::DenseMap<serialization::DeclID, FileOffsetsTy>;
 
   /// \brief Declarations that have modifications residing in a later file
   /// in the chain.
@@ -481,12 +518,15 @@ private:
   struct PendingUpdateRecord {
     Decl *D;
     serialization::GlobalDeclID ID;
+
     // Whether the declaration was just deserialized.
     bool JustLoaded;
+
     PendingUpdateRecord(serialization::GlobalDeclID ID, Decl *D,
                         bool JustLoaded)
         : D(D), ID(ID), JustLoaded(JustLoaded) {}
   };
+
   /// \brief Declaration updates for already-loaded declarations that we need
   /// to apply once we finish processing an import.
   llvm::SmallVector<PendingUpdateRecord, 16> PendingUpdateRecords;
@@ -505,7 +545,7 @@ private:
 
   /// \brief Declarations that have been imported and have typedef names for
   /// linkage purposes.
-  llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*>
+  llvm::DenseMap<std::pair<DeclContext *, IdentifierInfo *>, NamedDecl *>
       ImportedTypedefNamesForLinkage;
 
   /// \brief Mergeable declaration contexts that have anonymous declarations
@@ -514,10 +554,10 @@ private:
     AnonymousDeclarationsForMerging;
 
   struct FileDeclsInfo {
-    ModuleFile *Mod;
+    ModuleFile *Mod = nullptr;
     ArrayRef<serialization::LocalDeclID> Decls;
 
-    FileDeclsInfo() : Mod(nullptr) {}
+    FileDeclsInfo() = default;
     FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
       : Mod(Mod), Decls(Decls) {}
   };
@@ -527,7 +567,7 @@ private:
 
   /// \brief An array of lexical contents of a declaration context, as a sequence of
   /// Decl::Kind, DeclID pairs.
-  typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents;
+  using LexicalContents = ArrayRef<llvm::support::unaligned_uint32_t>;
 
   /// \brief Map from a DeclContext to its lexical contents.
   llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
@@ -548,7 +588,7 @@ private:
     ModuleFile *Mod;
     const unsigned char *Data;
   };
-  typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates;
+  using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate, 1>;
 
   /// \brief Updates to the visible declarations of declaration contexts that
   /// haven't been loaded yet.
@@ -559,22 +599,23 @@ private:
   /// declarations that have not yet been linked to their definitions.
   llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
 
-  typedef llvm::MapVector<Decl *, uint64_t,
-                          llvm::SmallDenseMap<Decl *, unsigned, 4>,
-                          SmallVector<std::pair<Decl *, uint64_t>, 4> >
-    PendingBodiesMap;
+  using PendingBodiesMap =
+      llvm::MapVector<Decl *, uint64_t,
+                      llvm::SmallDenseMap<Decl *, unsigned, 4>,
+                      SmallVector<std::pair<Decl *, uint64_t>, 4>>;
 
   /// \brief Functions or methods that have bodies that will be attached.
   PendingBodiesMap PendingBodies;
 
   /// \brief Definitions for which we have added merged definitions but not yet
   /// performed deduplication.
-  llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate;
+  llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate;
 
   /// \brief Read the record that describes the lexical contents of a DC.
   bool ReadLexicalDeclContextStorage(ModuleFile &M,
                                      llvm::BitstreamCursor &Cursor,
                                      uint64_t Offset, DeclContext *DC);
+
   /// \brief Read the record that describes the visible contents of a DC.
   bool ReadVisibleDeclContextStorage(ModuleFile &M,
                                      llvm::BitstreamCursor &Cursor,
@@ -588,8 +629,8 @@ private:
   /// been loaded.
   std::vector<IdentifierInfo *> IdentifiersLoaded;
 
-  typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>
-    GlobalIdentifierMapType;
+  using GlobalIdentifierMapType =
+      ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>;
 
   /// \brief Mapping from global identifier IDs to the module in which the
   /// identifier resides along with the offset that should be added to the
@@ -604,16 +645,16 @@ private:
   /// been loaded.
   std::vector<MacroInfo *> MacrosLoaded;
 
-  typedef std::pair<IdentifierInfo *, serialization::SubmoduleID>
-      LoadedMacroInfo;
+  using LoadedMacroInfo =
+      std::pair<IdentifierInfo *, serialization::SubmoduleID>;
 
   /// \brief A set of #undef directives that we have loaded; used to
   /// deduplicate the same #undef information coming from multiple module
   /// files.
   llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
 
-  typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
-    GlobalMacroMapType;
+  using GlobalMacroMapType =
+      ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>;
 
   /// \brief Mapping from global macro IDs to the module in which the
   /// macro resides along with the offset that should be added to the
@@ -626,8 +667,8 @@ private:
   /// indicate that the particular submodule ID has not yet been loaded.
   SmallVector<Module *, 2> SubmodulesLoaded;
   
-  typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>
-    GlobalSubmoduleMapType;
+  using GlobalSubmoduleMapType =
+      ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>;
   
   /// \brief Mapping from global submodule IDs to the module file in which the
   /// submodule resides along with the offset that should be added to the
@@ -635,14 +676,13 @@ private:
   GlobalSubmoduleMapType GlobalSubmoduleMap;
 
   /// \brief A set of hidden declarations.
-  typedef SmallVector<Decl*, 2> HiddenNames;
-  typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;
+  using HiddenNames = SmallVector<Decl *, 2>;
+  using HiddenNamesMapType = llvm::DenseMap<Module *, HiddenNames>;
 
   /// \brief A mapping from each of the hidden submodules to the deserialized
   /// declarations in that submodule that could be made visible.
   HiddenNamesMapType HiddenNamesMap;
   
-  
   /// \brief A module import, export, or conflict that hasn't yet been resolved.
   struct UnresolvedModuleRef {
     /// \brief The file in which this module resides.
@@ -675,11 +715,10 @@ private:
   /// been loaded.
   SmallVector<Selector, 16> SelectorsLoaded;
 
-  typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>
-    GlobalSelectorMapType;
+  using GlobalSelectorMapType =
+      ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>;
 
   /// \brief Mapping from global selector IDs to the module in which the
-
   /// global selector ID to produce a local ID.
   GlobalSelectorMapType GlobalSelectorMap;
 
@@ -699,15 +738,15 @@ private:
         : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
   };
 
-  typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> >
-    PendingMacroIDsMap;
+  using PendingMacroIDsMap =
+      llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2>>;
 
   /// \brief Mapping from identifiers that have a macro history to the global
   /// IDs have not yet been deserialized to the global IDs of those macros.
   PendingMacroIDsMap PendingMacroIDs;
 
-  typedef ContinuousRangeMap<unsigned, ModuleFile *, 4>
-    GlobalPreprocessedEntityMapType;
+  using GlobalPreprocessedEntityMapType =
+      ContinuousRangeMap<unsigned, ModuleFile *, 4>;
 
   /// \brief Mapping from global preprocessing entity IDs to the module in
   /// which the preprocessed entity resides along with the offset that should be
@@ -895,7 +934,8 @@ private:
   ///\brief Whether we are currently processing update records.
   bool ProcessingUpdateRecords = false;
 
-  typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy;
+  using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>;
+
   /// \brief Mapping from switch-case IDs in the chain to switch-case statements
   ///
   /// Statements usually don't have IDs, but switch cases need them, so that the
@@ -979,7 +1019,7 @@ private:
   ///
   /// The declarations on the identifier chain for these identifiers will be
   /// loaded once the recursive loading has completed.
-  llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> >
+  llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4>>
     PendingIdentifierInfos;
 
   /// \brief The set of lookup results that we have faked in order to support
@@ -998,7 +1038,9 @@ private:
   public:
     InterestingDecl(Decl *D, bool HasBody)
         : D(D), DeclHasPendingBody(HasBody) {}
+
     Decl *getDecl() { return D; }
+
     /// Whether the declaration has a pending body.
     bool hasPendingBody() { return DeclHasPendingBody; }
   };
@@ -1062,8 +1104,8 @@ private:
   /// module is loaded.
   SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
 
-  typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> >
-    KeyDeclsMap;
+  using KeyDeclsMap =
+      llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2>>;
     
   /// \brief A mapping from canonical declarations to the set of global
   /// declaration IDs for key declaration that have been merged with that
@@ -1097,15 +1139,14 @@ private:
     ASTReader &Reader;
     enum ReadingKind PrevKind;
 
-    ReadingKindTracker(const ReadingKindTracker &) = delete;
-    void operator=(const ReadingKindTracker &) = delete;
-
   public:
     ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader)
       : Reader(reader), PrevKind(Reader.ReadingKind) {
       Reader.ReadingKind = newKind;
     }
 
+    ReadingKindTracker(const ReadingKindTracker &) = delete;
+    ReadingKindTracker &operator=(const ReadingKindTracker &) = delete;
     ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
   };
 
@@ -1114,15 +1155,15 @@ private:
     ASTReader &Reader;
     bool PrevState;
 
-    ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete;
-    void operator=(const ProcessingUpdatesRAIIObj &) = delete;
-
   public:
     ProcessingUpdatesRAIIObj(ASTReader &reader)
       : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
       Reader.ProcessingUpdateRecords = true;
     }
 
+    ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete;
+    ProcessingUpdatesRAIIObj &
+    operator=(const ProcessingUpdatesRAIIObj &) = delete;
     ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
   };
 
@@ -1205,7 +1246,7 @@ private:
     ImportedModule(ModuleFile *Mod,
                    ModuleFile *ImportedBy,
                    SourceLocation ImportLoc)
-      : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { }
+      : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) {}
   };
 
   ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
@@ -1266,10 +1307,11 @@ private:
                                        std::string &SuggestedPredefines);
 
   struct RecordLocation {
-    RecordLocation(ModuleFile *M, uint64_t O)
-      : F(M), Offset(O) {}
     ModuleFile *F;
     uint64_t Offset;
+
+    RecordLocation(ModuleFile *M, uint64_t O)
+      : F(M), Offset(O) {}
   };
 
   QualType readTypeRecord(unsigned Index);
@@ -1328,12 +1370,11 @@ public:
             ModuleDeclIterator, const serialization::LocalDeclID *,
             std::random_access_iterator_tag, const Decl *, ptrdiff_t,
             const Decl *, const Decl *> {
-    ASTReader *Reader;
-    ModuleFile *Mod;
+    ASTReader *Reader = nullptr;
+    ModuleFile *Mod = nullptr;
 
   public:
-    ModuleDeclIterator()
-        : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {}
+    ModuleDeclIterator() : iterator_adaptor_base(nullptr) {}
 
     ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod,
                        const serialization::LocalDeclID *Pos)
@@ -1342,6 +1383,7 @@ public:
     value_type operator*() const {
       return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I));
     }
+
     value_type operator->() const { return **this; }
 
     bool operator==(const ModuleDeclIterator &RHS) const {
@@ -1378,8 +1420,6 @@ private:
   void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
              StringRef Arg2 = StringRef()) const;
 
-  ASTReader(const ASTReader &) = delete;
-  void operator=(const ASTReader &) = delete;
 public:
   /// \brief Load the AST file and validate its contents against the given
   /// Preprocessor.
@@ -1428,7 +1468,8 @@ public:
             bool AllowConfigurationMismatch = false,
             bool ValidateSystemInputs = false, bool UseGlobalIndex = true,
             std::unique_ptr<llvm::Timer> ReadTimer = {});
-
+  ASTReader(const ASTReader &) = delete;
+  ASTReader &operator=(const ASTReader &) = delete;
   ~ASTReader() override;
 
   SourceManager &getSourceManager() const { return SourceMgr; }
@@ -1443,15 +1484,19 @@ public:
   enum LoadFailureCapabilities {
     /// \brief The client can't handle any AST loading failures.
     ARR_None = 0,
+
     /// \brief The client can handle an AST file that cannot load because it
     /// is missing.
     ARR_Missing = 0x1,
+
     /// \brief The client can handle an AST file that cannot load because it
     /// is out-of-date relative to its input files.
     ARR_OutOfDate = 0x2,
+
     /// \brief The client can handle an AST file that cannot load because it
     /// was built with a different version of Clang.
     ARR_VersionMismatch = 0x4,
+
     /// \brief The client can handle an AST file that cannot load because it's
     /// compiled configuration doesn't match that of the context it was
     /// loaded into.
@@ -1522,11 +1567,11 @@ public:
   /// RAII object to temporarily add an AST callback listener.
   class ListenerScope {
     ASTReader &Reader;
-    bool Chained;
+    bool Chained = false;
 
   public:
     ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L)
-        : Reader(Reader), Chained(false) {
+        : Reader(Reader) {
       auto Old = Reader.takeListener();
       if (Old) {
         Chained = true;
@@ -1535,6 +1580,7 @@ public:
       }
       Reader.setListener(std::move(L));
     }
+
     ~ListenerScope() {
       auto New = Reader.takeListener();
       if (Chained)
@@ -1933,16 +1979,16 @@ public:
       llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override;
 
   void ReadReferencedSelectors(
-          SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override;
+           SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) override;
 
   void ReadWeakUndeclaredIdentifiers(
-          SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) override;
+           SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WI) override;
 
   void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override;
 
   void ReadPendingInstantiations(
-                 SmallVectorImpl<std::pair<ValueDecl *,
-                                           SourceLocation> > &Pending) override;
+                  SmallVectorImpl<std::pair<ValueDecl *,
+                                            SourceLocation>> &Pending) override;
 
   void ReadLateParsedTemplates(
       llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
@@ -2275,20 +2321,19 @@ public:
 
 /// \brief An object for streaming information from a record.
 class ASTRecordReader {
-  typedef serialization::ModuleFile ModuleFile;
+  using ModuleFile = serialization::ModuleFile;
 
   ASTReader *Reader;
   ModuleFile *F;
   unsigned Idx = 0;
   ASTReader::RecordData Record;
 
-  typedef ASTReader::RecordData RecordData;
-  typedef ASTReader::RecordDataImpl RecordDataImpl;
+  using RecordData = ASTReader::RecordData;
+  using RecordDataImpl = ASTReader::RecordDataImpl;
 
 public:
   /// Construct an ASTRecordReader that uses the default encoding scheme.
-  ASTRecordReader(ASTReader &Reader, ModuleFile &F)
-      : Reader(&Reader), F(&F) {}
+  ASTRecordReader(ASTReader &Reader, ModuleFile &F) : Reader(&Reader), F(&F) {}
 
   /// \brief Reads a record with id AbbrevID from Cursor, resetting the
   /// internal state.
@@ -2302,17 +2347,20 @@ public:
 
   /// \brief The current position in this record.
   unsigned getIdx() const { return Idx; }
+
   /// \brief The length of this record.
   size_t size() const { return Record.size(); }
 
   /// \brief An arbitrary index in this record.
   const uint64_t &operator[](size_t N) { return Record[N]; }
+
   /// \brief The last element in this record.
   const uint64_t &back() const { return Record.back(); }
 
   /// \brief Returns the current value in this record, and advances to the
   /// next value.
   const uint64_t &readInt() { return Record[Idx++]; }
+
   /// \brief Returns the current value in this record, without advancing.
   const uint64_t &peekInt() { return Record[Idx]; }
 
@@ -2566,7 +2614,7 @@ public:
 /// then restores it when destroyed.
 struct SavedStreamPosition {
   explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
-    : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { }
+    : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {}
 
   ~SavedStreamPosition() {
     Cursor.JumpToBit(Offset);
@@ -2581,6 +2629,6 @@ inline void PCHValidator::Error(const ch
   Reader.Error(Msg);
 }
 
-} // end namespace clang
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=317648&r1=317647&r2=317648&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Nov  7 17:03:16 2017
@@ -1,4 +1,4 @@
-//===-- ASTReader.cpp - AST File Reader -----------------------------------===//
+//===- ASTReader.cpp - AST File Reader ------------------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -19,28 +19,41 @@
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/ASTUnresolvedSet.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclGroup.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/ODRHash.h"
 #include "clang/AST/RawCommentList.h"
+#include "clang/AST/TemplateBase.h"
+#include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
 #include "clang/AST/TypeLocVisitor.h"
 #include "clang/AST/UnresolvedSet.h"
 #include "clang/Basic/CommentOptions.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/ExceptionSpecificationType.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/MemoryBufferCache.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/PragmaKinds.h"
 #include "clang/Basic/Sanitizers.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/SourceManagerInternals.h"
 #include "clang/Basic/Specifiers.h"
@@ -57,41 +70,61 @@
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Lex/Token.h"
+#include "clang/Sema/ObjCMethodList.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Weak.h"
+#include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTDeserializationListener.h"
+#include "clang/Serialization/ContinuousRangeMap.h"
 #include "clang/Serialization/GlobalModuleIndex.h"
+#include "clang/Serialization/Module.h"
+#include "clang/Serialization/ModuleFileExtension.h"
 #include "clang/Serialization/ModuleManager.h"
 #include "clang/Serialization/SerializationDiagnostic.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/Hashing.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#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/BitstreamReader.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SaveAndRestore.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <cstdio>
-#include <cstring>
 #include <ctime>
 #include <iterator>
 #include <limits>
 #include <map>
 #include <memory>
-#include <new>
 #include <string>
 #include <system_error>
 #include <tuple>
@@ -171,19 +204,23 @@ bool ChainedASTReaderListener::ReadPrepr
                                         SuggestedPredefines) ||
          Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
 }
+
 void ChainedASTReaderListener::ReadCounter(const serialization::ModuleFile &M,
                                            unsigned Value) {
   First->ReadCounter(M, Value);
   Second->ReadCounter(M, Value);
 }
+
 bool ChainedASTReaderListener::needsInputFileVisitation() {
   return First->needsInputFileVisitation() ||
          Second->needsInputFileVisitation();
 }
+
 bool ChainedASTReaderListener::needsSystemInputFileVisitation() {
   return First->needsSystemInputFileVisitation() ||
   Second->needsSystemInputFileVisitation();
 }
+
 void ChainedASTReaderListener::visitModuleFile(StringRef Filename,
                                                ModuleKind Kind) {
   First->visitModuleFile(Filename, Kind);
@@ -216,7 +253,7 @@ void ChainedASTReaderListener::readModul
 // PCH validator implementation
 //===----------------------------------------------------------------------===//
 
-ASTReaderListener::~ASTReaderListener() {}
+ASTReaderListener::~ASTReaderListener() = default;
 
 /// \brief Compare the given set of language options against an existing set of
 /// language options.
@@ -409,17 +446,16 @@ bool PCHValidator::ReadTargetOptions(con
 
 namespace {
 
-  typedef llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/> >
-    MacroDefinitionsMap;
-  typedef llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8> >
-    DeclsMap;
+using MacroDefinitionsMap =
+    llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>;
+using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
 
-} // end anonymous namespace
+} // namespace
 
 static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
                                          DiagnosticsEngine &Diags,
                                          bool Complain) {
-  typedef DiagnosticsEngine::Level Level;
+  using Level = DiagnosticsEngine::Level;
 
   // Check current mappings for new -Werror mappings, and the stored mappings
   // for cases that were explicitly mapped to *not* be errors that are now
@@ -603,8 +639,8 @@ static bool checkPreprocessorOptions(con
     std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
 
     // Check whether we know anything about this macro name or not.
-    llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/> >::iterator Known
-      = ASTFileMacros.find(MacroName);
+    llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>::iterator Known =
+        ASTFileMacros.find(MacroName);
     if (!Validate || Known == ASTFileMacros.end()) {
       // FIXME: Check whether this identifier was referenced anywhere in the
       // AST file. If so, we should reject the AST file. Unfortunately, this
@@ -770,6 +806,7 @@ unsigned ASTSelectorLookupTrait::Compute
 std::pair<unsigned, unsigned>
 ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) {
   using namespace llvm::support;
+
   unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
   return std::make_pair(KeyLen, DataLen);
@@ -778,6 +815,7 @@ ASTSelectorLookupTrait::ReadKeyDataLengt
 ASTSelectorLookupTrait::internal_key_type
 ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
   using namespace llvm::support;
+
   SelectorTable &SelTable = Reader.getContext().Selectors;
   unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
   IdentifierInfo *FirstII = Reader.getLocalIdentifier(
@@ -838,6 +876,7 @@ unsigned ASTIdentifierLookupTraitBase::C
 std::pair<unsigned, unsigned>
 ASTIdentifierLookupTraitBase::ReadKeyDataLength(const unsigned char*& d) {
   using namespace llvm::support;
+
   unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
   return std::make_pair(KeyLen, DataLen);
@@ -868,6 +907,7 @@ static bool readBit(unsigned &Bits) {
 
 IdentID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
   using namespace llvm::support;
+
   unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
   return Reader.getGlobalIdentifierID(F, RawID >> 1);
 }
@@ -885,6 +925,7 @@ IdentifierInfo *ASTIdentifierLookupTrait
                                                    const unsigned char* d,
                                                    unsigned DataLen) {
   using namespace llvm::support;
+
   unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
   bool IsInteresting = RawID & 0x01;
 
@@ -1027,6 +1068,7 @@ unsigned DeclarationNameKey::getHash() c
 ModuleFile *
 ASTDeclContextNameLookupTrait::ReadFileRef(const unsigned char *&d) {
   using namespace llvm::support;
+
   uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
   return Reader.getLocalModuleFile(F, ModuleFileID);
 }
@@ -1034,6 +1076,7 @@ ASTDeclContextNameLookupTrait::ReadFileR
 std::pair<unsigned, unsigned>
 ASTDeclContextNameLookupTrait::ReadKeyDataLength(const unsigned char *&d) {
   using namespace llvm::support;
+
   unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
   return std::make_pair(KeyLen, DataLen);
@@ -1079,6 +1122,7 @@ void ASTDeclContextNameLookupTrait::Read
                                                  unsigned DataLen,
                                                  data_type_builder &Val) {
   using namespace llvm::support;
+
   for (unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
     uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
     Val.insert(Reader.getGlobalDeclID(F, LocalID));
@@ -1278,7 +1322,9 @@ resolveFileRelativeToOriginalDir(const s
                                  const std::string &CurrDir) {
   assert(OriginalDir != CurrDir &&
          "No point trying to resolve the file if the PCH dir didn't change");
+
   using namespace llvm::sys;
+
   SmallString<128> filePath(Filename);
   fs::make_absolute(filePath);
   assert(path::is_absolute(OriginalDir));
@@ -1672,6 +1718,7 @@ bool HeaderFileInfoTrait::EqualKey(inter
 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++;
   return std::make_pair(KeyLen, DataLen);
@@ -1680,6 +1727,7 @@ HeaderFileInfoTrait::ReadKeyDataLength(c
 HeaderFileInfoTrait::internal_key_type
 HeaderFileInfoTrait::ReadKey(const unsigned char *d, unsigned) {
   using namespace llvm::support;
+
   internal_key_type ikey;
   ikey.Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
   ikey.ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
@@ -1691,8 +1739,9 @@ HeaderFileInfoTrait::ReadKey(const unsig
 HeaderFileInfoTrait::data_type
 HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
                               unsigned DataLen) {
-  const unsigned char *End = d + DataLen;
   using namespace llvm::support;
+
+  const unsigned char *End = d + DataLen;
   HeaderFileInfo HFI;
   unsigned Flags = *d++;
   // FIXME: Refactor with mergeHeaderFileInfo in HeaderSearch.cpp.
@@ -1813,7 +1862,7 @@ namespace {
     unsigned PriorGeneration;
     unsigned &NumIdentifierLookups;
     unsigned &NumIdentifierLookupHits;
-    IdentifierInfo *Found;
+    IdentifierInfo *Found = nullptr;
 
   public:
     IdentifierLookupVisitor(StringRef Name, unsigned PriorGeneration,
@@ -1822,10 +1871,7 @@ namespace {
       : Name(Name), NameHash(ASTIdentifierLookupTrait::ComputeHash(Name)),
         PriorGeneration(PriorGeneration),
         NumIdentifierLookups(NumIdentifierLookups),
-        NumIdentifierLookupHits(NumIdentifierLookupHits),
-        Found()
-    {
-    }
+        NumIdentifierLookupHits(NumIdentifierLookupHits) {}
 
     bool operator()(ModuleFile &M) {
       // If we've already searched this module file, skip it now.
@@ -1858,7 +1904,7 @@ namespace {
     IdentifierInfo *getIdentifierInfo() const { return Found; }
   };
 
-} // end anonymous namespace
+} // namespace
 
 void ASTReader::updateOutOfDateIdentifier(IdentifierInfo &II) {
   // Note that we are loading an identifier.
@@ -1985,10 +2031,9 @@ void ASTReader::resolvePendingMacro(Iden
       MD = PP.AllocateDefMacroDirective(MI, Loc);
       break;
     }
-    case MacroDirective::MD_Undefine: {
+    case MacroDirective::MD_Undefine:
       MD = PP.AllocateUndefMacroDirective(Loc);
       break;
-    }
     case MacroDirective::MD_Visibility:
       bool isPublic = Record[Idx++];
       MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
@@ -2124,7 +2169,7 @@ InputFile ASTReader::getInputFile(Module
     if (Complain) {
       // Build a list of the PCH imports that got us here (in reverse).
       SmallVector<ModuleFile *, 4> ImportStack(1, &F);
-      while (ImportStack.back()->ImportedBy.size() > 0)
+      while (!ImportStack.back()->ImportedBy.empty())
         ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
 
       // The top-level PCH is stale.
@@ -2622,7 +2667,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
     case llvm::BitstreamEntry::Error:
       Error("error at end of module block in AST file");
       return Failure;
-    case llvm::BitstreamEntry::EndBlock: {
+    case llvm::BitstreamEntry::EndBlock:
       // Outside of C++, we do not store a lookup map for the translation unit.
       // Instead, mark it as needing a lookup map to be built if this module
       // contains any declarations lexically within it (which it always does!).
@@ -2635,7 +2680,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
       }
 
       return Success;
-    }
     case llvm::BitstreamEntry::SubBlock:
       switch (Entry.ID) {
       case DECLTYPES_BLOCK_ID:
@@ -3170,7 +3214,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
       break;
     }
 
-    case DECL_UPDATE_OFFSETS: {
+    case DECL_UPDATE_OFFSETS:
       if (Record.size() % 2 != 0) {
         Error("invalid DECL_UPDATE_OFFSETS block in AST file");
         return Failure;
@@ -3186,9 +3230,8 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
               PendingUpdateRecord(ID, D, /*JustLoaded=*/false));
       }
       break;
-    }
 
-    case OBJC_CATEGORIES_MAP: {
+    case OBJC_CATEGORIES_MAP:
       if (F.LocalNumObjCCategoriesInMap != 0) {
         Error("duplicate OBJC_CATEGORIES_MAP record in AST file");
         return Failure;
@@ -3197,7 +3240,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
       F.LocalNumObjCCategoriesInMap = Record[0];
       F.ObjCCategoriesMap = (const ObjCCategoriesInfo *)Blob.data();
       break;
-    }
 
     case OBJC_CATEGORIES:
       F.ObjCCategories.swap(Record);
@@ -3211,7 +3253,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
       break;
 
-    case HEADER_SEARCH_TABLE: {
+    case HEADER_SEARCH_TABLE:
       F.HeaderFileInfoTableData = Blob.data();
       F.LocalNumHeaderFileInfos = Record[1];
       if (Record[0]) {
@@ -3228,7 +3270,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
           PP.getHeaderSearchInfo().SetExternalLookup(this);
       }
       break;
-    }
 
     case FP_PRAGMA_OPTIONS:
       // Later tables overwrite earlier ones.
@@ -3296,6 +3337,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
             ReadSourceLocation(F, Record, I).getRawEncoding());
       }
       break;
+
     case DELETE_EXPRS_TO_ANALYZE:
       for (unsigned I = 0, N = Record.size(); I != N;) {
         DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
@@ -3309,7 +3351,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
       }
       break;
 
-    case IMPORTED_MODULES: {
+    case IMPORTED_MODULES:
       if (!F.isModule()) {
         // If we aren't loading a module (which has its own exports), make
         // all of the imported modules visible.
@@ -3325,7 +3367,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         }
       }
       break;
-    }
 
     case MACRO_OFFSET: {
       if (F.LocalNumMacros != 0) {
@@ -3351,10 +3392,9 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
       break;
     }
 
-    case LATE_PARSED_TEMPLATE: {
+    case LATE_PARSED_TEMPLATE:
       LateParsedTemplates.append(Record.begin(), Record.end());
       break;
-    }
 
     case OPTIMIZE_PRAGMA_OPTIONS:
       if (Record.size() != 1) {
@@ -3436,8 +3476,7 @@ void ASTReader::ReadModuleOffsetMap(Modu
   }
 
   // Continuous range maps we may be updating in our module.
-  typedef ContinuousRangeMap<uint32_t, int, 2>::Builder
-      RemapBuilder;
+  using RemapBuilder = ContinuousRangeMap<uint32_t, int, 2>::Builder;
   RemapBuilder SLocRemap(F.SLocRemap);
   RemapBuilder IdentifierRemap(F.IdentifierRemap);
   RemapBuilder MacroRemap(F.MacroRemap);
@@ -3601,7 +3640,6 @@ ASTReader::ReadModuleMapFileBlock(Record
   return Success;
 }
 
-
 /// \brief Move the given method to the back of the global list of methods.
 static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) {
   // Find the entry for this selector in the method pool.
@@ -4254,7 +4292,7 @@ ASTReader::ASTReadResult ASTReader::read
   // Read all of the records in the options block.
   RecordData Record;
   ASTReadResult Result = Success;
-  while (1) {
+  while (true) {
     llvm::BitstreamEntry Entry = Stream.advance();
 
     switch (Entry.Kind) {
@@ -4274,11 +4312,10 @@ ASTReader::ASTReadResult ASTReader::read
     Record.clear();
     switch (
         (UnhashedControlBlockRecordTypes)Stream.readRecord(Entry.ID, Record)) {
-    case SIGNATURE: {
+    case SIGNATURE:
       if (F)
         std::copy(Record.begin(), Record.end(), F->Signature.data());
       break;
-    }
     case DIAGNOSTIC_OPTIONS: {
       bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
       if (Listener && ValidateDiagnosticOptions &&
@@ -4607,9 +4644,7 @@ namespace {
         ExistingTargetOpts(ExistingTargetOpts),
         ExistingPPOpts(ExistingPPOpts),
         ExistingModuleCachePath(ExistingModuleCachePath),
-        FileMgr(FileMgr)
-    {
-    }
+        FileMgr(FileMgr) {}
 
     bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
                              bool AllowCompatibleDifferences) override {
@@ -4639,7 +4674,7 @@ namespace {
     }
   };
 
-} // end anonymous namespace
+} // namespace
 
 bool ASTReader::readASTFileControlBlock(
     StringRef Filename, FileManager &FileMgr,
@@ -4723,15 +4758,12 @@ bool ASTReader::readASTFileControlBlock(
     StringRef Blob;
     unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
     switch ((ControlRecordTypes)RecCode) {
-    case METADATA: {
+    case METADATA:
       if (Record[0] != VERSION_MAJOR)
         return true;
-
       if (Listener.ReadFullVersionInformation(Blob))
         return true;
-
       break;
-    }
     case MODULE_NAME:
       Listener.ReadModuleName(Blob);
       break;
@@ -5039,10 +5071,9 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
       // them here.
       break;
 
-    case SUBMODULE_TOPHEADER: {
+    case SUBMODULE_TOPHEADER:
       CurrentModule->addTopHeaderFilename(Blob);
       break;
-    }
 
     case SUBMODULE_UMBRELLA_DIR: {
       std::string Dirname = Blob;
@@ -5079,7 +5110,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
       break;
     }
 
-    case SUBMODULE_IMPORTS: {
+    case SUBMODULE_IMPORTS:
       for (unsigned Idx = 0; Idx != Record.size(); ++Idx) {
         UnresolvedModuleRef Unresolved;
         Unresolved.File = &F;
@@ -5090,9 +5121,8 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
         UnresolvedModuleRefs.push_back(Unresolved);
       }
       break;
-    }
 
-    case SUBMODULE_EXPORTS: {
+    case SUBMODULE_EXPORTS:
       for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
         UnresolvedModuleRef Unresolved;
         Unresolved.File = &F;
@@ -5107,12 +5137,11 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
       // the parsed, unresolved exports around.
       CurrentModule->UnresolvedExports.clear();
       break;
-    }
-    case SUBMODULE_REQUIRES: {
+
+    case SUBMODULE_REQUIRES:
       CurrentModule->addRequirement(Blob, Record[0], PP.getLangOpts(),
                                     PP.getTargetInfo());
       break;
-    }
 
     case SUBMODULE_LINK_LIBRARY:
       CurrentModule->LinkLibraries.push_back(
@@ -5462,7 +5491,7 @@ struct PPEntityComp {
   const ASTReader &Reader;
   ModuleFile &M;
 
-  PPEntityComp(const ASTReader &Reader, ModuleFile &M) : Reader(Reader), M(M) { }
+  PPEntityComp(const ASTReader &Reader, ModuleFile &M) : Reader(Reader), M(M) {}
 
   bool operator()(const PPEntityOffset &L, const PPEntityOffset &R) const {
     SourceLocation LHS = getLoc(L);
@@ -5485,7 +5514,7 @@ struct PPEntityComp {
   }
 };
 
-} // end anonymous namespace
+} // namespace
 
 PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
                                                        bool EndsAfter) const {
@@ -5501,7 +5530,9 @@ PreprocessedEntityID ASTReader::findPrep
     return findNextPreprocessedEntity(SLocMapI);
 
   ModuleFile &M = *SLocMapI->second;
-  typedef const PPEntityOffset *pp_iterator;
+
+  using pp_iterator = const PPEntityOffset *;
+
   pp_iterator pp_begin = M.PreprocessedEntityOffsets;
   pp_iterator pp_end = pp_begin + M.NumPreprocessedEntities;
 
@@ -5579,12 +5610,10 @@ namespace {
   /// \brief Visitor used to search for information about a header file.
   class HeaderFileInfoVisitor {
     const FileEntry *FE;
-
     Optional<HeaderFileInfo> HFI;
 
   public:
-    explicit HeaderFileInfoVisitor(const FileEntry *FE)
-      : FE(FE) { }
+    explicit HeaderFileInfoVisitor(const FileEntry *FE) : FE(FE) {}
 
     bool operator()(ModuleFile &M) {
       HeaderFileInfoLookupTable *Table
@@ -5604,7 +5633,7 @@ namespace {
     Optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
   };
 
-} // end anonymous namespace
+} // namespace
 
 HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) {
   HeaderFileInfoVisitor Visitor(FE);
@@ -6125,6 +6154,7 @@ QualType ASTReader::readTypeRecord(unsig
       Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
     return Context.getObjCTypeParamType(Decl, Protos);
   }
+
   case TYPE_OBJC_OBJECT: {
     unsigned Idx = 0;
     QualType Base = readType(*Loc.F, Record, Idx);
@@ -6321,7 +6351,9 @@ void ASTReader::readExceptionSpec(Module
   }
 }
 
-class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
+namespace clang {
+
+class TypeLocReader : public TypeLocVisitor<TypeLocReader> {
   ModuleFile *F;
   ASTReader *Reader;
   const ASTReader::RecordData &Record;
@@ -6356,6 +6388,8 @@ public:
   void VisitArrayTypeLoc(ArrayTypeLoc);
 };
 
+} // namespace clang
+
 void TypeLocReader::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
   // nothing to do
 }
@@ -6472,23 +6506,28 @@ void TypeLocReader::VisitFunctionProtoTy
 void TypeLocReader::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
   VisitFunctionTypeLoc(TL);
 }
+
 void TypeLocReader::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
 }
+
 void TypeLocReader::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
 }
+
 void TypeLocReader::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
   TL.setTypeofLoc(ReadSourceLocation());
   TL.setLParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
 }
+
 void TypeLocReader::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
   TL.setTypeofLoc(ReadSourceLocation());
   TL.setLParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
   TL.setUnderlyingTInfo(GetTypeSourceInfo());
 }
+
 void TypeLocReader::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
 }
@@ -6542,10 +6581,12 @@ void TypeLocReader::VisitSubstTemplateTy
                                             SubstTemplateTypeParmTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
 }
+
 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
                                           SubstTemplateTypeParmPackTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
 }
+
 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
                                            TemplateSpecializationTypeLoc TL) {
   TL.setTemplateKeywordLoc(ReadSourceLocation());
@@ -6558,6 +6599,7 @@ void TypeLocReader::VisitTemplateSpecial
         Reader->GetTemplateArgumentLocInfo(
             *F, TL.getTypePtr()->getArg(i).getKind(), Record, Idx));
 }
+
 void TypeLocReader::VisitParenTypeLoc(ParenTypeLoc TL) {
   TL.setLParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
@@ -6668,13 +6710,11 @@ QualType ASTReader::GetType(TypeID ID) {
     case PREDEF_TYPE_BOOL_ID:
       T = Context.BoolTy;
       break;
-
     case PREDEF_TYPE_CHAR_U_ID:
     case PREDEF_TYPE_CHAR_S_ID:
       // FIXME: Check that the signedness of CharTy is correct!
       T = Context.CharTy;
       break;
-
     case PREDEF_TYPE_UCHAR_ID:
       T = Context.UnsignedCharTy;
       break;
@@ -6788,19 +6828,15 @@ QualType ASTReader::GetType(TypeID ID) {
     case PREDEF_TYPE_AUTO_DEDUCT:
       T = Context.getAutoDeductType();
       break;
-
     case PREDEF_TYPE_AUTO_RREF_DEDUCT:
       T = Context.getAutoRRefDeductType();
       break;
-
     case PREDEF_TYPE_ARC_UNBRIDGED_CAST:
       T = Context.ARCUnbridgedCastTy;
       break;
-
     case PREDEF_TYPE_BUILTIN_FN:
       T = Context.BuiltinFnTy;
       break;
-
     case PREDEF_TYPE_OMP_ARRAY_SECTION:
       T = Context.OMPArraySectionTy;
       break;
@@ -7287,7 +7323,7 @@ public:
   }
 };
 
-} // end anonymous namespace
+} // namespace
 
 void ASTReader::FindFileRegionDecls(FileID File,
                                     unsigned Offset, unsigned Length,
@@ -7483,30 +7519,25 @@ void ASTReader::PrintStats() {
                  NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
                  ((float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
                   * 100));
-  if (TotalNumMethodPoolEntries) {
+  if (TotalNumMethodPoolEntries)
     std::fprintf(stderr, "  %u/%u method pool entries read (%f%%)\n",
                  NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
                  ((float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
                   * 100));
-  }
-  if (NumMethodPoolLookups) {
+  if (NumMethodPoolLookups)
     std::fprintf(stderr, "  %u/%u method pool lookups succeeded (%f%%)\n",
                  NumMethodPoolHits, NumMethodPoolLookups,
                  ((float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
-  }
-  if (NumMethodPoolTableLookups) {
+  if (NumMethodPoolTableLookups)
     std::fprintf(stderr, "  %u/%u method pool table lookups succeeded (%f%%)\n",
                  NumMethodPoolTableHits, NumMethodPoolTableLookups,
                  ((float)NumMethodPoolTableHits/NumMethodPoolTableLookups
                   * 100.0));
-  }
-
-  if (NumIdentifierLookupHits) {
+  if (NumIdentifierLookupHits)
     std::fprintf(stderr,
                  "  %u / %u identifier table lookups succeeded (%f%%)\n",
                  NumIdentifierLookupHits, NumIdentifierLookups,
                  (double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
-  }
 
   if (GlobalIndex) {
     std::fprintf(stderr, "\n");
@@ -7526,7 +7557,8 @@ dumpModuleIDMap(StringRef Name,
   if (Map.begin() == Map.end())
     return;
 
-  typedef ContinuousRangeMap<Key, ModuleFile *, InitialCapacity> MapType;
+  using MapType = ContinuousRangeMap<Key, ModuleFile *, InitialCapacity>;
+
   llvm::errs() << Name << ":\n";
   for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
        I != IEnd; ++I) {
@@ -7723,7 +7755,7 @@ namespace clang {
     StringRef Next() override;
   };
 
-} // end namespace clang
+} // namespace clang
 
 ASTIdentifierIterator::ASTIdentifierIterator(const ASTReader &Reader,
                                              bool SkipModules)
@@ -7781,7 +7813,7 @@ public:
   }
 };
 
-} // end anonymous namespace.
+} // namespace
 
 IdentifierIterator *ASTReader::getIdentifiers() {
   if (!loadGlobalIndex()) {
@@ -7803,19 +7835,17 @@ namespace serialization {
     ASTReader &Reader;
     Selector Sel;
     unsigned PriorGeneration;
-    unsigned InstanceBits;
-    unsigned FactoryBits;
-    bool InstanceHasMoreThanOneDecl;
-    bool FactoryHasMoreThanOneDecl;
+    unsigned InstanceBits = 0;
+    unsigned FactoryBits = 0;
+    bool InstanceHasMoreThanOneDecl = false;
+    bool FactoryHasMoreThanOneDecl = false;
     SmallVector<ObjCMethodDecl *, 4> InstanceMethods;
     SmallVector<ObjCMethodDecl *, 4> FactoryMethods;
 
   public:
     ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel,
                           unsigned PriorGeneration)
-        : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration),
-          InstanceBits(0), FactoryBits(0), InstanceHasMoreThanOneDecl(false),
-          FactoryHasMoreThanOneDecl(false) {}
+        : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
 
     bool operator()(ModuleFile &M) {
       if (!M.SelectorLookupTable)
@@ -7863,14 +7893,16 @@ namespace serialization {
 
     unsigned getInstanceBits() const { return InstanceBits; }
     unsigned getFactoryBits() const { return FactoryBits; }
+
     bool instanceHasMoreThanOneDecl() const {
       return InstanceHasMoreThanOneDecl;
     }
+
     bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; }
   };
 
-} // end namespace serialization
-} // end namespace clang
+} // namespace serialization
+} // namespace clang
 
 /// \brief Add the given set of methods to the method list.
 static void addMethodsToPool(Sema &S, ArrayRef<ObjCMethodDecl *> Methods,
@@ -8013,7 +8045,7 @@ void ASTReader::ReadUnusedLocalTypedefNa
 }
 
 void ASTReader::ReadReferencedSelectors(
-       SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {
+       SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) {
   if (ReferencedSelectorsData.empty())
     return;
 
@@ -8031,7 +8063,7 @@ void ASTReader::ReadReferencedSelectors(
 }
 
 void ASTReader::ReadWeakUndeclaredIdentifiers(
-       SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WeakIDs) {
+       SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WeakIDs) {
   if (WeakUndeclaredIdentifiers.empty())
     return;
 
@@ -8063,7 +8095,7 @@ void ASTReader::ReadUsedVTables(SmallVec
 }
 
 void ASTReader::ReadPendingInstantiations(
-       SmallVectorImpl<std::pair<ValueDecl *, SourceLocation> > &Pending) {
+       SmallVectorImpl<std::pair<ValueDecl *, SourceLocation>> &Pending) {
   for (unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
     ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
     SourceLocation Loc
@@ -8775,11 +8807,10 @@ ASTReader::ReadNestedNameSpecifier(Modul
       break;
     }
 
-    case NestedNameSpecifier::Global: {
+    case NestedNameSpecifier::Global:
       NNS = NestedNameSpecifier::GlobalSpecifier(Context);
       // No associated value, and there can't be a prefix.
       break;
-    }
 
     case NestedNameSpecifier::Super: {
       CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
@@ -8956,7 +8987,7 @@ void ASTReader::ReadComments() {
   ASTContext &Context = getContext();
   std::vector<RawComment *> Comments;
   for (SmallVectorImpl<std::pair<BitstreamCursor,
-                                 serialization::ModuleFile *> >::iterator
+                                 serialization::ModuleFile *>>::iterator
        I = CommentsCursors.begin(),
        E = CommentsCursors.end();
        I != E; ++I) {
@@ -9046,7 +9077,7 @@ std::string ASTReader::getOwningModuleNa
     return M->ModuleName;
 
   // Not from a module.
-  return "";
+  return {};
 }
 
 void ASTReader::finishPendingActions() {
@@ -9056,8 +9087,8 @@ void ASTReader::finishPendingActions() {
          !PendingUpdateRecords.empty()) {
     // If any identifiers with corresponding top-level declarations have
     // been loaded, load those declarations now.
-    typedef llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2> >
-      TopLevelDeclsMap;
+    using TopLevelDeclsMap =
+        llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
     TopLevelDeclsMap TopLevelDecls;
 
     while (!PendingIdentifierInfos.empty()) {
@@ -10424,7 +10455,7 @@ void ASTReader::diagnoseOdrViolations()
       }
       }
 
-      if (Diagnosed == true)
+      if (Diagnosed)
         continue;
 
       Diag(FirstDecl->getLocation(),




More information about the cfe-commits mailing list