fbcode: remove unused includes from .cpp files with no #if and #define v2016.12.19.00
authorMathieu Baudet <mathieubaudet@fb.com>
Sun, 18 Dec 2016 02:23:24 +0000 (18:23 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 18 Dec 2016 02:33:03 +0000 (18:33 -0800)
Summary:
This is a first diff to remove the "easiest" unused includes in fbcode.

* For safety, we only touch .cpp files without #if and #define,
* We do not try to remove redundant systems headers (aka. "packing").

The diff was generated as follows:
```
foundation/scripts/ls-cpp-dirs | grep -v '^\(\.\.\|external/\|.*/external\)' | xargs ffmr -o /tmp/ffmr-diff-1 codegraph/scripts/ffmr/analyze_includes_no_headers_no_packing_skipping_ifdefs.sh

cat /tmp/ffmr-diff-1/*.diff | patch -p2
hg commit -m something
arc diff --prepare --nolint --nounit --less-context --excuse refactoring
```

Note: `grep -v` is just an optimization. The actual configuration is in these two files:
diffusion/FBS/browse/master/fbcode/codegraph/analysis/config.py
diffusion/FBS/browse/master/fbcode/codegraph/scripts/ffmr/analyze_includes_no_headers_no_packing_skipping_ifdefs.sh

See the task for more context, and the recent "safety" improvements on the tool.

depends on D4317825 for very few cases where `nolint` had to be manually added.

Reviewed By: igorsugak

Differential Revision: D4312617

fbshipit-source-id: ecc1f0addfd0651fa4770fcc43cd1314661a311a

26 files changed:
folly/experimental/RCUUtils.cpp
folly/experimental/exception_tracer/test/ExceptionCounterTest.cpp
folly/experimental/io/FsUtil.cpp
folly/experimental/io/HugePageUtil.cpp
folly/experimental/test/TestUtilTest.cpp
folly/futures/ManualExecutor.cpp
folly/futures/test/RetryingTest.cpp
folly/futures/test/TimekeeperTest.cpp
folly/io/ShutdownSocketSet.cpp
folly/io/async/test/DelayedDestructionBaseTest.cpp
folly/io/async/test/HHWheelTimerTest.cpp
folly/io/async/test/SSLSessionTest.cpp
folly/io/async/test/SocketPair.cpp
folly/test/AtomicHashMapTest.cpp
folly/test/BatonTest.cpp
folly/test/ExceptionWrapperTest.cpp
folly/test/LoggingBenchmark.cpp
folly/test/MemoryIdlerTest.cpp
folly/test/PortabilityTest.cpp
folly/test/RandomBenchmark.cpp
folly/test/ScopeGuardTest.cpp
folly/test/SingletonTestGlobal.cpp
folly/test/SingletonVaultCTest.cpp
folly/test/StringBenchmark.cpp
folly/test/SubprocessTestParentDeathHelper.cpp
folly/test/ThreadLocalTestLib.cpp

index 48ae846ac8022cb8d7677b954c25fec7114f34a5..d1c0eb76d5a7f20b5c196790374a35bec40626c2 100644 (file)
  */
 #include <folly/experimental/RCUUtils.h>
 
-#include <folly/Portability.h>
 #include <folly/ThreadLocal.h>
 
-
 namespace folly {
 
 namespace {
index 6751396b2ef8db05d859ed324bb512c6d3028aa5..bab2178d5ff29c64d4c447eee682eca5919cb12a 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include <stdexcept>
-#include <typeinfo>
 #include <thread>
 #include <mutex>
 #include <condition_variable>
index c6f75fb58c67da0f143014c839533fa81f0d4a0f..05d0147fe40ad77a9056fb1873b4890811202508 100644 (file)
@@ -17,7 +17,6 @@
 #include <folly/experimental/io/FsUtil.h>
 
 #include <folly/Exception.h>
-#include <folly/portability/Unistd.h>
 
 namespace bsys = ::boost::system;
 
index 09f3c07397e9aa7068a5daa8b1710e193a668829..48cda29c342f2980ba552a7081be2fb14d98b6cc 100644 (file)
  * limitations under the License.
  */
 
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
-
 #include <iostream>
 #include <stdexcept>
-#include <system_error>
 
 #include <folly/File.h>
 #include <folly/Format.h>
 #include <folly/MemoryMapping.h>
-#include <folly/Portability.h>
 #include <folly/Range.h>
 #include <folly/ScopeGuard.h>
 #include <folly/experimental/io/HugePages.h>
 #include <folly/portability/GFlags.h>
-#include <folly/portability/Unistd.h>
 
 DEFINE_bool(cp, false, "Copy file");
 
index 79046e0736ea126f8b91f4339a4a45ee192ea61e..4dea41061dfd512276402254a8475aa01a1be63b 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <folly/experimental/TestUtil.h>
 
-#include <sys/stat.h>
 #include <sys/types.h>
 
 #include <system_error>
index 5586afba7953b53b3a21756650d8d2df29e5515b..53980d64f75961b7e7b12832d14192348118dd86 100644 (file)
@@ -20,8 +20,6 @@
 #include <string>
 #include <tuple>
 
-#include <stdexcept>
-
 namespace folly {
 
 void ManualExecutor::add(Func callback) {
index 6988e5dff1bb7c40973f5279a302eceba12576c7..32b3b445dc95ee96ff675e993e098b42341ea58c 100644 (file)
 
 #include <algorithm>
 #include <atomic>
-#include <exception>
 #include <vector>
 
 #include <folly/futures/Future.h>
 #include <folly/portability/GTest.h>
 
-
 using namespace std;
 using namespace std::chrono;
 using namespace folly;
index 664dd73708e7ab941dbef89fb7fff3b736bc0cd0..9c69253af9bf02340376b614e685f971f78b94de 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <folly/futures/Timekeeper.h>
 #include <folly/portability/GTest.h>
-#include <folly/portability/Unistd.h>
 
 using namespace folly;
 using std::chrono::milliseconds;
index 215024e9e5a8fcd64ff08a6ba6648b4017ce81e7..a671c0df3689909deed013d2fb793c67027ac6b1 100644 (file)
@@ -16,8 +16,6 @@
 
 #include <folly/io/ShutdownSocketSet.h>
 
-#include <sys/types.h>
-
 #include <chrono>
 #include <thread>
 
index 580b2e52571ece1576b0591665f34daf22177bc7..bf820ca7721e08b3448274d3cef17113ce1c21ef 100644 (file)
@@ -34,8 +34,6 @@
 #include <folly/io/async/DelayedDestructionBase.h>
 
 #include <functional>
-#include <list>
-#include <vector>
 
 #include <folly/portability/GTest.h>
 
index d265f34ff582638dbae991658aa9b299c60025aa..efe9b5a152028fa3854584a475d3af76b9e739cf 100644 (file)
@@ -22,8 +22,6 @@
 #include <folly/io/async/test/Util.h>
 #include <folly/portability/GTest.h>
 
-#include <vector>
-
 using namespace folly;
 using std::chrono::milliseconds;
 
index ce7084c3237ea4960fc3030157daa26afdfdc52a..1927f8aa957cac2a6f37cb2680d78ca0f5965925 100644 (file)
@@ -17,7 +17,6 @@
 #include <folly/io/async/test/AsyncSSLSocketTest.h>
 #include <folly/portability/GTest.h>
 #include <folly/portability/Sockets.h>
-#include <folly/portability/Unistd.h>
 #include <folly/ssl/SSLSession.h>
 
 using namespace std;
index e2eae1b182932ad568db147f6e84120572adfe2a..08c8cc27c39078cd3432d95a25e0a5d290dbb2f5 100644 (file)
@@ -24,7 +24,6 @@
 #include <folly/portability/Unistd.h>
 
 #include <errno.h>
-#include <sys/types.h>
 #include <stdexcept>
 
 namespace folly {
index c39553952cb27b6cc7bbda1b79ffa07749a267fc..59103bbc5fe133c6c2bf8727923efdcfd828dcef 100644 (file)
@@ -24,7 +24,6 @@
 #include <folly/Assume.h>
 #include <folly/Benchmark.h>
 #include <folly/Conv.h>
-#include <folly/portability/Atomic.h>
 #include <folly/portability/GTest.h>
 #include <folly/portability/SysTime.h>
 
index 4fbc6959149527e7030fc21f4a14be10ec8226e6..e41a0753ebb1679753cac8aff6215a10e1f4cce4 100644 (file)
@@ -20,7 +20,6 @@
 #include <folly/portability/GTest.h>
 
 #include <thread>
-#include <semaphore.h>
 
 using namespace folly;
 using namespace folly::test;
index b1ee6e936d1528a0f39377140e4a90a0d786285c..26090a7628c23e153852a5e023de5ee2270e3c01 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <folly/ExceptionWrapper.h>
 #include <folly/Conv.h>
-#include <folly/Portability.h>
 #include <folly/portability/GTest.h>
 
 using namespace folly;
index bd08b23cd2fcfa76e15e37e7da31d6de31d7b2e9..6e483b31e3a85c3b102ef2cd9f55c0ffcd172b9d 100644 (file)
@@ -18,8 +18,6 @@
 
 #include <folly/Benchmark.h>
 
-#include <vector>
-
 BENCHMARK(skip_overhead, iter) {
   auto prev = FLAGS_minloglevel;
   FLAGS_minloglevel = 2;
index 74e377a8578b0ee81186a1c9276c03ce2aae1b9f..22f54f26347b0aff8037bcc0bb42f21071b7fd84 100644 (file)
 #include <folly/Baton.h>
 #include <folly/portability/GMock.h>
 #include <folly/portability/GTest.h>
-#include <folly/portability/Windows.h>
 
 #include <memory>
 #include <thread>
-#include <assert.h>
-#include <semaphore.h>
 
 using namespace folly;
 using namespace folly::detail;
index 58d104d940c7eeeb150cf2e9c66831fad79e9d61..e424cd5eb894ce6ce4d246dc28e339c4ab97ae8e 100644 (file)
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-#include <folly/Portability.h>
-
 #include <memory>
 
 #include <folly/portability/GTest.h>
index 14a0edb3d5e822d3408c15ebbc7506ee8bf249a7..37b8f09b5c16b2a41fa9698b28d111032225da7c 100644 (file)
@@ -22,9 +22,7 @@
 
 #include <glog/logging.h>
 
-#include <algorithm>
 #include <thread>
-#include <vector>
 #include <random>
 
 using namespace folly;
index b3eb981b663b01759dbb774b71583595f227803f..a3d8a02c09db0c47d2e855afcff19df439021dc8 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include <folly/ScopeGuard.h>
-#include <folly/Portability.h>
 
 #include <glog/logging.h>
 
index d62f41d1bea483f1158c82e443242e7c43746edc..02f1a8b6112f392c1ff395f78532542e5a1eaa5a 100644 (file)
@@ -22,8 +22,6 @@
 #include <folly/test/SingletonTestStructs.h>
 #include <folly/portability/GTest.h>
 
-#include <glog/logging.h>
-
 /*
  * This test needs to be in its own file, as a standalone program.
  * We want to ensure no other singletons are registered, so we can
index 471cc3571d74de686eda0252cfee842ca4494879..48f796fa5e4ce2bd54a6449419f409a758a9ee39 100644 (file)
@@ -17,8 +17,6 @@
 #include <folly/Singleton.h>
 #include <folly/SingletonVault_c.h>
 
-#include <thread>
-
 #include <folly/portability/GTest.h>
 
 FOLLY_TLS long instance_counter_instances = 0;
index d6b57161fbea59ad5a3d9e59dd87c9eb09d7a56d..5e2361f637b5c10f4bd07b3dfe7d38f13c86d9d1 100644 (file)
@@ -19,7 +19,6 @@
 #include <boost/algorithm/string.hpp>
 #include <folly/Benchmark.h>
 #include <folly/Random.h>
-#include <cstdarg>
 #include <random>
 
 using namespace folly;
index 6dfa896e191ec7f0a6352743ff78d9162408ddb3..13ee2d7d27667efa56fa4262d4f73dc4dfd3b4d8 100644 (file)
@@ -23,7 +23,6 @@
 // worked as intended.
 
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <fcntl.h>
 #include <signal.h>
 
index d61137ac5fa4837c569d10b25bd7f10c0d88c093..6161d4f4bf6d2aaaa14ed98134b01483cb6de46f 100644 (file)
@@ -13,8 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include <iostream>
-#include <thread>
 
 #include <folly/ThreadLocal.h>