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

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 27 09:41:53 PDT 2021


Author: Nico Weber
Date: 2021-04-27T12:41:39-04:00
New Revision: 21da04f701735ecd42f1d43b3f58b708ad382905

URL: https://github.com/llvm/llvm-project/commit/21da04f701735ecd42f1d43b3f58b708ad382905
DIFF: https://github.com/llvm/llvm-project/commit/21da04f701735ecd42f1d43b3f58b708ad382905.diff

LOG: [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

Added: 
    

Modified: 
    clang/include/clang/AST/DeclContextInternals.h
    clang/include/clang/Driver/Options.h
    clang/include/clang/Index/CommentToXML.h
    clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
    clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h
    clang/include/clang/Tooling/Transformer/Parsing.h
    llvm/include/llvm/CodeGen/MachineInstrBuilder.h
    llvm/include/llvm/CodeGen/TileShapeInfo.h
    llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
    llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
    llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
    llvm/include/llvm/DebugInfo/GSYM/FileEntry.h
    llvm/include/llvm/DebugInfo/GSYM/StringTable.h
    llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
    llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h
    llvm/include/llvm/Target/CGPassBuilderOption.h
    llvm/include/llvm/Transforms/Scalar/SpeculateAroundPHIs.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/DeclContextInternals.h b/clang/include/clang/AST/DeclContextInternals.h
index 3556044098c46..2eef2343b7500 100644
--- a/clang/include/clang/AST/DeclContextInternals.h
+++ b/clang/include/clang/AST/DeclContextInternals.h
@@ -22,7 +22,6 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
-#include <algorithm>
 #include <cassert>
 
 namespace clang {

diff  --git a/clang/include/clang/Driver/Options.h b/clang/include/clang/Driver/Options.h
index b641f64c31165..056660192ac5f 100644
--- a/clang/include/clang/Driver/Options.h
+++ b/clang/include/clang/Driver/Options.h
@@ -9,8 +9,6 @@
 #ifndef LLVM_CLANG_DRIVER_OPTIONS_H
 #define LLVM_CLANG_DRIVER_OPTIONS_H
 
-#include <memory>
-
 namespace llvm {
 namespace opt {
 class OptTable;

diff  --git a/clang/include/clang/Index/CommentToXML.h b/clang/include/clang/Index/CommentToXML.h
index 66b8650c5efb4..29904f163dc75 100644
--- a/clang/include/clang/Index/CommentToXML.h
+++ b/clang/include/clang/Index/CommentToXML.h
@@ -10,7 +10,6 @@
 #define LLVM_CLANG_INDEX_COMMENTTOXML_H
 
 #include "clang/Basic/LLVM.h"
-#include <memory>
 
 namespace clang {
 class ASTContext;

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
index 2679339537e89..ffe1fe846be1c 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
@@ -24,7 +24,6 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
 #include "llvm/ADT/ImmutableMap.h"
 #include "llvm/ADT/Optional.h"
-#include <utility>
 
 namespace clang {
 namespace ento {

diff  --git a/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h b/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h
index 0c6e38af381f0..57dffa945acc9 100644
--- a/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h
+++ b/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h
@@ -12,7 +12,6 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
-#include <vector>
 
 namespace clang {
 namespace tooling {

diff  --git a/clang/include/clang/Tooling/Transformer/Parsing.h b/clang/include/clang/Tooling/Transformer/Parsing.h
index 8e51f595cd5b1..b143f63d8ca89 100644
--- a/clang/include/clang/Tooling/Transformer/Parsing.h
+++ b/clang/include/clang/Tooling/Transformer/Parsing.h
@@ -21,7 +21,6 @@
 #include "clang/Tooling/Transformer/RangeSelector.h"
 #include "llvm/Support/Error.h"
 #include <functional>
-#include <string>
 
 namespace clang {
 namespace transformer {

diff  --git a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
index 5a6f688a1e57d..80f30231aef2f 100644
--- a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -31,7 +31,6 @@
 #include "llvm/Support/ErrorHandling.h"
 #include <cassert>
 #include <cstdint>
-#include <utility>
 
 namespace llvm {
 

diff  --git a/llvm/include/llvm/CodeGen/TileShapeInfo.h b/llvm/include/llvm/CodeGen/TileShapeInfo.h
index 031d23555b7e5..4e574bd96cca4 100644
--- a/llvm/include/llvm/CodeGen/TileShapeInfo.h
+++ b/llvm/include/llvm/CodeGen/TileShapeInfo.h
@@ -24,7 +24,6 @@
 #include "llvm/CodeGen/MachineOperand.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/Register.h"
-#include <utility>
 
 namespace llvm {
 

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
index 55b953561540a..5a91682e9bd4e 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
@@ -17,7 +17,6 @@
 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
 #include "llvm/Support/Allocator.h"
 #include <cstdint>
-#include <memory>
 
 namespace llvm {
 namespace codeview {

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
index 9d791403ebd6d..465c26ec2ce6a 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
@@ -20,7 +20,6 @@
 #include "llvm/Support/Allocator.h"
 #include <cassert>
 #include <cstdint>
-#include <memory>
 
 namespace llvm {
 namespace codeview {

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
index 40ac25c3b29d8..0f9d5e476075e 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
@@ -19,7 +19,6 @@
 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
 #include "llvm/Support/Allocator.h"
 #include <cstdint>
-#include <memory>
 
 namespace llvm {
 namespace codeview {

diff  --git a/llvm/include/llvm/DebugInfo/GSYM/FileEntry.h b/llvm/include/llvm/DebugInfo/GSYM/FileEntry.h
index 538f6760841c9..8e00c5f01c8e8 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/FileEntry.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/FileEntry.h
@@ -13,7 +13,6 @@
 #include "llvm/ADT/Hashing.h"
 #include <functional>
 #include <stdint.h>
-#include <utility>
 
 namespace llvm {
 namespace gsym {

diff  --git a/llvm/include/llvm/DebugInfo/GSYM/StringTable.h b/llvm/include/llvm/DebugInfo/GSYM/StringTable.h
index 3c0c65482e8cd..f7f800d01647d 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/StringTable.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/StringTable.h
@@ -13,8 +13,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/DebugInfo/GSYM/Range.h"
 #include <stdint.h>
-#include <string>
-
 
 namespace llvm {
 namespace gsym {

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h b/llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
index 5061c15cf4c96..82dfdc2701287 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
@@ -21,7 +21,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MathExtras.h"
-#include <algorithm>
 #include <cstdint>
 
 namespace llvm {

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h
index 811c50e3ce4da..14d30c4aa345c 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h
@@ -16,7 +16,6 @@
 
 #include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
 #include "llvm/Support/Error.h"
-#include <vector>
 
 namespace llvm {
 namespace orc {

diff  --git a/llvm/include/llvm/Target/CGPassBuilderOption.h b/llvm/include/llvm/Target/CGPassBuilderOption.h
index 09001d704f92f..11b904e6e7fe0 100644
--- a/llvm/include/llvm/Target/CGPassBuilderOption.h
+++ b/llvm/include/llvm/Target/CGPassBuilderOption.h
@@ -17,7 +17,6 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Target/TargetOptions.h"
-#include <vector>
 
 namespace llvm {
 class TargetMachine;

diff  --git a/llvm/include/llvm/Transforms/Scalar/SpeculateAroundPHIs.h b/llvm/include/llvm/Transforms/Scalar/SpeculateAroundPHIs.h
index 3c7dafe71e8e1..2104daff44abe 100644
--- a/llvm/include/llvm/Transforms/Scalar/SpeculateAroundPHIs.h
+++ b/llvm/include/llvm/Transforms/Scalar/SpeculateAroundPHIs.h
@@ -15,7 +15,6 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Compiler.h"
-#include <vector>
 
 namespace llvm {
 


        


More information about the cfe-commits mailing list