From d0856c87e70789282667a63015ac8c0509cf3e52 Mon Sep 17 00:00:00 2001 From: Mathieu Baudet Date: Sat, 17 Dec 2016 18:23:24 -0800 Subject: [PATCH] fbcode: remove unused includes from .cpp files with no #if and #define 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 --- folly/experimental/RCUUtils.cpp | 2 -- .../exception_tracer/test/ExceptionCounterTest.cpp | 1 - folly/experimental/io/FsUtil.cpp | 1 - folly/experimental/io/HugePageUtil.cpp | 9 --------- folly/experimental/test/TestUtilTest.cpp | 1 - folly/futures/ManualExecutor.cpp | 2 -- folly/futures/test/RetryingTest.cpp | 2 -- folly/futures/test/TimekeeperTest.cpp | 1 - folly/io/ShutdownSocketSet.cpp | 2 -- folly/io/async/test/DelayedDestructionBaseTest.cpp | 2 -- folly/io/async/test/HHWheelTimerTest.cpp | 2 -- folly/io/async/test/SSLSessionTest.cpp | 1 - folly/io/async/test/SocketPair.cpp | 1 - folly/test/AtomicHashMapTest.cpp | 1 - folly/test/BatonTest.cpp | 1 - folly/test/ExceptionWrapperTest.cpp | 1 - folly/test/LoggingBenchmark.cpp | 2 -- folly/test/MemoryIdlerTest.cpp | 3 --- folly/test/PortabilityTest.cpp | 2 -- folly/test/RandomBenchmark.cpp | 2 -- folly/test/ScopeGuardTest.cpp | 1 - folly/test/SingletonTestGlobal.cpp | 2 -- folly/test/SingletonVaultCTest.cpp | 2 -- folly/test/StringBenchmark.cpp | 1 - folly/test/SubprocessTestParentDeathHelper.cpp | 1 - folly/test/ThreadLocalTestLib.cpp | 2 -- 26 files changed, 48 deletions(-) diff --git a/folly/experimental/RCUUtils.cpp b/folly/experimental/RCUUtils.cpp index 48ae846a..d1c0eb76 100644 --- a/folly/experimental/RCUUtils.cpp +++ b/folly/experimental/RCUUtils.cpp @@ -15,10 +15,8 @@ */ #include -#include #include - namespace folly { namespace { diff --git a/folly/experimental/exception_tracer/test/ExceptionCounterTest.cpp b/folly/experimental/exception_tracer/test/ExceptionCounterTest.cpp index 6751396b..bab2178d 100644 --- a/folly/experimental/exception_tracer/test/ExceptionCounterTest.cpp +++ b/folly/experimental/exception_tracer/test/ExceptionCounterTest.cpp @@ -15,7 +15,6 @@ */ #include -#include #include #include #include diff --git a/folly/experimental/io/FsUtil.cpp b/folly/experimental/io/FsUtil.cpp index c6f75fb5..05d0147f 100644 --- a/folly/experimental/io/FsUtil.cpp +++ b/folly/experimental/io/FsUtil.cpp @@ -17,7 +17,6 @@ #include #include -#include namespace bsys = ::boost::system; diff --git a/folly/experimental/io/HugePageUtil.cpp b/folly/experimental/io/HugePageUtil.cpp index 09f3c073..48cda29c 100644 --- a/folly/experimental/io/HugePageUtil.cpp +++ b/folly/experimental/io/HugePageUtil.cpp @@ -14,25 +14,16 @@ * limitations under the License. */ -#include -#include -#include -#include -#include - #include #include -#include #include #include #include -#include #include #include #include #include -#include DEFINE_bool(cp, false, "Copy file"); diff --git a/folly/experimental/test/TestUtilTest.cpp b/folly/experimental/test/TestUtilTest.cpp index 79046e07..4dea4106 100644 --- a/folly/experimental/test/TestUtilTest.cpp +++ b/folly/experimental/test/TestUtilTest.cpp @@ -16,7 +16,6 @@ #include -#include #include #include diff --git a/folly/futures/ManualExecutor.cpp b/folly/futures/ManualExecutor.cpp index 5586afba..53980d64 100644 --- a/folly/futures/ManualExecutor.cpp +++ b/folly/futures/ManualExecutor.cpp @@ -20,8 +20,6 @@ #include #include -#include - namespace folly { void ManualExecutor::add(Func callback) { diff --git a/folly/futures/test/RetryingTest.cpp b/folly/futures/test/RetryingTest.cpp index 6988e5df..32b3b445 100644 --- a/folly/futures/test/RetryingTest.cpp +++ b/folly/futures/test/RetryingTest.cpp @@ -16,13 +16,11 @@ #include #include -#include #include #include #include - using namespace std; using namespace std::chrono; using namespace folly; diff --git a/folly/futures/test/TimekeeperTest.cpp b/folly/futures/test/TimekeeperTest.cpp index 664dd737..9c69253a 100644 --- a/folly/futures/test/TimekeeperTest.cpp +++ b/folly/futures/test/TimekeeperTest.cpp @@ -16,7 +16,6 @@ #include #include -#include using namespace folly; using std::chrono::milliseconds; diff --git a/folly/io/ShutdownSocketSet.cpp b/folly/io/ShutdownSocketSet.cpp index 215024e9..a671c0df 100644 --- a/folly/io/ShutdownSocketSet.cpp +++ b/folly/io/ShutdownSocketSet.cpp @@ -16,8 +16,6 @@ #include -#include - #include #include diff --git a/folly/io/async/test/DelayedDestructionBaseTest.cpp b/folly/io/async/test/DelayedDestructionBaseTest.cpp index 580b2e52..bf820ca7 100644 --- a/folly/io/async/test/DelayedDestructionBaseTest.cpp +++ b/folly/io/async/test/DelayedDestructionBaseTest.cpp @@ -34,8 +34,6 @@ #include #include -#include -#include #include diff --git a/folly/io/async/test/HHWheelTimerTest.cpp b/folly/io/async/test/HHWheelTimerTest.cpp index d265f34f..efe9b5a1 100644 --- a/folly/io/async/test/HHWheelTimerTest.cpp +++ b/folly/io/async/test/HHWheelTimerTest.cpp @@ -22,8 +22,6 @@ #include #include -#include - using namespace folly; using std::chrono::milliseconds; diff --git a/folly/io/async/test/SSLSessionTest.cpp b/folly/io/async/test/SSLSessionTest.cpp index ce7084c3..1927f8aa 100644 --- a/folly/io/async/test/SSLSessionTest.cpp +++ b/folly/io/async/test/SSLSessionTest.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include using namespace std; diff --git a/folly/io/async/test/SocketPair.cpp b/folly/io/async/test/SocketPair.cpp index e2eae1b1..08c8cc27 100644 --- a/folly/io/async/test/SocketPair.cpp +++ b/folly/io/async/test/SocketPair.cpp @@ -24,7 +24,6 @@ #include #include -#include #include namespace folly { diff --git a/folly/test/AtomicHashMapTest.cpp b/folly/test/AtomicHashMapTest.cpp index c3955395..59103bbc 100644 --- a/folly/test/AtomicHashMapTest.cpp +++ b/folly/test/AtomicHashMapTest.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include diff --git a/folly/test/BatonTest.cpp b/folly/test/BatonTest.cpp index 4fbc6959..e41a0753 100644 --- a/folly/test/BatonTest.cpp +++ b/folly/test/BatonTest.cpp @@ -20,7 +20,6 @@ #include #include -#include using namespace folly; using namespace folly::test; diff --git a/folly/test/ExceptionWrapperTest.cpp b/folly/test/ExceptionWrapperTest.cpp index b1ee6e93..26090a76 100644 --- a/folly/test/ExceptionWrapperTest.cpp +++ b/folly/test/ExceptionWrapperTest.cpp @@ -18,7 +18,6 @@ #include #include -#include #include using namespace folly; diff --git a/folly/test/LoggingBenchmark.cpp b/folly/test/LoggingBenchmark.cpp index bd08b23c..6e483b31 100644 --- a/folly/test/LoggingBenchmark.cpp +++ b/folly/test/LoggingBenchmark.cpp @@ -18,8 +18,6 @@ #include -#include - BENCHMARK(skip_overhead, iter) { auto prev = FLAGS_minloglevel; FLAGS_minloglevel = 2; diff --git a/folly/test/MemoryIdlerTest.cpp b/folly/test/MemoryIdlerTest.cpp index 74e377a8..22f54f26 100644 --- a/folly/test/MemoryIdlerTest.cpp +++ b/folly/test/MemoryIdlerTest.cpp @@ -19,12 +19,9 @@ #include #include #include -#include #include #include -#include -#include using namespace folly; using namespace folly::detail; diff --git a/folly/test/PortabilityTest.cpp b/folly/test/PortabilityTest.cpp index 58d104d9..e424cd5e 100644 --- a/folly/test/PortabilityTest.cpp +++ b/folly/test/PortabilityTest.cpp @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include #include diff --git a/folly/test/RandomBenchmark.cpp b/folly/test/RandomBenchmark.cpp index 14a0edb3..37b8f09b 100644 --- a/folly/test/RandomBenchmark.cpp +++ b/folly/test/RandomBenchmark.cpp @@ -22,9 +22,7 @@ #include -#include #include -#include #include using namespace folly; diff --git a/folly/test/ScopeGuardTest.cpp b/folly/test/ScopeGuardTest.cpp index b3eb981b..a3d8a02c 100644 --- a/folly/test/ScopeGuardTest.cpp +++ b/folly/test/ScopeGuardTest.cpp @@ -15,7 +15,6 @@ */ #include -#include #include diff --git a/folly/test/SingletonTestGlobal.cpp b/folly/test/SingletonTestGlobal.cpp index d62f41d1..02f1a8b6 100644 --- a/folly/test/SingletonTestGlobal.cpp +++ b/folly/test/SingletonTestGlobal.cpp @@ -22,8 +22,6 @@ #include #include -#include - /* * 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 diff --git a/folly/test/SingletonVaultCTest.cpp b/folly/test/SingletonVaultCTest.cpp index 471cc357..48f796fa 100644 --- a/folly/test/SingletonVaultCTest.cpp +++ b/folly/test/SingletonVaultCTest.cpp @@ -17,8 +17,6 @@ #include #include -#include - #include FOLLY_TLS long instance_counter_instances = 0; diff --git a/folly/test/StringBenchmark.cpp b/folly/test/StringBenchmark.cpp index d6b57161..5e2361f6 100644 --- a/folly/test/StringBenchmark.cpp +++ b/folly/test/StringBenchmark.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include using namespace folly; diff --git a/folly/test/SubprocessTestParentDeathHelper.cpp b/folly/test/SubprocessTestParentDeathHelper.cpp index 6dfa896e..13ee2d7d 100644 --- a/folly/test/SubprocessTestParentDeathHelper.cpp +++ b/folly/test/SubprocessTestParentDeathHelper.cpp @@ -23,7 +23,6 @@ // worked as intended. #include -#include #include #include diff --git a/folly/test/ThreadLocalTestLib.cpp b/folly/test/ThreadLocalTestLib.cpp index d61137ac..6161d4f4 100644 --- a/folly/test/ThreadLocalTestLib.cpp +++ b/folly/test/ThreadLocalTestLib.cpp @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include #include -- 2.34.1