[Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317953
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index 7563440..b512fa4 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -1,4 +1,4 @@
-//===--- ModuleManager.cpp - Module Manager ---------------------*- C++ -*-===//
+//===- ModuleManager.cpp - Module Manager ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,19 +11,33 @@
// 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 "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
-#include <system_error>
-
-#ifndef NDEBUG
+#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"
-#endif
+#include "llvm/Support/MemoryBuffer.h"
+#include <algorithm>
+#include <cassert>
+#include <memory>
+#include <string>
+#include <system_error>
using namespace clang;
using namespace serialization;
@@ -208,7 +222,6 @@
if (First == Last)
return;
-
// Explicitly clear VisitOrder since we might not notice it is stale.
VisitOrder.clear();
@@ -267,7 +280,6 @@
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 @@
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 @@
#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 @@
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");