HomePhabricator

[backport#10574] Remove includes in .cpp files for things the corresponding .h…

Description

[backport#10574] Remove includes in .cpp files for things the corresponding .h file already included

Summary:
Remove includes in .cpp files for things the corresponding .h file
already included.

Example case:

addrdb.cpp includes addrdb.h and fs.h
addrdb.h includes fs.h
Then remove the direct inclusion of fs.h in addrman.cpp and rely on the
indirect inclusion of fs.h via the included addrdb.h.

In line with the header include guideline (see #10575).

Candidates for removal found by:

#!/bin/bash

for H in $(git grep "" -- "*.h" | cut -f1 -d: | uniq); do
    CPP=${H/%\.h/.cpp}
    if [[ ! -e $CPP ]]; then
        continue
    fi
    cat "$H" "$CPP" | grep -E "^#include " | sort | uniq -c | \
      grep " 2 #include" && echo "$CPP" && echo
done

Backport of Core PR10574

Test Plan:

ninja check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6666

Details

Provenance
majcostaAuthored on Jun 22 2020, 11:43
majcostaPushed on Jun 23 2020, 18:29
Reviewer
Restricted Project
Differential Revision
D6666: [backport#10574] Remove includes in .cpp files for things the corresponding .h file already included
Parents
rABCc55ecd0094c1: [CI] Remove duplicated `cd` to the build dir with build-make-generator
Branches
Unknown
Tags
Unknown