From f3e216131b7b0a889507c3c4100b298c75ad3d84 Mon Sep 17 00:00:00 2001
From: Daniel Pfeifer <daniel@pfeifer-mail.de>
Date: Fri, 5 May 2017 23:21:39 +0200
Subject: cmServer: include what you use

---
 Source/cmFileMonitor.cxx      |  4 ++--
 Source/cmFileMonitor.h        |  4 +++-
 Source/cmServer.cxx           | 19 +++++++------------
 Source/cmServer.h             |  7 +++----
 Source/cmServerConnection.cxx |  3 +--
 Source/cmServerConnection.h   | 14 ++++++--------
 Source/cmServerProtocol.cxx   | 21 +++++++++++++--------
 Source/cmServerProtocol.h     | 16 ++++++++--------
 8 files changed, 43 insertions(+), 45 deletions(-)

diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx
index ed794c3..6971465 100644
--- a/Source/cmFileMonitor.cxx
+++ b/Source/cmFileMonitor.cxx
@@ -5,9 +5,9 @@
 #include "cmsys/SystemTools.hxx"
 
 #include <cassert>
-#include <iostream>
-#include <set>
+#include <stddef.h>
 #include <unordered_map>
+#include <utility>
 
 namespace {
 void on_directory_change(uv_fs_event_t* handle, const char* filename,
diff --git a/Source/cmFileMonitor.h b/Source/cmFileMonitor.h
index 8574db0..d7ec92a 100644
--- a/Source/cmFileMonitor.h
+++ b/Source/cmFileMonitor.h
@@ -2,7 +2,7 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #pragma once
 
-#include "cmConfigure.h" // IWYU pragma: keep
+#include "cmConfigure.h"
 
 #include <functional>
 #include <string>
@@ -14,6 +14,8 @@ class cmRootWatcher;
 
 class cmFileMonitor
 {
+  CM_DISABLE_COPY(cmFileMonitor)
+
 public:
   cmFileMonitor(uv_loop_t* l);
   ~cmFileMonitor();
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 5a71dc0..19bdd45 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -6,18 +6,15 @@
 #include "cmServerDictionary.h"
 #include "cmServerProtocol.h"
 #include "cmSystemTools.h"
-#include "cmVersionMacros.h"
-#include "cmake.h"
-
-#if defined(CMAKE_BUILD_WITH_CMAKE)
 #include "cm_jsoncpp_reader.h"
-#include "cm_jsoncpp_value.h"
-#endif
+#include "cm_jsoncpp_writer.h"
+#include "cmake.h"
+#include "cmsys/FStream.hxx"
 
 #include <algorithm>
-#include <fstream>
-#include <iostream>
-#include <memory>
+#include <cassert>
+#include <cstdint>
+#include <utility>
 
 class cmServer::DebugInfo
 {
@@ -270,10 +267,8 @@ void cmServer::WriteJsonObject(const Json::Value& jsonValue,
     }
 
     if (!debug->OutputFile.empty()) {
-      std::ofstream myfile;
-      myfile.open(debug->OutputFile);
+      cmsys::ofstream myfile(debug->OutputFile.c_str());
       myfile << result;
-      myfile.close();
     }
   }
 
diff --git a/Source/cmServer.h b/Source/cmServer.h
index 7f29e32..b814050 100644
--- a/Source/cmServer.h
+++ b/Source/cmServer.h
@@ -2,13 +2,10 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #pragma once
 
-#include "cmListFileCache.h"
-#include "cmState.h"
+#include "cmConfigure.h"
 
-#if defined(CMAKE_BUILD_WITH_CMAKE)
 #include "cm_jsoncpp_value.h"
 #include "cm_uv.h"
-#endif
 
 #include <string>
 #include <vector>
@@ -21,6 +18,8 @@ class cmServerResponse;
 
 class cmServer
 {
+  CM_DISABLE_COPY(cmServer)
+
 public:
   class DebugInfo;
 
diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx
index 008052b..36312ed 100644
--- a/Source/cmServerConnection.cxx
+++ b/Source/cmServerConnection.cxx
@@ -2,10 +2,9 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmServerConnection.h"
 
-#include "cmServerDictionary.h"
-
 #include "cmFileMonitor.h"
 #include "cmServer.h"
+#include "cmServerDictionary.h"
 
 #include <assert.h>
 #include <string.h>
diff --git a/Source/cmServerConnection.h b/Source/cmServerConnection.h
index 1fabe37..b96bf3c 100644
--- a/Source/cmServerConnection.h
+++ b/Source/cmServerConnection.h
@@ -2,21 +2,19 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #pragma once
 
-#include "cmConfigure.h" // IWYU pragma: keep
+#include "cmConfigure.h"
 
-#include <string>
-#include <vector>
-
-#if defined(CMAKE_BUILD_WITH_CMAKE)
 #include "cm_uv.h"
-#endif
 
-class cmServer;
+#include <string>
+
 class cmFileMonitor;
-class LoopGuard;
+class cmServer;
 
 class cmServerConnection
 {
+  CM_DISABLE_COPY(cmServerConnection)
+
 public:
   cmServerConnection();
   virtual ~cmServerConnection();
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 11ee897..4e9e80f 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -4,27 +4,32 @@
 
 #include "cmExternalMakefileProjectGenerator.h"
 #include "cmFileMonitor.h"
+#include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
 #include "cmLinkLineComputer.h"
-#include "cmListFileCache.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmServer.h"
 #include "cmServerDictionary.h"
 #include "cmSourceFile.h"
+#include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
+#include "cmStateTypes.h"
 #include "cmSystemTools.h"
+#include "cm_uv.h"
 #include "cmake.h"
 
-#include "cmServerDictionary.h"
-
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cm_jsoncpp_reader.h"
-#include "cm_jsoncpp_value.h"
-#endif
-
 #include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <functional>
+#include <limits>
+#include <map>
+#include <set>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 // Get rid of some windows macros:
diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h
index 027f145..83b3d58 100644
--- a/Source/cmServerProtocol.h
+++ b/Source/cmServerProtocol.h
@@ -2,20 +2,17 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #pragma once
 
-#include "cmListFileCache.h"
-#include "cmake.h"
+#include "cmConfigure.h"
 
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cm_jsoncpp_writer.h"
-#endif
+#include "cm_jsoncpp_value.h"
+#include "cmake.h"
 
 #include <memory>
 #include <string>
+#include <utility>
 
-class cmake;
 class cmFileMonitor;
 class cmServer;
-
 class cmServerRequest;
 
 class cmServerResponse
@@ -72,8 +69,11 @@ private:
 
 class cmServerProtocol
 {
+  CM_DISABLE_COPY(cmServerProtocol)
+
 public:
-  virtual ~cmServerProtocol() {}
+  cmServerProtocol() = default;
+  virtual ~cmServerProtocol() = default;
 
   virtual std::pair<int, int> ProtocolVersion() const = 0;
   virtual bool IsExperimental() const = 0;
-- 
cgit v0.12