r317953 - [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
Fri Nov 10 16:08:51 PST 2017


Author: eugenezelenko
Date: Fri Nov 10 16:08:50 2017
New Revision: 317953

URL: http://llvm.org/viewvc/llvm-project?rev=317953&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/ASTWriter.h
    cfe/trunk/include/clang/Serialization/ModuleManager.h
    cfe/trunk/lib/Serialization/ASTReaderInternals.h
    cfe/trunk/lib/Serialization/ASTWriter.cpp
    cfe/trunk/lib/Serialization/ModuleManager.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=317953&r1=317952&r2=317953&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Nov 10 16:08:50 2017
@@ -1,4 +1,4 @@
-//===--- ASTWriter.h - AST File Writer --------------------------*- C++ -*-===//
+//===- ASTWriter.h - AST File Writer ----------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -11,67 +11,89 @@
 //  containing a serialized representation of a translation unit.
 //
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CLANG_SERIALIZATION_ASTWRITER_H
 #define LLVM_CLANG_SERIALIZATION_ASTWRITER_H
 
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/TemplateBase.h"
+#include "clang/AST/TemplateName.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Sema/SemaConsumer.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTDeserializationListener.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Bitcode/BitstreamWriter.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <ctime>
+#include <memory>
 #include <queue>
+#include <string>
+#include <utility>
 #include <vector>
 
 namespace llvm {
-  class APFloat;
-  class APInt;
-}
+
+class APFloat;
+class APInt;
+class APSInt;
+
+} // namespace llvm
 
 namespace clang {
 
-class DeclarationName;
 class ASTContext;
+class ASTReader;
+class ASTUnresolvedSet;
 class Attr;
-class NestedNameSpecifier;
 class CXXBaseSpecifier;
 class CXXCtorInitializer;
+class CXXRecordDecl;
+class CXXTemporary;
 class FileEntry;
 class FPOptions;
+class FunctionDecl;
 class HeaderSearch;
 class HeaderSearchOptions;
 class IdentifierResolver;
+class LangOptions;
 class MacroDefinitionRecord;
-class MacroDirective;
 class MacroInfo;
-class OpaqueValueExpr;
-class OpenCLOptions;
-class ASTReader;
 class MemoryBufferCache;
 class Module;
 class ModuleFileExtension;
 class ModuleFileExtensionWriter;
-class PreprocessedEntity;
+class NamedDecl;
+class NestedNameSpecifier;
+class ObjCInterfaceDecl;
 class PreprocessingRecord;
 class Preprocessor;
+struct QualifierInfo;
 class RecordDecl;
 class Sema;
 class SourceManager;
+class Stmt;
 struct StoredDeclsList;
 class SwitchCase;
-class TargetInfo;
+class TemplateParameterList;
 class Token;
+class TypeSourceInfo;
 class VersionTuple;
-class ASTUnresolvedSet;
-
-namespace SrcMgr { class SLocEntry; }
 
 /// \brief Writes an AST file containing the contents of a translation unit.
 ///
@@ -82,14 +104,15 @@ namespace SrcMgr { class SLocEntry; }
 class ASTWriter : public ASTDeserializationListener,
                   public ASTMutationListener {
 public:
-  typedef SmallVector<uint64_t, 64> RecordData;
-  typedef SmallVectorImpl<uint64_t> RecordDataImpl;
-  typedef ArrayRef<uint64_t> RecordDataRef;
-
   friend class ASTDeclWriter;
+  friend class ASTRecordWriter;
   friend class ASTStmtWriter;
   friend class ASTTypeWriter;
-  friend class ASTRecordWriter;
+
+  using RecordData = SmallVector<uint64_t, 64>;
+  using RecordDataImpl = SmallVectorImpl<uint64_t>;
+  using RecordDataRef = ArrayRef<uint64_t>;
+
 private:
   /// \brief Map that provides the ID numbers of each type within the
   /// output stream, plus those deserialized from a chained PCH.
@@ -100,9 +123,8 @@ private:
   /// allow for the const/volatile qualifiers.
   ///
   /// Keys in the map never have const/volatile qualifiers.
-  typedef llvm::DenseMap<QualType, serialization::TypeIdx,
-                         serialization::UnsafeQualTypeDenseMapInfo>
-    TypeIdxMap;
+  using TypeIdxMap = llvm::DenseMap<QualType, serialization::TypeIdx,
+                                    serialization::UnsafeQualTypeDenseMapInfo>;
 
   /// \brief The bitstream writer used to emit this precompiled header.
   llvm::BitstreamWriter &Stream;
@@ -152,8 +174,8 @@ private:
   /// \brief Stores a declaration or a type to be written to the AST file.
   class DeclOrType {
   public:
-    DeclOrType(Decl *D) : Stored(D), IsType(false) { }
-    DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) { }
+    DeclOrType(Decl *D) : Stored(D), IsType(false) {}
+    DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) {}
 
     bool isType() const { return IsType; }
     bool isDecl() const { return !IsType; }
@@ -195,15 +217,16 @@ private:
   std::vector<serialization::DeclOffset> DeclOffsets;
 
   /// \brief Sorted (by file offset) vector of pairs of file offset/DeclID.
-  typedef SmallVector<std::pair<unsigned, serialization::DeclID>, 64>
-    LocDeclIDsTy;
+  using LocDeclIDsTy =
+      SmallVector<std::pair<unsigned, serialization::DeclID>, 64>;
   struct DeclIDInFileInfo {
     LocDeclIDsTy DeclIDs;
+
     /// \brief Set when the DeclIDs vectors from all files are joined, this
     /// indicates the index that this particular vector has in the global one.
     unsigned FirstDeclIndex;
   };
-  typedef llvm::DenseMap<FileID, DeclIDInFileInfo *> FileDeclIDsTy;
+  using FileDeclIDsTy = llvm::DenseMap<FileID, DeclIDInFileInfo *>;
 
   /// \brief Map from file SLocEntries to info about the file-level declarations
   /// that it contains.
@@ -260,6 +283,7 @@ private:
     MacroInfo *MI;
     serialization::MacroID ID;
   };
+
   /// \brief The macro infos to emit.
   std::vector<MacroInfoToEmitData> MacroInfosToEmit;
 
@@ -331,31 +355,33 @@ private:
         : Kind(Kind), Type(Type.getAsOpaquePtr()) {}
     DeclUpdate(unsigned Kind, SourceLocation Loc)
         : Kind(Kind), Loc(Loc.getRawEncoding()) {}
-    DeclUpdate(unsigned Kind, unsigned Val)
-        : Kind(Kind), Val(Val) {}
-    DeclUpdate(unsigned Kind, Module *M)
-          : Kind(Kind), Mod(M) {}
+    DeclUpdate(unsigned Kind, unsigned Val) : Kind(Kind), Val(Val) {}
+    DeclUpdate(unsigned Kind, Module *M) : Kind(Kind), Mod(M) {}
     DeclUpdate(unsigned Kind, const Attr *Attribute)
           : Kind(Kind), Attribute(Attribute) {}
 
     unsigned getKind() const { return Kind; }
     const Decl *getDecl() const { return Dcl; }
     QualType getType() const { return QualType::getFromOpaquePtr(Type); }
+
     SourceLocation getLoc() const {
       return SourceLocation::getFromRawEncoding(Loc);
     }
+
     unsigned getNumber() const { return Val; }
     Module *getModule() const { return Mod; }
     const Attr *getAttr() const { return Attribute; }
   };
 
-  typedef SmallVector<DeclUpdate, 1> UpdateRecord;
-  typedef llvm::MapVector<const Decl *, UpdateRecord> DeclUpdateMap;
+  using UpdateRecord = SmallVector<DeclUpdate, 1>;
+  using DeclUpdateMap = llvm::MapVector<const Decl *, UpdateRecord>;
+
   /// \brief Mapping from declarations that came from a chained PCH to the
   /// record containing modifications to them.
   DeclUpdateMap DeclUpdates;
 
-  typedef llvm::DenseMap<Decl *, Decl *> FirstLatestDeclMap;
+  using FirstLatestDeclMap = llvm::DenseMap<Decl *, Decl *>;
+
   /// \brief Map of first declarations from a chained PCH that point to the
   /// most recent declarations in another PCH.
   FirstLatestDeclMap FirstLatestDecls;
@@ -600,7 +626,6 @@ public:
   /// \brief Emit a reference to a declaration.
   void AddDeclRef(const Decl *D, RecordDataImpl &Record);
 
-
   /// \brief Force a declaration to be emitted and get its ID.
   serialization::DeclID GetDeclRef(const Decl *D);
 
@@ -651,6 +676,7 @@ public:
   unsigned getTypeExtQualAbbrev() const {
     return TypeExtQualAbbrev;
   }
+
   unsigned getTypeFunctionProtoAbbrev() const {
     return TypeFunctionProtoAbbrev;
   }
@@ -757,8 +783,8 @@ public:
       : Writer(Parent.Writer), Record(&Record) {}
 
   /// Copying an ASTRecordWriter is almost certainly a bug.
-  ASTRecordWriter(const ASTRecordWriter&) = delete;
-  void operator=(const ASTRecordWriter&) = delete;
+  ASTRecordWriter(const ASTRecordWriter &) = delete;
+  ASTRecordWriter &operator=(const ASTRecordWriter &) = delete;
 
   /// \brief Extract the underlying record storage.
   ASTWriter::RecordDataImpl &getRecordData() const { return *Record; }
@@ -910,7 +936,7 @@ public:
   void AddUnresolvedSet(const ASTUnresolvedSet &Set);
 
   /// \brief Emit a CXXCtorInitializer array.
-  void AddCXXCtorInitializers(ArrayRef<CXXCtorInitializer*> CtorInits);
+  void AddCXXCtorInitializers(ArrayRef<CXXCtorInitializer *> CtorInits);
 
   void AddCXXDefinitionData(const CXXRecordDecl *D);
 
@@ -956,6 +982,7 @@ public:
                ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
                bool AllowASTWithErrors = false, bool IncludeTimestamps = true);
   ~PCHGenerator() override;
+
   void InitializeSema(Sema &S) override { SemaPtr = &S; }
   void HandleTranslationUnit(ASTContext &Ctx) override;
   ASTMutationListener *GetASTMutationListener() override;
@@ -963,6 +990,6 @@ public:
   bool hasEmittedPCH() const { return Buffer->IsComplete; }
 };
 
-} // end namespace clang
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_SERIALIZATION_ASTWRITER_H

Modified: cfe/trunk/include/clang/Serialization/ModuleManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleManager.h?rev=317953&r1=317952&r2=317953&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ModuleManager.h (original)
+++ cfe/trunk/include/clang/Serialization/ModuleManager.h Fri Nov 10 16:08:50 2017
@@ -1,4 +1,4 @@
-//===--- ModuleManager.cpp - Module Manager ---------------------*- C++ -*-===//
+//===- ModuleManager.cpp - Module Manager -----------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -15,19 +15,33 @@
 #ifndef LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H
 #define LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H
 
-#include "clang/Basic/FileManager.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/Module.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Serialization/Module.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
+#include <cstdint>
+#include <ctime>
+#include <memory>
+#include <string>
+#include <utility>
 
-namespace clang { 
+namespace clang {
 
+class FileEntry;
+class FileManager;
 class GlobalModuleIndex;
+class HeaderSearch;
 class MemoryBufferCache;
 class ModuleMap;
 class PCHContainerReader;
-class HeaderSearch;
 
 namespace serialization {
 
@@ -83,14 +97,12 @@ class ModuleManager {
   ///
   /// The global module index will actually be owned by the ASTReader; this is
   /// just an non-owning pointer.
-  GlobalModuleIndex *GlobalIndex;
+  GlobalModuleIndex *GlobalIndex = nullptr;
 
   /// \brief State used by the "visit" operation to avoid malloc traffic in
   /// calls to visit().
   struct VisitState {
-    explicit VisitState(unsigned N)
-      : VisitNumber(N, 0), NextVisitNumber(1), NextState(nullptr)
-    {
+    explicit VisitState(unsigned N) : VisitNumber(N, 0) {
       Stack.reserve(N);
     }
 
@@ -107,29 +119,26 @@ class ModuleManager {
     SmallVector<unsigned, 4> VisitNumber;
 
     /// \brief The next visit number to use to mark visited module files.
-    unsigned NextVisitNumber;
+    unsigned NextVisitNumber = 1;
 
     /// \brief The next visit state.
-    VisitState *NextState;
+    VisitState *NextState = nullptr;
   };
 
   /// \brief The first visit() state in the chain.
-  VisitState *FirstVisitState;
+  VisitState *FirstVisitState = nullptr;
 
   VisitState *allocateVisitState();
   void returnVisitState(VisitState *State);
 
 public:
-  typedef llvm::pointee_iterator<
-      SmallVectorImpl<std::unique_ptr<ModuleFile>>::iterator>
-      ModuleIterator;
-  typedef llvm::pointee_iterator<
-      SmallVectorImpl<std::unique_ptr<ModuleFile>>::const_iterator>
-      ModuleConstIterator;
-  typedef llvm::pointee_iterator<
-      SmallVectorImpl<std::unique_ptr<ModuleFile>>::reverse_iterator>
-      ModuleReverseIterator;
-  typedef std::pair<uint32_t, StringRef> ModuleOffset;
+  using ModuleIterator = llvm::pointee_iterator<
+      SmallVectorImpl<std::unique_ptr<ModuleFile>>::iterator>;
+  using ModuleConstIterator = llvm::pointee_iterator<
+      SmallVectorImpl<std::unique_ptr<ModuleFile>>::const_iterator>;
+  using ModuleReverseIterator = llvm::pointee_iterator<
+      SmallVectorImpl<std::unique_ptr<ModuleFile>>::reverse_iterator>;
+  using ModuleOffset = std::pair<uint32_t, StringRef>;
 
   explicit ModuleManager(FileManager &FileMgr, MemoryBufferCache &PCMCache,
                          const PCHContainerReader &PCHContainerRdr,
@@ -138,16 +147,19 @@ public:
 
   /// \brief Forward iterator to traverse all loaded modules.
   ModuleIterator begin() { return Chain.begin(); }
+
   /// \brief Forward iterator end-point to traverse all loaded modules
   ModuleIterator end() { return Chain.end(); }
   
   /// \brief Const forward iterator to traverse all loaded modules.
   ModuleConstIterator begin() const { return Chain.begin(); }
+
   /// \brief Const forward iterator end-point to traverse all loaded modules
   ModuleConstIterator end() const { return Chain.end(); }
   
   /// \brief Reverse iterator to traverse all loaded modules.
   ModuleReverseIterator rbegin() { return Chain.rbegin(); }
+
   /// \brief Reverse iterator end-point to traverse all loaded modules.
   ModuleReverseIterator rend() { return Chain.rend(); }
 
@@ -187,15 +199,18 @@ public:
   enum AddModuleResult {
     /// \brief The module file had already been loaded.
     AlreadyLoaded,
+
     /// \brief The module file was just loaded in response to this call.
     NewlyLoaded,
+
     /// \brief The module file is missing.
     Missing,
+
     /// \brief The module file is out-of-date.
     OutOfDate
   };
 
-  typedef ASTFileSignature(*ASTFileSignatureReader)(StringRef);
+  using ASTFileSignatureReader = ASTFileSignature (*)(StringRef);
 
   /// \brief Attempts to create a new module and add it to the list of known
   /// modules.
@@ -306,6 +321,8 @@ public:
   MemoryBufferCache &getPCMCache() const { return *PCMCache; }
 };
 
-} } // end namespace clang::serialization
+} // namespace serialization
+
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H

Modified: cfe/trunk/lib/Serialization/ASTReaderInternals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderInternals.h?rev=317953&r1=317952&r2=317953&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderInternals.h (original)
+++ cfe/trunk/lib/Serialization/ASTReaderInternals.h Fri Nov 10 16:08:50 2017
@@ -1,4 +1,4 @@
-//===--- ASTReaderInternals.h - AST Reader Internals ------------*- C++ -*-===//
+//===- ASTReaderInternals.h - AST Reader Internals --------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -10,23 +10,29 @@
 //  This file provides internal definitions used in the AST reader.
 //
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CLANG_LIB_SERIALIZATION_ASTREADERINTERNALS_H
 #define LLVM_CLANG_LIB_SERIALIZATION_ASTREADERINTERNALS_H
 
 #include "MultiOnDiskHashTable.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/Support/Endian.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/OnDiskHashTable.h"
+#include <ctime>
 #include <utility>
 
 namespace clang {
 
 class ASTReader;
-class HeaderSearch;
-struct HeaderFileInfo;
 class FileEntry;
+struct HeaderFileInfo;
+class HeaderSearch;
+class IdentifierTable;
+class ObjCMethodDecl;
   
 namespace serialization {
 
@@ -45,12 +51,14 @@ public:
   static const int MaxTables = 4;
 
   /// The lookup result is a list of global declaration IDs.
-  typedef llvm::SmallVector<DeclID, 4> data_type;
+  using data_type = SmallVector<DeclID, 4>;
+
   struct data_type_builder {
     data_type &Data;
     llvm::DenseSet<DeclID> Found;
 
     data_type_builder(data_type &D) : Data(D) {}
+
     void insert(DeclID ID) {
       // Just use a linear scan unless we have more than a few IDs.
       if (Found.empty() && !Data.empty()) {
@@ -70,15 +78,15 @@ public:
         Data.push_back(ID);
     }
   };
-  typedef unsigned hash_value_type;
-  typedef unsigned offset_type;
-  typedef ModuleFile *file_type;
+  using hash_value_type = unsigned;
+  using offset_type = unsigned;
+  using file_type = ModuleFile *;
 
-  typedef DeclarationName external_key_type;
-  typedef DeclarationNameKey internal_key_type;
+  using external_key_type = DeclarationName;
+  using internal_key_type = DeclarationNameKey;
 
   explicit ASTDeclContextNameLookupTrait(ASTReader &Reader, ModuleFile &F)
-    : Reader(Reader), F(F) { }
+      : Reader(Reader), F(F) {}
 
   static bool EqualKey(const internal_key_type &a, const internal_key_type &b) {
     return a == b;
@@ -87,6 +95,7 @@ public:
   static hash_value_type ComputeHash(const internal_key_type &Key) {
     return Key.getHash();
   }
+
   static internal_key_type GetInternalKey(const external_key_type &Name) {
     return Name;
   }
@@ -119,14 +128,13 @@ struct DeclContextLookupTable {
 /// functionality for accessing the on-disk hash table of identifiers
 /// in an AST file. Different subclasses customize that functionality
 /// based on what information they are interested in. Those subclasses
-/// must provide the \c data_type typedef and the ReadData operation,
-/// only.
+/// must provide the \c data_type type and the ReadData operation, only.
 class ASTIdentifierLookupTraitBase {
 public:
-  typedef StringRef external_key_type;
-  typedef StringRef internal_key_type;
-  typedef unsigned hash_value_type;
-  typedef unsigned offset_type;
+  using external_key_type = StringRef;
+  using internal_key_type = StringRef;
+  using hash_value_type = unsigned;
+  using offset_type = unsigned;
 
   static bool EqualKey(const internal_key_type& a, const internal_key_type& b) {
     return a == b;
@@ -159,11 +167,11 @@ class ASTIdentifierLookupTrait : public
   IdentifierInfo *KnownII;
   
 public:
-  typedef IdentifierInfo * data_type;
+  using data_type = IdentifierInfo *;
 
   ASTIdentifierLookupTrait(ASTReader &Reader, ModuleFile &F,
                            IdentifierInfo *II = nullptr)
-    : Reader(Reader), F(F), KnownII(II) { }
+      : Reader(Reader), F(F), KnownII(II) {}
 
   data_type ReadData(const internal_key_type& k,
                      const unsigned char* d,
@@ -176,8 +184,8 @@ public:
   
 /// \brief The on-disk hash table used to contain information about
 /// all of the identifiers in the program.
-typedef llvm::OnDiskIterableChainedHashTable<ASTIdentifierLookupTrait>
-  ASTIdentifierLookupTable;
+using ASTIdentifierLookupTable =
+    llvm::OnDiskIterableChainedHashTable<ASTIdentifierLookupTrait>;
 
 /// \brief Class that performs lookup for a selector's entries in the global
 /// method pool stored in an AST file.
@@ -196,13 +204,13 @@ public:
     SmallVector<ObjCMethodDecl *, 2> Factory;
   };
   
-  typedef Selector external_key_type;
-  typedef external_key_type internal_key_type;
-  typedef unsigned hash_value_type;
-  typedef unsigned offset_type;
+  using external_key_type = Selector;
+  using internal_key_type = external_key_type;
+  using hash_value_type = unsigned;
+  using offset_type = unsigned;
   
-  ASTSelectorLookupTrait(ASTReader &Reader, ModuleFile &F) 
-    : Reader(Reader), F(F) { }
+  ASTSelectorLookupTrait(ASTReader &Reader, ModuleFile &F)
+      : Reader(Reader), F(F) {}
   
   static bool EqualKey(const internal_key_type& a,
                        const internal_key_type& b) {
@@ -222,8 +230,8 @@ public:
 };
   
 /// \brief The on-disk hash table used for the global method pool.
-typedef llvm::OnDiskChainedHashTable<ASTSelectorLookupTrait>
-  ASTSelectorLookupTable;
+using ASTSelectorLookupTable =
+    llvm::OnDiskChainedHashTable<ASTSelectorLookupTrait>;
   
 /// \brief Trait class used to search the on-disk hash table containing all of
 /// the header search information.
@@ -241,7 +249,7 @@ class HeaderFileInfoTrait {
   const char *FrameworkStrings;
 
 public:
-  typedef const FileEntry *external_key_type;
+  using external_key_type = const FileEntry *;
 
   struct internal_key_type {
     off_t Size;
@@ -249,15 +257,16 @@ public:
     StringRef Filename;
     bool Imported;
   };
-  typedef const internal_key_type &internal_key_ref;
+
+  using internal_key_ref = const internal_key_type &;
   
-  typedef HeaderFileInfo data_type;
-  typedef unsigned hash_value_type;
-  typedef unsigned offset_type;
+  using data_type = HeaderFileInfo;
+  using hash_value_type = unsigned;
+  using offset_type = unsigned;
   
   HeaderFileInfoTrait(ASTReader &Reader, ModuleFile &M, HeaderSearch *HS,
                       const char *FrameworkStrings)
-  : Reader(Reader), M(M), HS(HS), FrameworkStrings(FrameworkStrings) { }
+      : Reader(Reader), M(M), HS(HS), FrameworkStrings(FrameworkStrings) {}
   
   static hash_value_type ComputeHash(internal_key_ref ikey);
   internal_key_type GetInternalKey(const FileEntry *FE);
@@ -272,12 +281,13 @@ public:
 };
 
 /// \brief The on-disk hash table used for known header files.
-typedef llvm::OnDiskChainedHashTable<HeaderFileInfoTrait>
-  HeaderFileInfoLookupTable;
+using HeaderFileInfoLookupTable =
+    llvm::OnDiskChainedHashTable<HeaderFileInfoTrait>;
   
-} // end namespace clang::serialization::reader
-} // end namespace clang::serialization
-} // end namespace clang
+} // namespace reader
+
+} // namespace serialization
 
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_LIB_SERIALIZATION_ASTREADERINTERNALS_H

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=317953&r1=317952&r2=317953&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Nov 10 16:08:50 2017
@@ -1,4 +1,4 @@
-//===--- ASTWriter.cpp - AST File Writer ------------------------*- C++ -*-===//
+//===- ASTWriter.cpp - AST File Writer ------------------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -17,11 +17,15 @@
 #include "MultiOnDiskHashTable.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTUnresolvedSet.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclContextInternals.h"
 #include "clang/AST/DeclFriend.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/LambdaCapture.h"
@@ -30,16 +34,22 @@
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLocVisitor.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/Lambda.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/MemoryBufferCache.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/ObjCRuntime.h"
+#include "clang/Basic/OpenCLOptions.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/SourceManagerInternals.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Basic/Version.h"
@@ -62,24 +72,30 @@
 #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/Hashing.h"
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.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/Bitcode/BitCodes.h"
 #include "llvm/Bitcode/BitstreamWriter.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compression.h"
+#include "llvm/Support/Endian.h"
 #include "llvm/Support/EndianStream.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/OnDiskHashTable.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/Process.h"
 #include "llvm/Support/SHA1.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
@@ -87,11 +103,14 @@
 #include <cstdint>
 #include <cstdlib>
 #include <cstring>
+#include <ctime>
 #include <deque>
 #include <limits>
-#include <new>
+#include <memory>
+#include <queue>
 #include <tuple>
 #include <utility>
+#include <vector>
 
 using namespace clang;
 using namespace clang::serialization;
@@ -120,13 +139,14 @@ namespace clang {
     ASTRecordWriter Record;
 
     /// \brief Type code that corresponds to the record generated.
-    TypeCode Code;
+    TypeCode Code = static_cast<TypeCode>(0);
+
     /// \brief Abbreviation to use for the record, if any.
-    unsigned AbbrevToUse;
+    unsigned AbbrevToUse = 0;
 
   public:
     ASTTypeWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
-      : Writer(Writer), Record(Writer, Record), Code((TypeCode)0), AbbrevToUse(0) { }
+      : Writer(Writer), Record(Writer, Record) {}
 
     uint64_t Emit() {
       return Record.Emit(Code, AbbrevToUse);
@@ -160,7 +180,7 @@ namespace clang {
 #include "clang/AST/TypeNodes.def"
   };
 
-} // end namespace clang
+} // namespace clang
 
 void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) {
   llvm_unreachable("Built-in types are never serialized");
@@ -550,8 +570,7 @@ class TypeLocWriter : public TypeLocVisi
   ASTRecordWriter &Record;
 
 public:
-  TypeLocWriter(ASTRecordWriter &Record)
-    : Record(Record) { }
+  TypeLocWriter(ASTRecordWriter &Record) : Record(Record) {}
 
 #define ABSTRACT_TYPELOC(CLASS, PARENT)
 #define TYPELOC(CLASS, PARENT) \
@@ -562,7 +581,7 @@ public:
   void VisitFunctionTypeLoc(FunctionTypeLoc TyLoc);
 };
 
-} // end anonymous namespace
+} // namespace
 
 void TypeLocWriter::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
   // nothing to do
@@ -667,18 +686,23 @@ void TypeLocWriter::VisitFunctionTypeLoc
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
     Record.AddDeclRef(TL.getParam(i));
 }
+
 void TypeLocWriter::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
   VisitFunctionTypeLoc(TL);
 }
+
 void TypeLocWriter::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
   VisitFunctionTypeLoc(TL);
 }
+
 void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
   Record.AddSourceLocation(TL.getNameLoc());
 }
+
 void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
   Record.AddSourceLocation(TL.getNameLoc());
 }
+
 void TypeLocWriter::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
   if (TL.getNumProtocols()) {
     Record.AddSourceLocation(TL.getProtocolLAngleLoc());
@@ -687,6 +711,7 @@ void TypeLocWriter::VisitObjCTypeParamTy
   for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
     Record.AddSourceLocation(TL.getProtocolLoc(i));
 }
+
 void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
   Record.AddSourceLocation(TL.getTypeofLoc());
   Record.AddSourceLocation(TL.getLParenLoc());
@@ -1416,6 +1441,7 @@ void ASTWriter::WriteControlBlock(Prepro
                                   StringRef isysroot,
                                   const std::string &OutputFile) {
   using namespace llvm;
+
   Stream.EnterSubblock(CONTROL_BLOCK_ID, 5);
   RecordData Record;
   
@@ -1706,21 +1732,22 @@ void ASTWriter::WriteControlBlock(Prepro
 
 namespace  {
 
-  /// \brief An input file.
-  struct InputFileEntry {
-    const FileEntry *File;
-    bool IsSystemFile;
-    bool IsTransient;
-    bool BufferOverridden;
-    bool IsTopLevelModuleMap;
-  };
+/// \brief An input file.
+struct InputFileEntry {
+  const FileEntry *File;
+  bool IsSystemFile;
+  bool IsTransient;
+  bool BufferOverridden;
+  bool IsTopLevelModuleMap;
+};
 
-} // end anonymous namespace
+} // namespace
 
 void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
                                 HeaderSearchOptions &HSOpts,
                                 bool Modules) {
   using namespace llvm;
+
   Stream.EnterSubblock(INPUT_FILES_BLOCK_ID, 4);
 
   // Create input-file abbreviation.
@@ -1897,7 +1924,7 @@ namespace {
       off_t Size;
       time_t ModTime;
     };
-    typedef const key_type &key_type_ref;
+    using key_type_ref = const key_type &;
 
     using UnresolvedModule =
         llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
@@ -1907,10 +1934,10 @@ namespace {
       ArrayRef<ModuleMap::KnownHeader> KnownHeaders;
       UnresolvedModule Unresolved;
     };
-    typedef const data_type &data_type_ref;
+    using data_type_ref = const data_type &;
 
-    typedef unsigned hash_value_type;
-    typedef unsigned offset_type;
+    using hash_value_type = unsigned;
+    using offset_type = unsigned;
     
     hash_value_type ComputeHash(key_type_ref key) {
       // The hash is based only on size/time of the file, so that the reader can
@@ -1919,9 +1946,10 @@ namespace {
       return llvm::hash_combine(key.Size, key.ModTime);
     }
     
-    std::pair<unsigned,unsigned>
+    std::pair<unsigned, unsigned>
     EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
       using namespace llvm::support;
+
       endian::Writer<little> LE(Out);
       unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
       LE.write<uint16_t>(KeyLen);
@@ -1937,6 +1965,7 @@ namespace {
 
     void EmitKey(raw_ostream& Out, key_type_ref key, unsigned KeyLen) {
       using namespace llvm::support;
+
       endian::Writer<little> LE(Out);
       LE.write<uint64_t>(key.Size);
       KeyLen -= 8;
@@ -1948,6 +1977,7 @@ namespace {
     void EmitData(raw_ostream &Out, key_type_ref key,
                   data_type_ref Data, unsigned DataLen) {
       using namespace llvm::support;
+
       endian::Writer<little> LE(Out);
       uint64_t Start = Out.tell(); (void)Start;
       
@@ -2002,7 +2032,7 @@ namespace {
     const char *strings_end() const { return FrameworkStringData.end(); }
   };
 
-} // end anonymous namespace
+} // namespace
 
 /// \brief Write the header search block for the list of files that 
 ///
@@ -2115,6 +2145,7 @@ void ASTWriter::WriteHeaderSearch(const
   uint32_t BucketOffset;
   {
     using namespace llvm::support;
+
     llvm::raw_svector_ostream Out(TableData);
     // Make sure that no bucket is at offset 0
     endian::Writer<little>(Out).write<uint32_t>(0);
@@ -2146,7 +2177,7 @@ void ASTWriter::WriteHeaderSearch(const
 static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
                      unsigned SLocBufferBlobCompressedAbbrv,
                      unsigned SLocBufferBlobAbbrv) {
-  typedef ASTWriter::RecordData::value_type RecordDataType;
+  using RecordDataType = ASTWriter::RecordData::value_type;
 
   // Compress the buffer if possible. We expect that almost all PCM
   // consumers will not want its contents.
@@ -2390,7 +2421,6 @@ static bool shouldIgnoreMacro(MacroDirec
 
 /// \brief Writes the block containing the serialized form of the
 /// preprocessor.
-///
 void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
   PreprocessingRecord *PPRec = PP.getPreprocessingRecord();
   if (PPRec)
@@ -3207,28 +3237,29 @@ class ASTMethodPoolTrait {
   ASTWriter &Writer;
 
 public:
-  typedef Selector key_type;
-  typedef key_type key_type_ref;
+  using key_type = Selector;
+  using key_type_ref = key_type;
 
   struct data_type {
     SelectorID ID;
     ObjCMethodList Instance, Factory;
   };
-  typedef const data_type& data_type_ref;
+  using data_type_ref = const data_type &;
 
-  typedef unsigned hash_value_type;
-  typedef unsigned offset_type;
+  using hash_value_type = unsigned;
+  using offset_type = unsigned;
 
-  explicit ASTMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) { }
+  explicit ASTMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) {}
 
   static hash_value_type ComputeHash(Selector Sel) {
     return serialization::ComputeHash(Sel);
   }
 
-  std::pair<unsigned,unsigned>
+  std::pair<unsigned, unsigned>
     EmitKeyDataLength(raw_ostream& Out, Selector Sel,
                       data_type_ref Methods) {
     using namespace llvm::support;
+
     endian::Writer<little> LE(Out);
     unsigned KeyLen = 2 + (Sel.getNumArgs()? Sel.getNumArgs() * 4 : 4);
     LE.write<uint16_t>(KeyLen);
@@ -3247,6 +3278,7 @@ public:
 
   void EmitKey(raw_ostream& Out, Selector Sel, unsigned) {
     using namespace llvm::support;
+
     endian::Writer<little> LE(Out);
     uint64_t Start = Out.tell();
     assert((Start >> 32) == 0 && "Selector key offset too large");
@@ -3263,6 +3295,7 @@ public:
   void EmitData(raw_ostream& Out, key_type_ref,
                 data_type_ref Methods, unsigned DataLen) {
     using namespace llvm::support;
+
     endian::Writer<little> LE(Out);
     uint64_t Start = Out.tell(); (void)Start;
     LE.write<uint32_t>(Methods.ID);
@@ -3307,7 +3340,7 @@ public:
   }
 };
 
-} // end anonymous namespace
+} // namespace
 
 /// \brief Write ObjC data: selectors and the method pool.
 ///
@@ -3371,6 +3404,7 @@ void ASTWriter::WriteSelectors(Sema &Sem
     uint32_t BucketOffset;
     {
       using namespace llvm::support;
+
       ASTMethodPoolTrait Trait(*this);
       llvm::raw_svector_ostream Out(MethodPool);
       // Make sure that no bucket is at offset 0
@@ -3415,6 +3449,7 @@ void ASTWriter::WriteSelectors(Sema &Sem
 /// \brief Write the selectors referenced in @selector expression into AST file.
 void ASTWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
   using namespace llvm;
+
   if (SemaRef.ReferencedSelectors.empty())
     return;
 
@@ -3503,14 +3538,14 @@ class ASTIdentifierTableTrait {
   }
 
 public:
-  typedef IdentifierInfo* key_type;
-  typedef key_type  key_type_ref;
+  using key_type = IdentifierInfo *;
+  using key_type_ref = key_type;
 
-  typedef IdentID data_type;
-  typedef data_type data_type_ref;
+  using data_type = IdentID;
+  using data_type_ref = data_type;
 
-  typedef unsigned hash_value_type;
-  typedef unsigned offset_type;
+  using hash_value_type = unsigned;
+  using offset_type = unsigned;
 
   ASTIdentifierTableTrait(ASTWriter &Writer, Preprocessor &PP,
                           IdentifierResolver &IdResolver, bool IsModule,
@@ -3534,7 +3569,7 @@ public:
     return isInterestingIdentifier(II, 0);
   }
 
-  std::pair<unsigned,unsigned>
+  std::pair<unsigned, unsigned>
   EmitKeyDataLength(raw_ostream& Out, IdentifierInfo* II, IdentID ID) {
     unsigned KeyLen = II->getLength() + 1;
     unsigned DataLen = 4; // 4 bytes for the persistent ID << 1
@@ -3552,7 +3587,9 @@ public:
           DataLen += 4;
       }
     }
+
     using namespace llvm::support;
+
     endian::Writer<little> LE(Out);
 
     assert((uint16_t)DataLen == DataLen && (uint16_t)KeyLen == KeyLen);
@@ -3581,6 +3618,7 @@ public:
   void EmitData(raw_ostream& Out, IdentifierInfo* II,
                 IdentID ID, unsigned) {
     using namespace llvm::support;
+
     endian::Writer<little> LE(Out);
 
     auto MacroOffset = Writer.getMacroDirectivesOffset(II);
@@ -3624,7 +3662,7 @@ public:
   }
 };
 
-} // end anonymous namespace
+} // namespace
 
 /// \brief Write the identifier table into the AST file.
 ///
@@ -3682,6 +3720,7 @@ void ASTWriter::WriteIdentifierTable(Pre
     uint32_t BucketOffset;
     {
       using namespace llvm::support;
+
       llvm::raw_svector_ostream Out(IdentifierTable);
       // Make sure that no bucket is at offset 0
       endian::Writer<little>(Out).write<uint32_t>(0);
@@ -3737,17 +3776,17 @@ class ASTDeclContextNameLookupTrait {
   llvm::SmallVector<DeclID, 64> DeclIDs;
 
 public:
-  typedef DeclarationNameKey key_type;
-  typedef key_type key_type_ref;
+  using key_type = DeclarationNameKey;
+  using key_type_ref = key_type;
 
   /// A start and end index into DeclIDs, representing a sequence of decls.
-  typedef std::pair<unsigned, unsigned> data_type;
-  typedef const data_type& data_type_ref;
+  using data_type = std::pair<unsigned, unsigned>;
+  using data_type_ref = const data_type &;
 
-  typedef unsigned hash_value_type;
-  typedef unsigned offset_type;
+  using hash_value_type = unsigned;
+  using offset_type = unsigned;
 
-  explicit ASTDeclContextNameLookupTrait(ASTWriter &Writer) : Writer(Writer) { }
+  explicit ASTDeclContextNameLookupTrait(ASTWriter &Writer) : Writer(Writer) {}
 
   template<typename Coll>
   data_type getData(const Coll &Decls) {
@@ -3779,6 +3818,7 @@ public:
            "have reference to loaded module file but no chain?");
 
     using namespace llvm::support;
+
     endian::Writer<little>(Out)
         .write<uint32_t>(Writer.getChain()->getModuleFileID(F));
   }
@@ -3787,6 +3827,7 @@ public:
                                                   DeclarationNameKey Name,
                                                   data_type_ref Lookup) {
     using namespace llvm::support;
+
     endian::Writer<little> LE(Out);
     unsigned KeyLen = 1;
     switch (Name.getKind()) {
@@ -3820,6 +3861,7 @@ public:
 
   void EmitKey(raw_ostream &Out, DeclarationNameKey Name, unsigned) {
     using namespace llvm::support;
+
     endian::Writer<little> LE(Out);
     LE.write<uint8_t>(Name.getKind());
     switch (Name.getKind()) {
@@ -3851,6 +3893,7 @@ public:
   void EmitData(raw_ostream &Out, key_type_ref, data_type Lookup,
                 unsigned DataLen) {
     using namespace llvm::support;
+
     endian::Writer<little> LE(Out);
     uint64_t Start = Out.tell(); (void)Start;
     for (unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
@@ -3859,7 +3902,7 @@ public:
   }
 };
 
-} // end anonymous namespace
+} // namespace
 
 bool ASTWriter::isLookupResultExternal(StoredDeclsList &Result,
                                        DeclContext *DC) {
@@ -4392,7 +4435,6 @@ void ASTRecordWriter::AddAttributes(Arra
     Record.AddSourceRange(A->getRange());
 
 #include "clang/Serialization/AttrPCHWrite.inc"
-
   }
 }
 
@@ -4837,7 +4879,6 @@ ASTFileSignature ASTWriter::WriteASTCore
     // module-kind is the ModuleKind enum value. If it is MK_PrebuiltModule or
     // MK_ExplicitModule, then the module-name is the module name. Otherwise,
     // it is the module file name.
-    //
     auto Abbrev = std::make_shared<BitCodeAbbrev>();
     Abbrev->Add(BitCodeAbbrevOp(MODULE_OFFSET_MAP));
     Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
@@ -4847,6 +4888,7 @@ ASTFileSignature ASTWriter::WriteASTCore
       llvm::raw_svector_ostream Out(Buffer);
       for (ModuleFile &M : Chain->ModuleMgr) {
         using namespace llvm::support;
+
         endian::Writer<little> LE(Out);
         LE.write<uint8_t>(static_cast<uint8_t>(M.Kind));
         StringRef Name =

Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=317953&r1=317952&r2=317953&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Fri Nov 10 16:08:50 2017
@@ -1,4 +1,4 @@
-//===--- ModuleManager.cpp - Module Manager ---------------------*- C++ -*-===//
+//===- ModuleManager.cpp - Module Manager ---------------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -11,20 +11,34 @@
 //  modules for the ASTReader.
 //
 //===----------------------------------------------------------------------===//
+
 #include "clang/Serialization/ModuleManager.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/MemoryBufferCache.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Serialization/GlobalModuleIndex.h"
+#include "clang/Serialization/Module.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/DOTGraphTraits.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/GraphWriter.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
+#include <algorithm>
+#include <cassert>
+#include <memory>
+#include <string>
 #include <system_error>
 
-#ifndef NDEBUG
-#include "llvm/Support/GraphWriter.h"
-#endif
-
 using namespace clang;
 using namespace serialization;
 
@@ -208,7 +222,6 @@ void ModuleManager::removeModules(
   if (First == Last)
     return;
 
-
   // Explicitly clear VisitOrder since we might not notice it is stale.
   VisitOrder.clear();
 
@@ -267,7 +280,6 @@ void ModuleManager::removeModules(
 void
 ModuleManager::addInMemoryBuffer(StringRef FileName,
                                  std::unique_ptr<llvm::MemoryBuffer> Buffer) {
-
   const FileEntry *Entry =
       FileMgr.getVirtualFile(FileName, Buffer->getBufferSize(), 0);
   InMemoryBuffers[Entry] = std::move(Buffer);
@@ -317,8 +329,7 @@ ModuleManager::ModuleManager(FileManager
                              const PCHContainerReader &PCHContainerRdr,
                              const HeaderSearch& HeaderSearchInfo)
     : FileMgr(FileMgr), PCMCache(&PCMCache), PCHContainerRdr(PCHContainerRdr),
-      HeaderSearchInfo (HeaderSearchInfo), GlobalIndex(),
-      FirstVisitState(nullptr) {}
+      HeaderSearchInfo(HeaderSearchInfo) {}
 
 ModuleManager::~ModuleManager() { delete FirstVisitState; }
 
@@ -452,11 +463,12 @@ bool ModuleManager::lookupModuleFile(Str
 
 #ifndef NDEBUG
 namespace llvm {
+
   template<>
   struct GraphTraits<ModuleManager> {
-    typedef ModuleFile *NodeRef;
-    typedef llvm::SetVector<ModuleFile *>::const_iterator ChildIteratorType;
-    typedef pointer_iterator<ModuleManager::ModuleConstIterator> nodes_iterator;
+    using NodeRef = ModuleFile *;
+    using ChildIteratorType = llvm::SetVector<ModuleFile *>::const_iterator;
+    using nodes_iterator = pointer_iterator<ModuleManager::ModuleConstIterator>;
 
     static ChildIteratorType child_begin(NodeRef Node) {
       return Node->Imports.begin();
@@ -478,17 +490,16 @@ namespace llvm {
   template<>
   struct DOTGraphTraits<ModuleManager> : public DefaultDOTGraphTraits {
     explicit DOTGraphTraits(bool IsSimple = false)
-      : DefaultDOTGraphTraits(IsSimple) { }
+        : DefaultDOTGraphTraits(IsSimple) {}
     
-    static bool renderGraphFromBottomUp() {
-      return true;
-    }
+    static bool renderGraphFromBottomUp() { return true; }
 
     std::string getNodeLabel(ModuleFile *M, const ModuleManager&) {
       return M->ModuleName;
     }
   };
-}
+
+} // namespace llvm
 
 void ModuleManager::viewGraph() {
   llvm::ViewGraph(*this, "Modules");




More information about the cfe-commits mailing list