Page MenuHomePhabricator

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

Authored by majcosta on Jun 22 2020, 11:46.

Details

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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

This revision is now accepted and ready to land.Jun 22 2020, 21:42