This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

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.

Diff Detail

Event Timeline

thakis created this revision.Apr 27 2021, 9:34 AM
thakis requested review of this revision.Apr 27 2021, 9:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2021, 9:34 AM
aeubanks accepted this revision.Apr 27 2021, 9:40 AM
aeubanks added a subscriber: aeubanks.

lgtm

This revision is now accepted and ready to land.Apr 27 2021, 9:40 AM
This revision was landed with ongoing or failed builds.Apr 27 2021, 9:41 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2021, 9:41 AM

A drive-by look.

clang/include/clang/Tooling/Transformer/Parsing.h
24

<functional> appears unnecessary as well.

And while this doesn't require <string> it does require llvm/ADT/StringRef.h.

llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
72

size_t may have been coming indirectly from <memory>.