[clang] [clang] Remove unused includes (NFC) (PR #246950)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 02:02:16 PST 2026
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/246950
This patch removes unused #include directives across .cpp files under
clang/lib/. Identified by clang-include-cleaner and verified
locally.
Assisted-by: Antigravity
>From e091a2163170a0439d411c609fd6ba1481b38e07 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 28 Nov 2026 14:54:06 -0800
Subject: [PATCH] [clang] Remove unused includes (NFC)
This patch removes unused #include directives across .cpp files under
clang/lib/. Identified by clang-include-cleaner and verified
locally.
Assisted-by: Antigravity
---
clang/lib/Basic/Diagnostic.cpp | 1 -
clang/lib/Basic/FileManager.cpp | 2 --
clang/lib/Basic/OffloadArch.cpp | 1 -
clang/lib/Basic/ParsedAttrInfo.cpp | 1 -
clang/lib/Basic/SourceManager.cpp | 2 --
clang/lib/Basic/TargetInfo.cpp | 1 -
clang/lib/Basic/Targets/M68k.cpp | 2 --
clang/lib/Basic/Warnings.cpp | 2 --
clang/lib/CodeGen/CGExprScalar.cpp | 1 -
clang/lib/CodeGen/CGHLSLRuntime.cpp | 1 -
clang/lib/CodeGen/CGObjCMac.cpp | 1 -
clang/lib/CodeGen/CodeGenFunction.cpp | 2 --
clang/lib/CodeGen/CodeGenModule.cpp | 1 -
clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp | 1 -
clang/lib/CodeGen/Targets/PPC.cpp | 1 -
clang/lib/Driver/OffloadBundler.cpp | 2 --
clang/lib/Driver/SanitizerArgs.cpp | 2 --
clang/lib/Driver/ToolChain.cpp | 1 -
clang/lib/Driver/ToolChains/Arch/CSKY.cpp | 1 -
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp | 1 -
clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 1 -
clang/lib/Driver/ToolChains/BareMetal.cpp | 1 -
clang/lib/Driver/ToolChains/Cuda.cpp | 1 -
clang/lib/Driver/ToolChains/Gnu.cpp | 1 -
clang/lib/Driver/ToolChains/Hexagon.cpp | 1 -
25 files changed, 32 deletions(-)
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index 865d4ec3b1e35..379066e038fa3 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -26,7 +26,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/CrashRecoveryContext.h"
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index fe80ffbebd2bf..04679b17d2240 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -28,9 +28,7 @@
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
-#include <climits>
#include <cstdint>
-#include <cstdlib>
#include <optional>
#include <string>
#include <utility>
diff --git a/clang/lib/Basic/OffloadArch.cpp b/clang/lib/Basic/OffloadArch.cpp
index b95ab8a6119f2..dd4b930950bd5 100644
--- a/clang/lib/Basic/OffloadArch.cpp
+++ b/clang/lib/Basic/OffloadArch.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/OffloadArch.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/TargetParser/AMDGPUTargetParser.h"
#include "llvm/TargetParser/IntelGPUTargetParser.h"
diff --git a/clang/lib/Basic/ParsedAttrInfo.cpp b/clang/lib/Basic/ParsedAttrInfo.cpp
index 4c82fad98478f..dd4b86e176c56 100644
--- a/clang/lib/Basic/ParsedAttrInfo.cpp
+++ b/clang/lib/Basic/ParsedAttrInfo.cpp
@@ -13,7 +13,6 @@
#include "clang/Basic/ParsedAttrInfo.h"
#include "clang/Support/Compiler.h"
-#include "llvm/Support/ManagedStatic.h"
#include <list>
#include <memory>
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 7c7ae664edc89..8427476fe8104 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -30,7 +30,6 @@
#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -39,7 +38,6 @@
#include <cstdint>
#include <memory>
#include <optional>
-#include <string>
#include <tuple>
#include <utility>
#include <vector>
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 6e390226d2e4b..758cd3f02a137 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -21,7 +21,6 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/TargetParser/TargetParser.h"
#include "llvm/TargetParser/Triple.h"
#include <cstdlib>
using namespace clang;
diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp
index a174633c21803..7cadfd01fc5a3 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -15,9 +15,7 @@
#include "clang/Basic/Diagnostic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
-#include "llvm/TargetParser/TargetParser.h"
#include <cstdint>
-#include <cstring>
#include <limits>
#include <optional>
diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp
index 18e6274f53267..6fdb6bff52de9 100644
--- a/clang/lib/Basic/Warnings.cpp
+++ b/clang/lib/Basic/Warnings.cpp
@@ -30,8 +30,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/VirtualFileSystem.h"
-#include "llvm/Support/raw_ostream.h"
-#include <cstring>
using namespace clang;
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 4ced42154b6a2..8b024804fc3bb 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -54,7 +54,6 @@
#include "llvm/IR/MatrixBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/TypeSize.h"
-#include <cstdarg>
#include <optional>
using namespace clang;
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 8540f98bc7d05..a47814141d7c4 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -34,7 +34,6 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Enum.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 7bfe0e0249407..c9c5767e14a9f 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -41,7 +41,6 @@
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdio>
-#include <numeric>
using namespace clang;
using namespace CodeGen;
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index d9c886259e4cf..4b5cbd04abdf1 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -33,7 +33,6 @@
#include "clang/Basic/Builtins.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/DiagnosticFrontend.h"
-#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "clang/CodeGenUtils/FunctionUtils.h"
@@ -47,7 +46,6 @@
#include "llvm/IR/Instruction.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
-#include "llvm/IR/IntrinsicsPowerPC.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/Support/CRC.h"
#include "llvm/Support/SaveAndRestore.h"
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index accf1bd42666a..24f0249f0973a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -81,7 +81,6 @@
#include "llvm/TargetParser/RISCVISAInfo.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/TargetParser/X86TargetParser.h"
-#include "llvm/Transforms/Instrumentation/KCFI.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include "llvm/Transforms/Utils/KCFIHash.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
diff --git a/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp b/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
index e55de8b0692e2..ce5f4cfbde1e5 100644
--- a/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
@@ -11,7 +11,6 @@
#include "CodeGenModule.h"
#include "TargetInfo.h"
#include "clang/AST/Type.h"
-#include <climits>
//===----------------------------------------------------------------------===//
// Implementation of constant buffer layout common between DirectX and
diff --git a/clang/lib/CodeGen/Targets/PPC.cpp b/clang/lib/CodeGen/Targets/PPC.cpp
index de296680ce6af..95c0672255959 100644
--- a/clang/lib/CodeGen/Targets/PPC.cpp
+++ b/clang/lib/CodeGen/Targets/PPC.cpp
@@ -9,7 +9,6 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
#include "clang/Basic/DiagnosticFrontend.h"
-#include "llvm/Support/CodeGen.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp
index 38981e27150c0..43aef78aaf162 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -39,7 +39,6 @@
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MD5.h"
-#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
@@ -50,7 +49,6 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
-#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 5df712cb9578d..3f3d6a525d06e 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -17,8 +17,6 @@
#include "llvm/Support/SpecialCaseList.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/AArch64TargetParser.h"
-#include "llvm/TargetParser/RISCVTargetParser.h"
-#include "llvm/TargetParser/TargetParser.h"
#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
#include <memory>
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index aaa1e6b87fa8f..1f0195f148d43 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -48,7 +48,6 @@
#include "llvm/TargetParser/AArch64TargetParser.h"
#include "llvm/TargetParser/AMDGPUTargetParser.h"
#include "llvm/TargetParser/RISCVISAInfo.h"
-#include "llvm/TargetParser/TargetParser.h"
#include "llvm/TargetParser/Triple.h"
#include <cassert>
#include <cstddef>
diff --git a/clang/lib/Driver/ToolChains/Arch/CSKY.cpp b/clang/lib/Driver/ToolChains/Arch/CSKY.cpp
index 65f6534e4d038..d9564e9bc97bc 100644
--- a/clang/lib/Driver/ToolChains/Arch/CSKY.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/CSKY.cpp
@@ -13,7 +13,6 @@
#include "llvm/Option/ArgList.h"
#include "llvm/TargetParser/CSKYTargetParser.h"
#include "llvm/TargetParser/Host.h"
-#include "llvm/TargetParser/TargetParser.h"
using namespace clang::driver;
using namespace clang::driver::tools;
diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index e6a0e35511a3d..9624789ded8ca 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "LoongArch.h"
-#include "../Clang.h"
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index db21c46d7f6f1..473a59dcd6363 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "RISCV.h"
-#include "../Clang.h"
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 621b448190dd5..5f8b47cc87f17 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -19,7 +19,6 @@
#include "clang/Driver/Driver.h"
#include "clang/Driver/MultilibBuilder.h"
#include "clang/Options/Options.h"
-#include "llvm/ADT/StringExtras.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index 57470c18db393..3082c3ac11e93 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -25,7 +25,6 @@
#include "llvm/Support/Program.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/Host.h"
-#include "llvm/TargetParser/TargetParser.h"
#include <system_error>
using namespace clang::driver;
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 90fc71c147364..a5a429db09d1f 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -30,7 +30,6 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/RISCVISAInfo.h"
-#include "llvm/TargetParser/TargetParser.h"
#include <system_error>
using namespace clang::driver;
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index e50247a9a0d5e..b8571f57f5b23 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -16,7 +16,6 @@
#include "clang/Options/Options.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Option/ArgList.h"
-#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
More information about the cfe-commits
mailing list