HomePhabricator

[llvm, clang] Remove stdlib includes from .h files without `std::`

Authored by thakis on Apr 27 2021, 9:31 AM.

Description

[llvm, clang] Remove stdlib includes from .h files without std::

Found files not containing std:: with:

INCL="algorithm|array|list|map|memory|queue|set|string|utility|vector|unordered_map|unordered_set"
git ls-files llvm/include/llvm | grep '\.h$' | xargs grep -L std:: | \
    xargs grep -El "#include <($INCL)>$" > to_process.txt
git ls-files clang/include/clang | grep '\.h$' | xargs grep -L std:: | \
    xargs grep -El "#include <($INCL)>$" >> to_process.txt

Then removed these headers from those files with

INCL_ESCAPED="$(echo $INCL|sed 's/|/\\|/g')"
cat to_process.txt | xargs sed -i "/^#include <\($INCL_ESCAPED\)>$/d"
cat to_process.txt | xargs sed -i '/^$/N;/^\n$/D'

No behavior change.

Differential Revision: https://reviews.llvm.org/D101378

Details