Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions contrib/devtools/lint-includes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ for HEADER_FILE in $(filter_suffix h); do
echo
EXIT_CODE=1
fi
CPP_FILE=${HEADER_FILE/%\.h/.cpp}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible followup (for a future pr) could be merge h/cpp loops since the files are treated the same now.

if [[ ! -e $CPP_FILE ]]; then
continue
fi
DUPLICATE_INCLUDES_IN_HEADER_AND_CPP_FILES=$(grep -hE "^#include " <(sort -u < "${HEADER_FILE}") <(sort -u < "${CPP_FILE}") | grep -E "^#include " | sort | uniq -d)

@practicalswift practicalswift Apr 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't extend the scope beyond what is needed for your suggested policy change. No need to touch anything beyond DUPLICATE_INCLUDES_IN_HEADER_AND_CPP_FILES if we're switching to a new policy.

if [[ ${DUPLICATE_INCLUDES_IN_HEADER_AND_CPP_FILES} != "" ]]; then
echo "Include(s) from ${HEADER_FILE} duplicated in ${CPP_FILE}:"
echo "${DUPLICATE_INCLUDES_IN_HEADER_AND_CPP_FILES}"
echo
EXIT_CODE=1
fi
done
for CPP_FILE in $(filter_suffix cpp); do
DUPLICATE_INCLUDES_IN_CPP_FILE=$(grep -E "^#include " < "${CPP_FILE}" | sort | uniq -d)
Expand Down
3 changes: 1 addition & 2 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ Source code organization
- *Rationale*: Shorter and simpler header files are easier to read, and reduce compile time

- Every `.cpp` and `.h` file should `#include` every header file it directly uses classes, functions or other
definitions from, even if those headers are already included indirectly through other headers. One exception
is that a `.cpp` file does not need to re-include the includes already included in its corresponding `.h` file.
definitions from, even if those headers are already included indirectly through other headers.

- *Rationale*: Excluding headers because they are already indirectly included results in compilation
failures when those indirect dependencies change. Furthermore, it obscures what the real code
Expand Down