IWYU: Don't filter for already-included header files.

The Google C++ style guide says that when both use a declaration, both
the .h file and the .cc file should include the relevant header.

Bug: webrtc:12057
Change-Id: I4c01ce8930d73418cb23c7fe1bb7bcd12c1e2568
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/189541
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32435}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index e34a5be..7123b7b 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -13,6 +13,7 @@
 #include <limits.h>
 #include <stddef.h>
 #include <algorithm>
+#include <utility>
 
 #include "absl/algorithm/container.h"
 #include "absl/strings/match.h"
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc
index 29fdf3a..d7863d7 100644
--- a/pc/sdp_offer_answer.cc
+++ b/pc/sdp_offer_answer.cc
@@ -12,6 +12,7 @@
 
 #include <algorithm>
 #include <iterator>
+#include <map>
 #include <queue>
 #include <type_traits>
 
@@ -42,8 +43,11 @@
 #include "pc/peer_connection_message_handler.h"
 #include "pc/rtp_data_channel.h"
 #include "pc/rtp_media_utils.h"
+#include "pc/rtp_sender.h"
 #include "pc/rtp_transport_internal.h"
+#include "pc/sctp_transport.h"
 #include "pc/simulcast_description.h"
+#include "pc/stats_collector.h"
 #include "pc/usage_pattern.h"
 #include "rtc_base/bind.h"
 #include "rtc_base/helpers.h"
diff --git a/tools_webrtc/iwyu/apply-iwyu b/tools_webrtc/iwyu/apply-iwyu
index a043493..65950d3 100755
--- a/tools_webrtc/iwyu/apply-iwyu
+++ b/tools_webrtc/iwyu/apply-iwyu
@@ -11,6 +11,9 @@
 set -e
 set -x
 FILE=$1
+# If you want to exclude files that are in $FILE.h from $FILE.cc, set
+# the following variable to "yes". This is a style guide violation.
+REMOVE_CC_INCLUDES=no
 
 if [ ! -f $FILE.h ]; then
    echo "$FILE.h not found"
@@ -22,11 +25,16 @@
    exit 1
 fi 
 
-iwyu -Xiwyu --no_fwd_decls --no-default-mappings -D__X86_64__  -DWEBRTC_POSIX -I . -I third_party/abseil-cpp $FILE.cc |& fix_include || echo "Some files modified"
+iwyu -Xiwyu --no_fwd_decls -D__X86_64__  -DWEBRTC_POSIX -I . -I third_party/abseil-cpp $FILE.cc |& fix_include || echo "Some files modified"
 
-grep ^#include $FILE.h | grep -v -f - $FILE.cc > $FILE.ccnew
-grep -v -f tools_webrtc/iwyu/iwyu-filter-list $FILE.ccnew > $FILE.cc
-rm $FILE.ccnew
+if [ $REMOVE_CC_INCLUDES == "yes" ]; then
+  grep ^#include $FILE.h | grep -v -f - $FILE.cc > $FILE.ccnew
+  grep -v -f tools_webrtc/iwyu/iwyu-filter-list $FILE.ccnew > $FILE.cc
+  rm $FILE.ccnew
+else
+  grep -v -f tools_webrtc/iwyu/iwyu-filter-list $FILE.cc > $FILE.ccnew
+  mv $FILE.ccnew $FILE.cc
+fi
 grep -v -f tools_webrtc/iwyu/iwyu-filter-list $FILE.h > $FILE.hnew
 mv $FILE.hnew $FILE.h