https://github.com/chandlerc updated https://github.com/llvm/llvm-project/pull/216946
>From e7a12fe28165a37c2ea5ba22df717f652e533d4b Mon Sep 17 00:00:00 2001 From: Chandler Carruth <[email protected]> Date: Mon, 17 Aug 2026 10:19:00 -0700 Subject: [PATCH 1/3] [clang] Trim large(-ish) includes from common headers Several widely included Clang headers pull in whole subsystems to name types they only use through pointers, references, or declarations. Because these headers sit underneath SourceManager.h, Sema.h, and CompilerInstance.h, nearly every translation unit in Clang pays for them, as well as many down-stream users of Clang. Translation units across Clang and clang-tools-extra that were relying on any of the removed transitive includes now include what they use. Out-of-tree code that was relying on any of these transitive includes needs the same treatment. The failure is an incomplete type or an undeclared identifier at the point of use, and the fix is to include the header that declares it; llvm/Support/VirtualFileSystem.h and AST/Attr.h account for most of it, since Basic/FileManager.h and AST/GlobalDecl.h are reached from so much of Clang. Measured on a random 90 translation unit sample of clang's 1006 library translation units, compiling each directly: 280.0s drops to 267.2s of compiler CPU time, a 4.6% reduction. In isolation, Basic/SourceManager.h drops from 1.11s to 0.85s and Lex/Preprocessor.h from 1.56s to 1.33s. Assisted-by: Claude Code --- clang-tools-extra/clang-tidy/ClangTidy.cpp | 1 + .../utils/FormatStringConverter.cpp | 1 + clang-tools-extra/clangd/FindSymbols.cpp | 1 + clang-tools-extra/clangd/ParsedAST.cpp | 1 + clang-tools-extra/clangd/ParsedAST.h | 1 + clang-tools-extra/clangd/Preamble.h | 1 + .../clangd/unittests/ASTTests.cpp | 1 + .../clangd/unittests/ExpectedTypeTest.cpp | 1 + .../clangd/unittests/FindTargetTests.cpp | 1 + .../clangd/unittests/InsertionPointTests.cpp | 1 + .../include-cleaner/lib/FindHeaders.cpp | 1 + .../include-cleaner/lib/HTMLReport.cpp | 1 + .../include-cleaner/lib/IncludeSpeller.cpp | 1 + .../include-cleaner/unittests/RecordTest.cpp | 1 + clang/include/clang/AST/ExprObjC.h | 1 - clang/include/clang/AST/GlobalDecl.h | 60 +++++++++++-------- .../LifetimeSafety/LifetimeAnnotations.h | 7 ++- clang/include/clang/Basic/FileManager.h | 29 +++++---- clang/include/clang/Basic/TargetInfo.h | 15 +---- clang/include/clang/Driver/Driver.h | 1 + clang/include/clang/Frontend/ASTUnit.h | 1 + .../include/clang/Frontend/CompilerInstance.h | 5 +- .../clang/Frontend/CompilerInvocation.h | 2 +- clang/include/clang/Frontend/FrontendAction.h | 21 ++----- clang/include/clang/Sema/Sema.h | 1 - clang/lib/AST/CMakeLists.txt | 1 + clang/lib/AST/Decl.cpp | 1 + clang/lib/AST/GlobalDecl.cpp | 46 ++++++++++++++ .../lib/Analysis/FlowSensitive/HTMLLogger.cpp | 1 + clang/lib/Basic/FileManager.cpp | 14 +++++ clang/lib/Basic/SourceManager.cpp | 1 + clang/lib/Basic/TargetInfo.cpp | 15 +++++ clang/lib/Basic/Targets/RISCV.h | 1 + clang/lib/Basic/Targets/X86.h | 1 + clang/lib/CIR/CodeGen/CIRGenerator.cpp | 1 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 1 + clang/lib/CodeGen/CGOpenMPRuntime.cpp | 1 + clang/lib/CodeGen/CGPointerAuth.cpp | 1 + clang/lib/CodeGen/CodeGenFunction.h | 1 + clang/lib/CodeGen/CodeGenModule.cpp | 1 + clang/lib/CrossTU/CrossTranslationUnit.cpp | 1 + clang/lib/Format/Format.cpp | 2 + clang/lib/Frontend/CompilerInstance.cpp | 5 ++ clang/lib/Frontend/FrontendAction.cpp | 19 ++++++ clang/lib/Frontend/FrontendActions.cpp | 1 + .../InterfaceStubFunctionsConsumer.cpp | 1 + .../Frontend/Rewrite/InclusionRewriter.cpp | 1 + clang/lib/Frontend/TextDiagnostic.cpp | 1 + .../ExecuteCompilerInvocation.cpp | 1 + clang/lib/Index/IndexingAction.cpp | 1 + clang/lib/InstallAPI/DirectoryScanner.cpp | 1 + clang/lib/InstallAPI/Frontend.cpp | 1 + clang/lib/InstallAPI/HeaderFile.cpp | 1 + clang/lib/Interpreter/IncrementalAction.h | 1 + clang/lib/Lex/PPLexerChange.cpp | 1 + .../SourceTransformationFrontendAction.cpp | 1 + .../TUSummaryExtractorFrontendAction.cpp | 1 + clang/lib/Sema/SemaCodeComplete.cpp | 2 + clang/lib/Sema/SemaExpr.cpp | 1 + clang/lib/Serialization/ASTReader.cpp | 2 + clang/lib/Serialization/ASTWriter.cpp | 2 + .../StaticAnalyzer/Core/PlistDiagnostics.cpp | 1 + .../StaticAnalyzer/Core/SarifDiagnostics.cpp | 2 + .../StaticAnalyzer/Frontend/ModelInjector.cpp | 1 + clang/lib/Testing/TestAST.cpp | 1 + clang/lib/Tooling/Syntax/Tokens.cpp | 1 + clang/tools/clang-format/ClangFormat.cpp | 1 + clang/tools/clang-installapi/Options.cpp | 1 + .../Analysis/MacroExpansionContextTest.cpp | 1 + .../CrossTU/CrossTranslationUnitTest.cpp | 1 + .../Frontend/CompilerInstanceTest.cpp | 2 + .../Frontend/CompilerInvocationTest.cpp | 1 + clang/unittests/Lex/HeaderSearchTest.cpp | 1 + .../Lex/NoTrivialPPDirectiveTracerTest.cpp | 1 + clang/unittests/Lex/PPCallbacksTest.cpp | 1 + .../Lex/PPDependencyDirectivesTest.cpp | 1 + clang/unittests/Tooling/ASTSelectionTest.cpp | 1 + clang/unittests/Tooling/RewriterTestContext.h | 1 + .../unittests/Tooling/Syntax/TreeTestBase.cpp | 1 + clang/unittests/Tooling/Syntax/TreeTestBase.h | 1 + 80 files changed, 237 insertions(+), 75 deletions(-) create mode 100644 clang/lib/AST/GlobalDecl.cpp diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index 8135826ef660d..d065bb2c4bcfc 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -42,6 +42,7 @@ #if CLANG_TIDY_ENABLE_STATIC_ANALYZER #include "clang/Analysis/PathDiagnostic.h" +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h" #endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER diff --git a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp index 98709e924a7a1..a710c6ab728c2 100644 --- a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp +++ b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp @@ -23,6 +23,7 @@ #include "clang/Tooling/FixIt.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Path.h" using namespace clang::ast_matchers; using namespace clang::analyze_printf; diff --git a/clang-tools-extra/clangd/FindSymbols.cpp b/clang-tools-extra/clangd/FindSymbols.cpp index eeb6a56023b11..7e3067cf41464 100644 --- a/clang-tools-extra/clangd/FindSymbols.cpp +++ b/clang-tools-extra/clangd/FindSymbols.cpp @@ -26,6 +26,7 @@ #include "llvm/ADT/StringRef.h" #include <limits> #include <optional> +#include "clang/AST/Attr.h" #define DEBUG_TYPE "FindSymbols" diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp index df56420cd7f24..164ab02abfba7 100644 --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -80,6 +80,7 @@ #if CLANGD_TIDY_CHECKS #define CLANG_TIDY_DISABLE_STATIC_ANALYZER_CHECKS #include "../clang-tidy/ClangTidyForceLinker.h" +#include "clang/Lex/PreprocessingRecord.h" #endif namespace clang { diff --git a/clang-tools-extra/clangd/ParsedAST.h b/clang-tools-extra/clangd/ParsedAST.h index 6640ccccf5815..03b1ad836a34c 100644 --- a/clang-tools-extra/clangd/ParsedAST.h +++ b/clang-tools-extra/clangd/ParsedAST.h @@ -36,6 +36,7 @@ #include <optional> #include <string> #include <vector> +#include "clang/AST/DeclCXX.h" namespace clang { class HeuristicResolver; diff --git a/clang-tools-extra/clangd/Preamble.h b/clang-tools-extra/clangd/Preamble.h index 8a5edf1fee1af..44f20901caad3 100644 --- a/clang-tools-extra/clangd/Preamble.h +++ b/clang-tools-extra/clangd/Preamble.h @@ -47,6 +47,7 @@ #include <string> #include <utility> #include <vector> +#include "clang/AST/ASTContext.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/clangd/unittests/ASTTests.cpp b/clang-tools-extra/clangd/unittests/ASTTests.cpp index 91ae727d8c944..323a89a25e495 100644 --- a/clang-tools-extra/clangd/unittests/ASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/ASTTests.cpp @@ -25,6 +25,7 @@ #include <cstddef> #include <string> #include <vector> +#include "clang/AST/DeclTemplate.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp b/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp index afefa245f03e7..9ba18688066e6 100644 --- a/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp +++ b/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp @@ -15,6 +15,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include <optional> +#include "clang/Sema/CodeCompleteConsumer.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp index d8c903cfcafeb..89c39b010922b 100644 --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -19,6 +19,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include <initializer_list> +#include "clang/AST/DeclObjC.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp b/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp index 3d5365a099f0a..d0b60e7434513 100644 --- a/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp +++ b/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp @@ -16,6 +16,7 @@ #include "llvm/Testing/Support/Error.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "clang/AST/DeclObjC.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp index b96d9a70728c2..1b00f7cf6a474 100644 --- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp +++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp @@ -30,6 +30,7 @@ #include <queue> #include <set> #include <utility> +#include "llvm/Support/Path.h" namespace clang::include_cleaner { namespace { diff --git a/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp b/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp index 5b24008c1b08d..c056752fba95f 100644 --- a/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp +++ b/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp @@ -26,6 +26,7 @@ #include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/raw_ostream.h" #include <numeric> +#include "llvm/Support/Path.h" namespace clang::include_cleaner { namespace { diff --git a/clang-tools-extra/include-cleaner/lib/IncludeSpeller.cpp b/clang-tools-extra/include-cleaner/lib/IncludeSpeller.cpp index d0549825d4c40..0b4a92b485248 100644 --- a/clang-tools-extra/include-cleaner/lib/IncludeSpeller.cpp +++ b/clang-tools-extra/include-cleaner/lib/IncludeSpeller.cpp @@ -14,6 +14,7 @@ #include "llvm/Support/Registry.h" #include <memory> #include <string> +#include "llvm/Support/VirtualFileSystem.h" LLVM_INSTANTIATE_REGISTRY(clang::include_cleaner::IncludeSpellingStrategy) diff --git a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp index cbf7bae23b365..c7abb4f23d838 100644 --- a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp @@ -36,6 +36,7 @@ #include <memory> #include <optional> #include <utility> +#include "clang/Lex/Preprocessor.h" namespace clang::include_cleaner { namespace { diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h index 7f7b556f14329..b424530c8447c 100644 --- a/clang/include/clang/AST/ExprObjC.h +++ b/clang/include/clang/AST/ExprObjC.h @@ -13,7 +13,6 @@ #ifndef LLVM_CLANG_AST_EXPROBJC_H #define LLVM_CLANG_AST_EXPROBJC_H -#include "clang/AST/Attr.h" #include "clang/AST/ComputeDependence.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclObjC.h" diff --git a/clang/include/clang/AST/GlobalDecl.h b/clang/include/clang/AST/GlobalDecl.h index 0f9ff9496ff88..c6a7c6431a762 100644 --- a/clang/include/clang/AST/GlobalDecl.h +++ b/clang/include/clang/AST/GlobalDecl.h @@ -14,14 +14,11 @@ #ifndef LLVM_CLANG_AST_GLOBALDECL_H #define LLVM_CLANG_AST_GLOBALDECL_H -#include "clang/AST/Attr.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" -#include "clang/AST/DeclOpenACC.h" -#include "clang/AST/DeclOpenMP.h" -#include "clang/AST/DeclTemplate.h" #include "clang/Basic/ABI.h" #include "clang/Basic/LLVM.h" +#include "clang/Support/Compiler.h" #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/Support/Casting.h" @@ -30,6 +27,12 @@ namespace clang { +class FunctionTemplateDecl; +class OMPDeclareMapperDecl; +class OMPDeclareReductionDecl; +class OpenACCDeclareDecl; +class OpenACCRoutineDecl; + enum class DynamicInitKind : unsigned { NoStub = 0, Initializer, @@ -58,10 +61,23 @@ class GlobalDecl { llvm::PointerIntPair<const Decl *, 3> Value; unsigned MultiVersionIndex = 0; + /// Whether \p D carries the CUDA `__global__` attribute. + /// + /// Defined out of line so that this header does not have to include the + /// generated attribute class definitions for assertions alone. + CLANG_ABI static bool hasCUDAGlobalAttr(const Decl *D); + + /// Whether \p D is a kernel that is referred to through an explicit + /// KernelReferenceKind, either directly or as a function template. + /// + /// Defined out of line so that this header does not have to include the + /// template declaration hierarchy for assertions alone. + CLANG_ABI static bool isKernelReference(const Decl *D); + void Init(const Decl *D) { assert(!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!"); assert(!isa<CXXDestructorDecl>(D) && "Use other ctor with dtor decls!"); - assert(!D->hasAttr<CUDAGlobalAttr>() && "Use other ctor with GPU kernels!"); + assert(!hasCUDAGlobalAttr(D) && "Use other ctor with GPU kernels!"); Value.setPointer(D); } @@ -85,10 +101,12 @@ class GlobalDecl { GlobalDecl(const BlockDecl *D) { Init(D); } GlobalDecl(const CapturedDecl *D) { Init(D); } GlobalDecl(const ObjCMethodDecl *D) { Init(D); } - GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); } - GlobalDecl(const OMPDeclareMapperDecl *D) { Init(D); } - GlobalDecl(const OpenACCRoutineDecl *D) { Init(D); } - GlobalDecl(const OpenACCDeclareDecl *D) { Init(D); } + // Defined out of line so that this header does not have to pull in the + // OpenMP and OpenACC declaration hierarchies for these rare cases. + GlobalDecl(const OMPDeclareReductionDecl *D); + GlobalDecl(const OMPDeclareMapperDecl *D); + GlobalDecl(const OpenACCRoutineDecl *D); + GlobalDecl(const OpenACCDeclareDecl *D); GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) : Value(D, Type) {} GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {} GlobalDecl(const VarDecl *D, DynamicInitKind StubKind) @@ -123,9 +141,7 @@ class GlobalDecl { } unsigned getMultiVersionIndex() const { - assert(isa<FunctionDecl>( - getDecl()) && - !cast<FunctionDecl>(getDecl())->hasAttr<CUDAGlobalAttr>() && + assert(isa<FunctionDecl>(getDecl()) && !hasCUDAGlobalAttr(getDecl()) && !isa<CXXConstructorDecl>(getDecl()) && !isa<CXXDestructorDecl>(getDecl()) && "Decl is not a plain FunctionDecl!"); @@ -133,13 +149,7 @@ class GlobalDecl { } KernelReferenceKind getKernelReferenceKind() const { - assert(((isa<FunctionDecl>(getDecl()) && - cast<FunctionDecl>(getDecl())->isReferenceableKernel()) || - (isa<FunctionTemplateDecl>(getDecl()) && - cast<FunctionTemplateDecl>(getDecl()) - ->getTemplatedDecl() - ->hasAttr<CUDAGlobalAttr>())) && - "Decl is not a GPU kernel!"); + assert(isKernelReference(getDecl()) && "Decl is not a GPU kernel!"); return static_cast<KernelReferenceKind>(Value.getInt()); } @@ -163,11 +173,10 @@ class GlobalDecl { return GD; } - static KernelReferenceKind getDefaultKernelReference(const FunctionDecl *D) { - return (D->hasAttr<DeviceKernelAttr>() || D->getLangOpts().CUDAIsDevice) - ? KernelReferenceKind::Kernel - : KernelReferenceKind::Stub; - } + /// Defined out of line so that this header does not have to include the + /// generated attribute class definitions. + CLANG_ABI static KernelReferenceKind + getDefaultKernelReference(const FunctionDecl *D); GlobalDecl getWithDecl(const Decl *D) { GlobalDecl Result(*this); @@ -190,8 +199,7 @@ class GlobalDecl { } GlobalDecl getWithMultiVersionIndex(unsigned Index) { - assert(isa<FunctionDecl>(getDecl()) && - !cast<FunctionDecl>(getDecl())->hasAttr<CUDAGlobalAttr>() && + assert(isa<FunctionDecl>(getDecl()) && !hasCUDAGlobalAttr(getDecl()) && !isa<CXXConstructorDecl>(getDecl()) && !isa<CXXDestructorDecl>(getDecl()) && "Decl is not a plain FunctionDecl!"); diff --git a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h index 6f1259fa867dc..d0d0d4a103918 100644 --- a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h +++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h @@ -10,13 +10,18 @@ #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMEANNOTATIONS_H #define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMEANNOTATIONS_H -#include "clang/AST/Attr.h" #include "clang/AST/DeclCXX.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallVector.h" #include <optional> +namespace clang { +// Only ever named through a pointer here, so the generated attribute +// class definitions are not needed. +class LifetimeBoundAttr; +} // namespace clang + namespace clang ::lifetimes { // This function is needed because Decl::isInStdNamespace will return false for diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h index f328969b1033a..daded34eb7e01 100644 --- a/clang/include/clang/Basic/FileManager.h +++ b/clang/include/clang/Basic/FileManager.h @@ -25,9 +25,10 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorOr.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/VirtualFileSystem.h" +#include "llvm/Support/FileSystem/UniqueID.h" +#include "llvm/Support/MemoryBuffer.h" #include <ctime> #include <map> #include <memory> @@ -36,7 +37,15 @@ namespace llvm { -class MemoryBuffer; +namespace vfs { +// Only named through pointers, references and IntrusiveRefCntPtr below. +// Including VirtualFileSystem.h here would put <chrono>, and with it libc++'s +// <sstream>/<locale>/<format> machinery, into every translation unit that +// touches SourceManager. +class File; +class FileSystem; +class Status; +} // end namespace vfs } // end namespace llvm @@ -151,7 +160,11 @@ class FileManager : public RefCountedBase<FileManager> { /// \param FS if non-null, the VFS to use. Otherwise uses /// llvm::vfs::getRealFileSystem(). FileManager(const FileSystemOptions &FileSystemOpts, - IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS = nullptr); + IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS); + /// Construct a file manager over the real file system. Kept separate from + /// the constructor above rather than defaulting its argument so that callers + /// do not need llvm::vfs::FileSystem to be complete. + explicit FileManager(const FileSystemOptions &FileSystemOpts); ~FileManager(); /// Returns the number of unique real file entries cached by the file manager. @@ -231,17 +244,13 @@ class FileManager : public RefCountedBase<FileManager> { llvm::vfs::FileSystem &getVirtualFileSystem() const { return *FS; } llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> - getVirtualFileSystemPtr() const { - return FS; - } + getVirtualFileSystemPtr() const; /// Enable or disable tracking of VFS usage. Used to not track full header /// search and implicit modulemap lookup. void trackVFSUsage(bool Active); - void setVirtualFileSystem(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) { - this->FS = std::move(FS); - } + void setVirtualFileSystem(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS); /// Retrieve a file entry for a "virtual" file that acts as /// if there were a file with the given name on disk. diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 6311b6b567a5e..5a541aaf797fe 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -35,7 +35,6 @@ #include "llvm/ADT/StringSet.h" #include "llvm/ADT/StringTable.h" #include "llvm/Frontend/OpenMP/OMPGridValues.h" -#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Error.h" #include "llvm/Support/VersionTuple.h" @@ -699,19 +698,7 @@ class TargetInfo : public TransferrableTargetInfo, // Different targets may support a different maximum width for the _BitInt // type, depending on what operations are supported. - virtual size_t getMaxBitIntWidth() const { - // Consider -fexperimental-max-bitint-width= first. - if (MaxBitIntWidth) - return std::min<size_t>(*MaxBitIntWidth, llvm::IntegerType::MAX_INT_BITS); - - // FIXME: this value should be llvm::IntegerType::MAX_INT_BITS, which is - // maximum bit width that LLVM claims its IR can support. However, most - // backends currently have a bug where they only support float to int - // conversion (and vice versa) on types that are <= 128 bits and crash - // otherwise. We're setting the max supported value to 128 to be - // conservative. - return 128; - } + virtual size_t getMaxBitIntWidth() const; /// Determine whether the target has fast native support for operations /// on half types. diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index eece9ac5293f0..0a21a54993e14 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -33,6 +33,7 @@ #include <set> #include <string> #include <vector> +#include "llvm/Support/VirtualFileSystem.h" namespace llvm { class Triple; diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index b187494e449f2..cbff9980e6906 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -47,6 +47,7 @@ #include <string> #include <utility> #include <vector> +#include "llvm/Support/VirtualFileSystem.h" namespace llvm { diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 24488e053c628..21b83dfefa842 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -558,10 +558,7 @@ class CompilerInstance : public ModuleLoader { return *Context; } - IntrusiveRefCntPtr<ASTContext> getASTContextPtr() const { - assert(Context && "Compiler instance has no AST context!"); - return Context; - } + IntrusiveRefCntPtr<ASTContext> getASTContextPtr() const; void resetAndLeakASTContext() { llvm::BuryPointer(Context.get()); diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h index f71969d515be0..de38029596672 100644 --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -20,7 +20,6 @@ #include "clang/Frontend/FrontendOptions.h" #include "clang/Frontend/MigratorOptions.h" #include "clang/Frontend/PreprocessorOutputOptions.h" -#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/ScopeExit.h" @@ -48,6 +47,7 @@ class FileSystem; namespace clang { +class AnalyzerOptions; class DiagnosticsEngine; class HeaderSearchOptions; class PreprocessorOptions; diff --git a/clang/include/clang/Frontend/FrontendAction.h b/clang/include/clang/Frontend/FrontendAction.h index 08c5fbc78f8ae..6fbe13633c945 100644 --- a/clang/include/clang/Frontend/FrontendAction.h +++ b/clang/include/clang/Frontend/FrontendAction.h @@ -20,7 +20,6 @@ #include "clang/AST/ASTConsumer.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" -#include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendOptions.h" #include "llvm/ADT/StringRef.h" @@ -31,6 +30,7 @@ namespace clang { class ASTMergeAction; +class ASTUnit; class CompilerInstance; /// Abstract base class for actions which can be performed by the frontend. @@ -83,11 +83,7 @@ class FrontendAction { /// /// \return True on success; on failure ExecutionAction() and /// EndSourceFileAction() will not be called. - virtual bool BeginSourceFileAction(CompilerInstance &CI) { - if (CurrentInput.isPreprocessed()) - CI.getPreprocessor().SetMacroExpansionOnlyInDirectives(); - return true; - } + virtual bool BeginSourceFileAction(CompilerInstance &CI); /// Callback to run the program action, using the initialized /// compiler instance. @@ -100,11 +96,7 @@ class FrontendAction { /// /// This is guaranteed to only be called following a successful call to /// BeginSourceFileAction (and BeginSourceFile). - virtual void EndSourceFileAction() { - if (CurrentInput.isPreprocessed()) - // Reset the preprocessor macro expansion to the default. - getCompilerInstance().getPreprocessor().SetEnableMacroExpansion(); - } + virtual void EndSourceFileAction(); /// Callback at the end of processing a single input, to determine /// if the output files should be erased or not. @@ -192,12 +184,7 @@ class FrontendAction { virtual bool usesPreprocessorOnly() const = 0; /// For AST-based actions, the kind of translation unit we're handling. - virtual TranslationUnitKind getTranslationUnitKind() { - // The ASTContext, if exists, knows the exact TUKind of the frondend. - if (Instance && Instance->hasASTContext()) - return Instance->getASTContext().TUKind; - return TU_Complete; - } + virtual TranslationUnitKind getTranslationUnitKind(); /// Does this action support use with PCH? virtual bool hasPCHSupport() const { return true; } diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 3cb0dcbbba83a..0a85cccfba2ec 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -66,7 +66,6 @@ #include "clang/Sema/Scope.h" #include "clang/Sema/SemaBase.h" #include "clang/Sema/SemaConcept.h" -#include "clang/Sema/SemaRISCV.h" #include "clang/Sema/TypoCorrection.h" #include "clang/Sema/Weak.h" #include "llvm/ADT/APInt.h" diff --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt index e3f74d73f21da..9c3c118b22fed 100644 --- a/clang/lib/AST/CMakeLists.txt +++ b/clang/lib/AST/CMakeLists.txt @@ -66,6 +66,7 @@ add_clang_library(clangAST ExternalASTMerger.cpp ExternalASTSource.cpp FormatString.cpp + GlobalDecl.cpp InferAlloc.cpp InheritViz.cpp ByteCode/BitcastBuffer.cpp diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 55f34e27ae535..da7ed96093752 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -62,6 +62,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Triple.h" +#include "llvm/Support/Path.h" #include <algorithm> #include <cassert> #include <cstddef> diff --git a/clang/lib/AST/GlobalDecl.cpp b/clang/lib/AST/GlobalDecl.cpp new file mode 100644 index 0000000000000..72f2848c17a0d --- /dev/null +++ b/clang/lib/AST/GlobalDecl.cpp @@ -0,0 +1,46 @@ +//===--- GlobalDecl.cpp - Global declaration holder -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Out-of-line members of GlobalDecl. GlobalDecl is a small key type that is +// included very widely, so everything here is kept out of the header to spare +// its users the OpenMP and OpenACC declaration hierarchies, the generated +// attribute classes, and the template declaration hierarchy. +// +//===----------------------------------------------------------------------===// + +#include "clang/AST/GlobalDecl.h" +#include "clang/AST/Attr.h" +#include "clang/AST/DeclOpenACC.h" +#include "clang/AST/DeclOpenMP.h" +#include "clang/AST/DeclTemplate.h" + +using namespace clang; + +GlobalDecl::GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); } +GlobalDecl::GlobalDecl(const OMPDeclareMapperDecl *D) { Init(D); } +GlobalDecl::GlobalDecl(const OpenACCRoutineDecl *D) { Init(D); } +GlobalDecl::GlobalDecl(const OpenACCDeclareDecl *D) { Init(D); } + +bool GlobalDecl::hasCUDAGlobalAttr(const Decl *D) { + return D->hasAttr<CUDAGlobalAttr>(); +} + +bool GlobalDecl::isKernelReference(const Decl *D) { + if (const auto *FD = dyn_cast<FunctionDecl>(D)) + return FD->isReferenceableKernel(); + if (const auto *FTD = dyn_cast<FunctionTemplateDecl>(D)) + return FTD->getTemplatedDecl()->hasAttr<CUDAGlobalAttr>(); + return false; +} + +KernelReferenceKind +GlobalDecl::getDefaultKernelReference(const FunctionDecl *D) { + return (D->hasAttr<DeviceKernelAttr>() || D->getLangOpts().CUDAIsDevice) + ? KernelReferenceKind::Kernel + : KernelReferenceKind::Stub; +} diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp index a1469d690a3a8..cf7f289f0a111 100644 --- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp +++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp @@ -66,6 +66,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/JSON.h" +#include "llvm/Support/Path.h" #include "llvm/Support/Program.h" #include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/raw_ostream.h" diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 8fb3ba0a27aad..fe80ffbebd2bf 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -25,6 +25,7 @@ #include "llvm/Support/IOSandbox.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" #include <cassert> #include <climits> @@ -63,6 +64,9 @@ static void normalizeCacheKey(StringRef &Path, // Common logic. //===----------------------------------------------------------------------===// +FileManager::FileManager(const FileSystemOptions &FSO) + : FileManager(FSO, nullptr) {} + FileManager::FileManager(const FileSystemOptions &FSO, IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) : FS(std::move(FS)), FileSystemOpts(FSO), SeenDirEntries(64), @@ -73,6 +77,16 @@ FileManager::FileManager(const FileSystemOptions &FSO, this->FS = llvm::vfs::getRealFileSystem(); } +void FileManager::setVirtualFileSystem( + IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) { + this->FS = std::move(FS); +} + +IntrusiveRefCntPtr<llvm::vfs::FileSystem> +FileManager::getVirtualFileSystemPtr() const { + return FS; +} + FileManager::~FileManager() = default; llvm::ErrorOr<DirectoryEntryRef> diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 5540aade05ef5..136426d302f61 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/AutoConvert.h" #include "llvm/Support/Capacity.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index 1bb0026d8422e..0a6255b6e05d5 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -19,6 +19,7 @@ #include "llvm/ADT/APFloat.h" #include "llvm/ADT/STLExtras.h" #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" @@ -203,6 +204,20 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) { // Out of line virtual dtor for TargetInfo. TargetInfo::~TargetInfo() {} +size_t TargetInfo::getMaxBitIntWidth() const { + // Consider -fexperimental-max-bitint-width= first. + if (MaxBitIntWidth) + return std::min<size_t>(*MaxBitIntWidth, llvm::IntegerType::MAX_INT_BITS); + + // FIXME: this value should be llvm::IntegerType::MAX_INT_BITS, which is + // maximum bit width that LLVM claims its IR can support. However, most + // backends currently have a bug where they only support float to int + // conversion (and vice versa) on types that are <= 128 bits and crash + // otherwise. We're setting the max supported value to 128 to be + // conservative. + return 128; +} + void TargetInfo::resetDataLayout(StringRef DL) { DataLayoutString = DL.str(); } void TargetInfo::resetDataLayout() { diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h index 73287c5d2d58d..edaac3e74f9d3 100644 --- a/clang/lib/Basic/Targets/RISCV.h +++ b/clang/lib/Basic/Targets/RISCV.h @@ -15,6 +15,7 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetOptions.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/Compiler.h" #include "llvm/TargetParser/RISCVISAInfo.h" #include "llvm/TargetParser/Triple.h" diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index 9ed7035ccc230..658730ae88186 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -17,6 +17,7 @@ #include "clang/Basic/BitmaskEnum.h" #include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetOptions.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/Compiler.h" #include "llvm/TargetParser/Triple.h" #include "llvm/TargetParser/X86TargetParser.h" diff --git a/clang/lib/CIR/CodeGen/CIRGenerator.cpp b/clang/lib/CIR/CodeGen/CIRGenerator.cpp index 312766d66ba7e..8cbee4ea39a4b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenerator.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenerator.cpp @@ -18,6 +18,7 @@ #include "mlir/IR/MLIRContext.h" #include "clang/AST/DeclGroup.h" +#include "clang/AST/DeclOpenACC.h" #include "clang/CIR/CIRDataLayoutSpec.h" #include "clang/CIR/CIRGenerator.h" #include "clang/CIR/InitAllDialects.h" diff --git a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp index 78702a64da795..30f499e597cb6 100644 --- a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp +++ b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/IPO/Internalize.h" +#include "clang/AST/ASTContext.h" using namespace cir; using namespace clang; diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 409c222da87fc..5267d65e85ad8 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -40,6 +40,7 @@ #include "llvm/IR/Value.h" #include "llvm/Support/AtomicOrdering.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/VirtualFileSystem.h" #include <cassert> #include <cstdint> #include <numeric> diff --git a/clang/lib/CodeGen/CGPointerAuth.cpp b/clang/lib/CodeGen/CGPointerAuth.cpp index 6889899107266..438d08b53a742 100644 --- a/clang/lib/CodeGen/CGPointerAuth.cpp +++ b/clang/lib/CodeGen/CGPointerAuth.cpp @@ -14,6 +14,7 @@ #include "CGCXXABI.h" #include "CodeGenFunction.h" #include "CodeGenModule.h" +#include "clang/AST/Attr.h" #include "clang/CodeGen/CodeGenABITypes.h" #include "clang/CodeGen/ConstantInitBuilder.h" #include "llvm/Analysis/ValueTracking.h" diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 25606a51b6d71..0e6ae7e6d811e 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -44,6 +44,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Transforms/Utils/SanitizerStats.h" #include <optional> +#include "clang/AST/Attr.h" namespace llvm { class BasicBlock; diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3a2b261db011a..1c4e1cb110f26 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -81,6 +81,7 @@ #include "llvm/Transforms/Utils/BuildLibCalls.h" #include "llvm/Transforms/Utils/KCFIHash.h" #include "llvm/Transforms/Utils/ModuleUtils.h" +#include "llvm/Support/VirtualFileSystem.h" #include <optional> #include <set> diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp index 2239d54d591bf..4ef7a1fc4bf7a 100644 --- a/clang/lib/CrossTU/CrossTranslationUnit.cpp +++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp @@ -20,6 +20,7 @@ #include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/TextDiagnosticPrinter.h" +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "clang/UnifiedSymbolResolution/USRGeneration.h" #include "llvm/ADT/Statistic.h" #include "llvm/Option/ArgList.h" diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 2b6e65efbf026..fa308086da5b5 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -25,6 +25,8 @@ #include "clang/Tooling/Inclusions/HeaderIncludes.h" #include "llvm/ADT/Sequence.h" #include "llvm/ADT/StringSet.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/VirtualFileSystem.h" #include <functional> #include <limits> diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 66662a786e6fc..9126ad4c09dfe 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -188,6 +188,11 @@ void CompilerInstance::setPreprocessor(std::shared_ptr<Preprocessor> Value) { PP = std::move(Value); } +IntrusiveRefCntPtr<ASTContext> CompilerInstance::getASTContextPtr() const { + assert(Context && "Compiler instance has no AST context!"); + return Context; +} + void CompilerInstance::setASTContext( llvm::IntrusiveRefCntPtr<ASTContext> Value) { Context = std::move(Value); diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index c18c702d46cc7..e467ffc6ecf83 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -370,6 +370,25 @@ FrontendAction::FrontendAction() : Instance(nullptr) {} FrontendAction::~FrontendAction() {} +TranslationUnitKind FrontendAction::getTranslationUnitKind() { + // The ASTContext, if exists, knows the exact TUKind of the frondend. + if (Instance && Instance->hasASTContext()) + return Instance->getASTContext().TUKind; + return TU_Complete; +} + +bool FrontendAction::BeginSourceFileAction(CompilerInstance &CI) { + if (CurrentInput.isPreprocessed()) + CI.getPreprocessor().SetMacroExpansionOnlyInDirectives(); + return true; +} + +void FrontendAction::EndSourceFileAction() { + if (CurrentInput.isPreprocessed()) + // Reset the preprocessor macro expansion to the default. + getCompilerInstance().getPreprocessor().SetEnableMacroExpansion(); +} + void FrontendAction::setCurrentInput(const FrontendInputFile &CurrentInput, std::unique_ptr<ASTUnit> AST) { this->CurrentInput = CurrentInput; diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 4ef94c1991ee2..e7b05740b8376 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -15,6 +15,7 @@ #include "clang/Basic/Module.h" #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/ASTConsumers.h" +#include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/MultiplexConsumer.h" #include "clang/Frontend/Utils.h" diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp index 7142383fc64b3..73ab710af84fc 100644 --- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -11,6 +11,7 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" +#include "clang/Sema/Sema.h" #include "llvm/BinaryFormat/ELF.h" using namespace clang; diff --git a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp index dd2eb6721eae2..3854cbb73e249 100644 --- a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp +++ b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp @@ -18,6 +18,7 @@ #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Path.h" #include <optional> using namespace clang; diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index 5221ed4de02ff..fe54b8c083317 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/Locale.h" #include <algorithm> #include <optional> +#include "llvm/Support/Path.h" using namespace clang; diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 560aef43086cb..e872f0823f23e 100644 --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -27,6 +27,7 @@ #include "clang/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.h" #include "clang/ScalableStaticAnalysis/Frontend/TUSummaryExtractorFrontendAction.h" #include "clang/ScalableStaticAnalysis/SSAFForceLinker.h" // IWYU pragma: keep +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h" #include "clang/StaticAnalyzer/Frontend/FrontendActions.h" #include "llvm/Option/OptTable.h" diff --git a/clang/lib/Index/IndexingAction.cpp b/clang/lib/Index/IndexingAction.cpp index 1d98179111e78..1cdb4e14779dc 100644 --- a/clang/lib/Index/IndexingAction.cpp +++ b/clang/lib/Index/IndexingAction.cpp @@ -9,6 +9,7 @@ #include "clang/Index/IndexingAction.h" #include "IndexingContext.h" #include "clang/AST/DeclGroup.h" +#include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendAction.h" #include "clang/Index/IndexDataConsumer.h" diff --git a/clang/lib/InstallAPI/DirectoryScanner.cpp b/clang/lib/InstallAPI/DirectoryScanner.cpp index f8f708fda4ca4..80fe3938ef21e 100644 --- a/clang/lib/InstallAPI/DirectoryScanner.cpp +++ b/clang/lib/InstallAPI/DirectoryScanner.cpp @@ -9,6 +9,7 @@ #include "clang/InstallAPI/DirectoryScanner.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/Support/VirtualFileSystem.h" using namespace llvm; using namespace llvm::MachO; diff --git a/clang/lib/InstallAPI/Frontend.cpp b/clang/lib/InstallAPI/Frontend.cpp index cce0b19b50619..b2335e659d677 100644 --- a/clang/lib/InstallAPI/Frontend.cpp +++ b/clang/lib/InstallAPI/Frontend.cpp @@ -9,6 +9,7 @@ #include "clang/InstallAPI/Frontend.h" #include "clang/AST/Availability.h" #include "clang/InstallAPI/FrontendRecords.h" +#include "clang/Lex/Preprocessor.h" #include "llvm/ADT/StringRef.h" using namespace llvm; diff --git a/clang/lib/InstallAPI/HeaderFile.cpp b/clang/lib/InstallAPI/HeaderFile.cpp index d736a0af0dd47..63fad847abe7d 100644 --- a/clang/lib/InstallAPI/HeaderFile.cpp +++ b/clang/lib/InstallAPI/HeaderFile.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "clang/InstallAPI/HeaderFile.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/TextAPI/Utils.h" using namespace llvm; diff --git a/clang/lib/Interpreter/IncrementalAction.h b/clang/lib/Interpreter/IncrementalAction.h index 725cdd0c27cf4..2893ff7b5baa6 100644 --- a/clang/lib/Interpreter/IncrementalAction.h +++ b/clang/lib/Interpreter/IncrementalAction.h @@ -13,6 +13,7 @@ #include "clang/Frontend/MultiplexConsumer.h" namespace llvm { +class LLVMContext; class Module; } diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index b44bf2cd3c253..552902e70f094 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -21,6 +21,7 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/MemoryBufferRef.h" #include "llvm/Support/Path.h" +#include "llvm/Support/VirtualFileSystem.h" #include <optional> using namespace clang; diff --git a/clang/lib/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.cpp b/clang/lib/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.cpp index b7886af72479d..3592f131e8217 100644 --- a/clang/lib/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.cpp +++ b/clang/lib/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.cpp @@ -29,6 +29,7 @@ #include <string> #include <utility> #include <vector> +#include "clang/AST/ASTContext.h" using namespace clang; using namespace ssaf; diff --git a/clang/lib/ScalableStaticAnalysis/Frontend/TUSummaryExtractorFrontendAction.cpp b/clang/lib/ScalableStaticAnalysis/Frontend/TUSummaryExtractorFrontendAction.cpp index bb4caef8f99ab..dc72fa20ee02b 100644 --- a/clang/lib/ScalableStaticAnalysis/Frontend/TUSummaryExtractorFrontendAction.cpp +++ b/clang/lib/ScalableStaticAnalysis/Frontend/TUSummaryExtractorFrontendAction.cpp @@ -8,6 +8,7 @@ #include "clang/ScalableStaticAnalysis/Frontend/TUSummaryExtractorFrontendAction.h" #include "clang/AST/ASTConsumer.h" +#include "clang/AST/ASTContext.h" #include "clang/Basic/DiagnosticFrontend.h" #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/MultiplexConsumer.h" diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 3b3c9a476421d..1821ecf41a005 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -54,7 +54,9 @@ #include "llvm/ADT/Twine.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" #include <list> diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d06079a43e23a..60d1083ccc76b 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -65,6 +65,7 @@ #include "clang/Sema/Template.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/SaveAndRestore.h" #include "llvm/Support/TimeProfiler.h" diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index c4c4b22f85093..e3e3d29f3273e 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -81,6 +81,7 @@ #include "clang/Sema/Sema.h" #include "clang/Sema/SemaCUDA.h" #include "clang/Sema/SemaObjC.h" +#include "clang/Sema/SemaRISCV.h" #include "clang/Sema/Weak.h" #include "clang/Serialization/ASTBitCodes.h" #include "clang/Serialization/ASTDeserializationListener.h" @@ -141,6 +142,7 @@ #include <tuple> #include <utility> #include <vector> +#include "llvm/Support/VirtualFileSystem.h" using namespace clang; using namespace clang::serialization; diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index f34b2ff182bc8..4db2bfb900ac9 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -70,6 +70,7 @@ #include "clang/Sema/Sema.h" #include "clang/Sema/SemaCUDA.h" #include "clang/Sema/SemaObjC.h" +#include "clang/Sema/SemaRISCV.h" #include "clang/Sema/Weak.h" #include "clang/Serialization/ASTBitCodes.h" #include "clang/Serialization/ASTReader.h" @@ -118,6 +119,7 @@ #include <tuple> #include <utility> #include <vector> +#include "llvm/Support/VirtualFileSystem.h" using namespace clang; using namespace clang::serialization; diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp index 3e3fff900cde8..ee6b613e579f1 100644 --- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -25,6 +25,7 @@ #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Support/FileSystem.h" #include <memory> #include <optional> diff --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp index 1d5139c067c7b..8d85d5543e47d 100644 --- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp @@ -25,6 +25,8 @@ #include "llvm/ADT/StringMap.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/JSON.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" #include <memory> using namespace llvm; diff --git a/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp b/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp index 531c642bf4f31..ee59e6a7be939 100644 --- a/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp @@ -17,6 +17,7 @@ #include "clang/Frontend/FrontendAction.h" #include "clang/Lex/Preprocessor.h" #include "clang/Serialization/ASTReader.h" +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "clang/StaticAnalyzer/Frontend/FrontendActions.h" #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/FileSystem.h" diff --git a/clang/lib/Testing/TestAST.cpp b/clang/lib/Testing/TestAST.cpp index f99f649f52e9c..af5eedf9beddb 100644 --- a/clang/lib/Testing/TestAST.cpp +++ b/clang/lib/Testing/TestAST.cpp @@ -18,6 +18,7 @@ #include "gtest/gtest.h" #include <string> +#include "clang/Lex/Preprocessor.h" namespace clang { namespace { diff --git a/clang/lib/Tooling/Syntax/Tokens.cpp b/clang/lib/Tooling/Syntax/Tokens.cpp index 6b75c17cab67e..0550dddf8d8ea 100644 --- a/clang/lib/Tooling/Syntax/Tokens.cpp +++ b/clang/lib/Tooling/Syntax/Tokens.cpp @@ -28,6 +28,7 @@ #include <string> #include <utility> #include <vector> +#include "llvm/Support/Path.h" using namespace clang; using namespace clang::syntax; diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index de513d942df1a..3703ea6488df5 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -25,6 +25,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/InitLLVM.h" #include "llvm/Support/Process.h" +#include "llvm/Support/VirtualFileSystem.h" #include <fstream> using namespace llvm; diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp index f484d6f33ad8f..f0ad4501a4593 100644 --- a/clang/tools/clang-installapi/Options.cpp +++ b/clang/tools/clang-installapi/Options.cpp @@ -16,6 +16,7 @@ #include "llvm/BinaryFormat/Magic.h" #include "llvm/Support/JSON.h" #include "llvm/Support/Program.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/TargetParser/Host.h" #include "llvm/TextAPI/DylibReader.h" #include "llvm/TextAPI/TextAPIError.h" diff --git a/clang/unittests/Analysis/MacroExpansionContextTest.cpp b/clang/unittests/Analysis/MacroExpansionContextTest.cpp index 25a76edbfdc49..d180f3be3dc0a 100644 --- a/clang/unittests/Analysis/MacroExpansionContextTest.cpp +++ b/clang/unittests/Analysis/MacroExpansionContextTest.cpp @@ -23,6 +23,7 @@ #include "clang/Parse/Parser.h" #include "llvm/ADT/SmallString.h" #include "gtest/gtest.h" +#include "llvm/Support/VirtualFileSystem.h" // static bool HACK_EnableDebugInUnitTest = (::llvm::DebugFlag = true); diff --git a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp index 96d0c1954505c..8457c1b16ad1c 100644 --- a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp +++ b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp @@ -17,6 +17,7 @@ #include "llvm/Support/ToolOutputFile.h" #include "gtest/gtest.h" #include <cassert> +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" namespace clang { namespace cross_tu { diff --git a/clang/unittests/Frontend/CompilerInstanceTest.cpp b/clang/unittests/Frontend/CompilerInstanceTest.cpp index 41908e9c0f254..f4d47bdfbc676 100644 --- a/clang/unittests/Frontend/CompilerInstanceTest.cpp +++ b/clang/unittests/Frontend/CompilerInstanceTest.cpp @@ -20,6 +20,8 @@ #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/VirtualFileSystem.h" #include "gtest/gtest.h" +#include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PPCallbacks.h" using namespace llvm; using namespace clang; diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index be537ae88bdf9..ac881c3a3217c 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -15,6 +15,7 @@ #include "llvm/Support/VirtualFileSystem.h" #include "llvm/TargetParser/Host.h" +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp index 0213bfeb8e221..845115cdfa906 100644 --- a/clang/unittests/Lex/HeaderSearchTest.cpp +++ b/clang/unittests/Lex/HeaderSearchTest.cpp @@ -20,6 +20,7 @@ #include "gtest/gtest.h" #include <memory> #include <string> +#include "llvm/Support/VirtualFileSystem.h" namespace clang { namespace { diff --git a/clang/unittests/Lex/NoTrivialPPDirectiveTracerTest.cpp b/clang/unittests/Lex/NoTrivialPPDirectiveTracerTest.cpp index d79c1428e55bb..0833ac59dfc06 100644 --- a/clang/unittests/Lex/NoTrivialPPDirectiveTracerTest.cpp +++ b/clang/unittests/Lex/NoTrivialPPDirectiveTracerTest.cpp @@ -21,6 +21,7 @@ #include "gtest/gtest.h" #include <cstddef> #include <initializer_list> +#include "llvm/Support/VirtualFileSystem.h" using namespace clang; diff --git a/clang/unittests/Lex/PPCallbacksTest.cpp b/clang/unittests/Lex/PPCallbacksTest.cpp index 9533fbc776e6e..4f2c158f6a8ab 100644 --- a/clang/unittests/Lex/PPCallbacksTest.cpp +++ b/clang/unittests/Lex/PPCallbacksTest.cpp @@ -25,6 +25,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/Support/Path.h" #include "gtest/gtest.h" +#include "llvm/Support/VirtualFileSystem.h" using namespace clang; diff --git a/clang/unittests/Lex/PPDependencyDirectivesTest.cpp b/clang/unittests/Lex/PPDependencyDirectivesTest.cpp index 3b369ffc60d27..6a62b36241768 100644 --- a/clang/unittests/Lex/PPDependencyDirectivesTest.cpp +++ b/clang/unittests/Lex/PPDependencyDirectivesTest.cpp @@ -22,6 +22,7 @@ #include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" #include <optional> +#include "llvm/Support/VirtualFileSystem.h" using namespace clang; diff --git a/clang/unittests/Tooling/ASTSelectionTest.cpp b/clang/unittests/Tooling/ASTSelectionTest.cpp index 0f60749725cde..de4b1979f1ebd 100644 --- a/clang/unittests/Tooling/ASTSelectionTest.cpp +++ b/clang/unittests/Tooling/ASTSelectionTest.cpp @@ -10,6 +10,7 @@ #include "clang/Basic/SourceManager.h" #include "clang/Tooling/Refactoring/ASTSelection.h" #include <optional> +#include "clang/AST/ExprObjC.h" using namespace clang; using namespace tooling; diff --git a/clang/unittests/Tooling/RewriterTestContext.h b/clang/unittests/Tooling/RewriterTestContext.h index 020ef60aa16ae..46bd3dcbb510a 100644 --- a/clang/unittests/Tooling/RewriterTestContext.h +++ b/clang/unittests/Tooling/RewriterTestContext.h @@ -21,6 +21,7 @@ #include "clang/Rewrite/Core/Rewriter.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" namespace clang { diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp index dad75854240ef..2453b1f03d802 100644 --- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp @@ -31,6 +31,7 @@ #include "llvm/Support/Error.h" #include "llvm/Testing/Annotations/Annotations.h" #include "gtest/gtest.h" +#include "clang/AST/ASTContext.h" using namespace clang; using namespace clang::syntax; diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.h b/clang/unittests/Tooling/Syntax/TreeTestBase.h index e85d76c9efed7..780778030fb6d 100644 --- a/clang/unittests/Tooling/Syntax/TreeTestBase.h +++ b/clang/unittests/Tooling/Syntax/TreeTestBase.h @@ -25,6 +25,7 @@ #include "llvm/Testing/Annotations/Annotations.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "llvm/Support/VirtualFileSystem.h" namespace clang { namespace syntax { >From 76355f54b2bba62e530e658c88211eb80859a46e Mon Sep 17 00:00:00 2001 From: Chandler Carruth <[email protected]> Date: Tue, 18 Aug 2026 12:41:26 -0700 Subject: [PATCH 2/3] Fix premerge build failures, include order, and comment verbosity Sort the includes added by the previous commit into their blocks so clang-format is clean. Include what the trimmed headers no longer provide transitively: NestedNameSpecifier.h in QualTypeNames.cpp, DeclTemplate.h in clangd's ExpandDeducedType.cpp, and the OpenACC declarations and kinds used by the CIR CodeGen headers. Cut the comments explaining why members are defined out of line down to a single statement in GlobalDecl.cpp. Assisted-by: Claude Code --- clang-tools-extra/clangd/FindSymbols.cpp | 2 +- clang-tools-extra/clangd/ParsedAST.h | 2 +- clang-tools-extra/clangd/Preamble.h | 2 +- .../clangd/refactor/tweaks/ExpandDeducedType.cpp | 1 + clang-tools-extra/clangd/unittests/ASTTests.cpp | 2 +- .../clangd/unittests/ExpectedTypeTest.cpp | 2 +- .../clangd/unittests/FindTargetTests.cpp | 2 +- .../clangd/unittests/InsertionPointTests.cpp | 2 +- .../include-cleaner/lib/FindHeaders.cpp | 2 +- .../include-cleaner/lib/HTMLReport.cpp | 2 +- .../include-cleaner/lib/IncludeSpeller.cpp | 2 +- .../include-cleaner/unittests/RecordTest.cpp | 2 +- clang/include/clang/AST/GlobalDecl.h | 15 ++------------- .../Analyses/LifetimeSafety/LifetimeAnnotations.h | 2 -- clang/include/clang/Basic/FileManager.h | 9 ++------- clang/include/clang/Driver/Driver.h | 2 +- clang/include/clang/Frontend/ASTUnit.h | 2 +- clang/lib/AST/Decl.cpp | 2 +- clang/lib/AST/GlobalDecl.cpp | 7 +++---- clang/lib/AST/QualTypeNames.cpp | 1 + clang/lib/Basic/SourceManager.cpp | 2 +- clang/lib/CIR/CodeGen/CIRGenFunction.h | 1 + clang/lib/CIR/CodeGen/CIRGenModule.h | 4 ++++ clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h | 1 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 2 +- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 2 +- clang/lib/CodeGen/CodeGenFunction.h | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- clang/lib/Frontend/Rewrite/InclusionRewriter.cpp | 4 ++-- clang/lib/Frontend/TextDiagnostic.cpp | 2 +- .../SourceTransformationFrontendAction.cpp | 2 +- clang/lib/Serialization/ASTReader.cpp | 2 +- clang/lib/Serialization/ASTWriter.cpp | 2 +- .../lib/StaticAnalyzer/Core/SarifDiagnostics.cpp | 2 +- clang/lib/Testing/TestAST.cpp | 2 +- clang/lib/Tooling/Syntax/Tokens.cpp | 2 +- .../Analysis/MacroExpansionContextTest.cpp | 2 +- .../CrossTU/CrossTranslationUnitTest.cpp | 2 +- clang/unittests/Frontend/CompilerInstanceTest.cpp | 4 ++-- clang/unittests/Lex/HeaderSearchTest.cpp | 2 +- .../Lex/NoTrivialPPDirectiveTracerTest.cpp | 2 +- clang/unittests/Lex/PPCallbacksTest.cpp | 4 ++-- .../unittests/Lex/PPDependencyDirectivesTest.cpp | 2 +- clang/unittests/Tooling/ASTSelectionTest.cpp | 4 ++-- clang/unittests/Tooling/Syntax/TreeTestBase.cpp | 2 +- clang/unittests/Tooling/Syntax/TreeTestBase.h | 2 +- 46 files changed, 56 insertions(+), 67 deletions(-) diff --git a/clang-tools-extra/clangd/FindSymbols.cpp b/clang-tools-extra/clangd/FindSymbols.cpp index 7e3067cf41464..2a674d375b5d9 100644 --- a/clang-tools-extra/clangd/FindSymbols.cpp +++ b/clang-tools-extra/clangd/FindSymbols.cpp @@ -16,6 +16,7 @@ #include "index/Symbol.h" #include "index/SymbolLocation.h" #include "support/Logger.h" +#include "clang/AST/Attr.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclTemplate.h" @@ -26,7 +27,6 @@ #include "llvm/ADT/StringRef.h" #include <limits> #include <optional> -#include "clang/AST/Attr.h" #define DEBUG_TYPE "FindSymbols" diff --git a/clang-tools-extra/clangd/ParsedAST.h b/clang-tools-extra/clangd/ParsedAST.h index 03b1ad836a34c..353859a3b46d5 100644 --- a/clang-tools-extra/clangd/ParsedAST.h +++ b/clang-tools-extra/clangd/ParsedAST.h @@ -27,6 +27,7 @@ #include "Preamble.h" #include "clang-include-cleaner/Record.h" #include "support/Path.h" +#include "clang/AST/DeclCXX.h" #include "clang/Frontend/FrontendAction.h" #include "clang/Lex/Preprocessor.h" #include "clang/Tooling/Syntax/Tokens.h" @@ -36,7 +37,6 @@ #include <optional> #include <string> #include <vector> -#include "clang/AST/DeclCXX.h" namespace clang { class HeuristicResolver; diff --git a/clang-tools-extra/clangd/Preamble.h b/clang-tools-extra/clangd/Preamble.h index 44f20901caad3..9802f56d9962a 100644 --- a/clang-tools-extra/clangd/Preamble.h +++ b/clang-tools-extra/clangd/Preamble.h @@ -41,13 +41,13 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +#include "clang/AST/ASTContext.h" #include <cstddef> #include <functional> #include <memory> #include <string> #include <utility> #include <vector> -#include "clang/AST/ASTContext.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp index 52afda56a5028..2c6ab530e6f6c 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp @@ -8,6 +8,7 @@ #include "refactor/Tweak.h" #include "support/Logger.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/Type.h" #include "clang/AST/TypeLoc.h" #include "clang/Basic/LLVM.h" diff --git a/clang-tools-extra/clangd/unittests/ASTTests.cpp b/clang-tools-extra/clangd/unittests/ASTTests.cpp index 323a89a25e495..4c4cb16044a0b 100644 --- a/clang-tools-extra/clangd/unittests/ASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/ASTTests.cpp @@ -16,6 +16,7 @@ #include "clang/AST/Attr.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclBase.h" +#include "clang/AST/DeclTemplate.h" #include "clang/Basic/AttrKinds.h" #include "clang/Basic/SourceManager.h" #include "llvm/ADT/StringRef.h" @@ -25,7 +26,6 @@ #include <cstddef> #include <string> #include <vector> -#include "clang/AST/DeclTemplate.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp b/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp index 9ba18688066e6..45292bbeec2e8 100644 --- a/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp +++ b/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp @@ -11,11 +11,11 @@ #include "TestTU.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" +#include "clang/Sema/CodeCompleteConsumer.h" #include "llvm/ADT/StringRef.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include <optional> -#include "clang/Sema/CodeCompleteConsumer.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp index 89c39b010922b..3377b017410b5 100644 --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -10,6 +10,7 @@ #include "Selection.h" #include "TestTU.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/StringRef.h" @@ -19,7 +20,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include <initializer_list> -#include "clang/AST/DeclObjC.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp b/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp index d0b60e7434513..f8a0df5b73dac 100644 --- a/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp +++ b/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp @@ -13,10 +13,10 @@ #include "XRefs.h" #include "refactor/InsertionPoint.h" #include "clang/AST/DeclBase.h" +#include "clang/AST/DeclObjC.h" #include "llvm/Testing/Support/Error.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "clang/AST/DeclObjC.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp index 1b00f7cf6a474..47f3c37501cdc 100644 --- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp +++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp @@ -26,11 +26,11 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Path.h" #include <optional> #include <queue> #include <set> #include <utility> -#include "llvm/Support/Path.h" namespace clang::include_cleaner { namespace { diff --git a/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp b/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp index c056752fba95f..cd739e0ab329b 100644 --- a/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp +++ b/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp @@ -23,10 +23,10 @@ #include "clang/Lex/Lexer.h" #include "clang/Lex/Preprocessor.h" #include "clang/Tooling/Inclusions/StandardLibrary.h" +#include "llvm/Support/Path.h" #include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/raw_ostream.h" #include <numeric> -#include "llvm/Support/Path.h" namespace clang::include_cleaner { namespace { diff --git a/clang-tools-extra/include-cleaner/lib/IncludeSpeller.cpp b/clang-tools-extra/include-cleaner/lib/IncludeSpeller.cpp index 0b4a92b485248..c420af7b41dfe 100644 --- a/clang-tools-extra/include-cleaner/lib/IncludeSpeller.cpp +++ b/clang-tools-extra/include-cleaner/lib/IncludeSpeller.cpp @@ -12,9 +12,9 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Registry.h" +#include "llvm/Support/VirtualFileSystem.h" #include <memory> #include <string> -#include "llvm/Support/VirtualFileSystem.h" LLVM_INSTANTIATE_REGISTRY(clang::include_cleaner::IncludeSpellingStrategy) diff --git a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp index c7abb4f23d838..cc0fc127af72c 100644 --- a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp @@ -17,6 +17,7 @@ #include "clang/Frontend/FrontendAction.h" #include "clang/Frontend/FrontendActions.h" #include "clang/Frontend/FrontendOptions.h" +#include "clang/Lex/Preprocessor.h" #include "clang/Serialization/PCHContainerOperations.h" #include "clang/Testing/CommandLineArgs.h" #include "clang/Testing/TestAST.h" @@ -36,7 +37,6 @@ #include <memory> #include <optional> #include <utility> -#include "clang/Lex/Preprocessor.h" namespace clang::include_cleaner { namespace { diff --git a/clang/include/clang/AST/GlobalDecl.h b/clang/include/clang/AST/GlobalDecl.h index c6a7c6431a762..0ae48e030bb3f 100644 --- a/clang/include/clang/AST/GlobalDecl.h +++ b/clang/include/clang/AST/GlobalDecl.h @@ -61,17 +61,10 @@ class GlobalDecl { llvm::PointerIntPair<const Decl *, 3> Value; unsigned MultiVersionIndex = 0; - /// Whether \p D carries the CUDA `__global__` attribute. - /// - /// Defined out of line so that this header does not have to include the - /// generated attribute class definitions for assertions alone. CLANG_ABI static bool hasCUDAGlobalAttr(const Decl *D); - /// Whether \p D is a kernel that is referred to through an explicit - /// KernelReferenceKind, either directly or as a function template. - /// - /// Defined out of line so that this header does not have to include the - /// template declaration hierarchy for assertions alone. + /// Whether \p D is a kernel referred to through a KernelReferenceKind, + /// either directly or as a function template. CLANG_ABI static bool isKernelReference(const Decl *D); void Init(const Decl *D) { @@ -101,8 +94,6 @@ class GlobalDecl { GlobalDecl(const BlockDecl *D) { Init(D); } GlobalDecl(const CapturedDecl *D) { Init(D); } GlobalDecl(const ObjCMethodDecl *D) { Init(D); } - // Defined out of line so that this header does not have to pull in the - // OpenMP and OpenACC declaration hierarchies for these rare cases. GlobalDecl(const OMPDeclareReductionDecl *D); GlobalDecl(const OMPDeclareMapperDecl *D); GlobalDecl(const OpenACCRoutineDecl *D); @@ -173,8 +164,6 @@ class GlobalDecl { return GD; } - /// Defined out of line so that this header does not have to include the - /// generated attribute class definitions. CLANG_ABI static KernelReferenceKind getDefaultKernelReference(const FunctionDecl *D); diff --git a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h index d0d0d4a103918..ec2ae64589544 100644 --- a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h +++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h @@ -17,8 +17,6 @@ #include <optional> namespace clang { -// Only ever named through a pointer here, so the generated attribute -// class definitions are not needed. class LifetimeBoundAttr; } // namespace clang diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h index daded34eb7e01..04003654bab72 100644 --- a/clang/include/clang/Basic/FileManager.h +++ b/clang/include/clang/Basic/FileManager.h @@ -38,10 +38,6 @@ namespace llvm { namespace vfs { -// Only named through pointers, references and IntrusiveRefCntPtr below. -// Including VirtualFileSystem.h here would put <chrono>, and with it libc++'s -// <sstream>/<locale>/<format> machinery, into every translation unit that -// touches SourceManager. class File; class FileSystem; class Status; @@ -161,9 +157,8 @@ class FileManager : public RefCountedBase<FileManager> { /// llvm::vfs::getRealFileSystem(). FileManager(const FileSystemOptions &FileSystemOpts, IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS); - /// Construct a file manager over the real file system. Kept separate from - /// the constructor above rather than defaulting its argument so that callers - /// do not need llvm::vfs::FileSystem to be complete. + /// Construct a file manager over the real file system. Separate from the + /// overload above so that callers do not need a complete FileSystem type. explicit FileManager(const FileSystemOptions &FileSystemOpts); ~FileManager(); diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 0a21a54993e14..2c2d12920f479 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -29,11 +29,11 @@ #include "llvm/Option/ArgList.h" #include "llvm/Support/StringSaver.h" +#include "llvm/Support/VirtualFileSystem.h" #include <map> #include <set> #include <string> #include <vector> -#include "llvm/Support/VirtualFileSystem.h" namespace llvm { class Triple; diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index cbff9980e6906..fb7a0addcc202 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -39,6 +39,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Bitstream/BitstreamWriter.h" +#include "llvm/Support/VirtualFileSystem.h" #include <cassert> #include <cstddef> #include <cstdint> @@ -47,7 +48,6 @@ #include <string> #include <utility> #include <vector> -#include "llvm/Support/VirtualFileSystem.h" namespace llvm { diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index da7ed96093752..0894097333d73 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -60,9 +60,9 @@ #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Triple.h" -#include "llvm/Support/Path.h" #include <algorithm> #include <cassert> #include <cstddef> diff --git a/clang/lib/AST/GlobalDecl.cpp b/clang/lib/AST/GlobalDecl.cpp index 72f2848c17a0d..f520a45101d13 100644 --- a/clang/lib/AST/GlobalDecl.cpp +++ b/clang/lib/AST/GlobalDecl.cpp @@ -6,10 +6,9 @@ // //===----------------------------------------------------------------------===// // -// Out-of-line members of GlobalDecl. GlobalDecl is a small key type that is -// included very widely, so everything here is kept out of the header to spare -// its users the OpenMP and OpenACC declaration hierarchies, the generated -// attribute classes, and the template declaration hierarchy. +// GlobalDecl.h is included very widely, so these members are defined here to +// keep the OpenMP and OpenACC declaration hierarchies, the generated attribute +// classes, and the template declaration hierarchy out of it. // //===----------------------------------------------------------------------===// diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp index 191841649a86f..806953b18cd0c 100644 --- a/clang/lib/AST/QualTypeNames.cpp +++ b/clang/lib/AST/QualTypeNames.cpp @@ -10,6 +10,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/Mangle.h" +#include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/Type.h" namespace clang { diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 136426d302f61..c9567d263c444 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -27,11 +27,11 @@ #include "llvm/Support/AutoConvert.h" #include "llvm/Support/Capacity.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/VirtualFileSystem.h" #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> #include <cassert> diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.h b/clang/lib/CIR/CodeGen/CIRGenFunction.h index 20e2d13c9652f..dfe173ae7c8f3 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.h +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.h @@ -30,6 +30,7 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/Stmt.h" #include "clang/AST/Type.h" +#include "clang/Basic/OpenACCKinds.h" #include "clang/Basic/OperatorKinds.h" #include "clang/Basic/TargetBuiltins.h" #include "clang/CIR/Dialect/IR/CIRDialect.h" diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.h b/clang/lib/CIR/CodeGen/CIRGenModule.h index b41a2535991a2..7ea47ba6d5d24 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.h +++ b/clang/lib/CIR/CodeGen/CIRGenModule.h @@ -32,6 +32,7 @@ #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/MLIRContext.h" #include "clang/AST/Decl.h" +#include "clang/Basic/OpenACCKinds.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "clang/CIR/Dialect/IR/CIROpsEnums.h" @@ -45,6 +46,9 @@ class CodeGenOptions; class Decl; class GlobalDecl; class LangOptions; +class OpenACCConstructDecl; +class OpenACCDeclareDecl; +class OpenACCRoutineDecl; class TargetInfo; class VarDecl; diff --git a/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h b/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h index 745d42446896e..e709380be0d1f 100644 --- a/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h +++ b/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h @@ -17,6 +17,7 @@ #include "clang/AST/DeclBase.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" +#include "clang/AST/OpenACCClause.h" #include "clang/AST/TypeBase.h" #include "clang/Basic/OpenACCKinds.h" diff --git a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp index 30f499e597cb6..66c2f9b7a8937 100644 --- a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp +++ b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp @@ -10,6 +10,7 @@ #include "CIRDiagnosticHandler.h" #include "mlir/IR/MLIRContext.h" #include "mlir/IR/OwningOpRef.h" +#include "clang/AST/ASTContext.h" #include "clang/Basic/DiagnosticCodeGen.h" #include "clang/CIR/CIRGenerator.h" #include "clang/CIR/CIRToCIRPasses.h" @@ -29,7 +30,6 @@ #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/IPO/Internalize.h" -#include "clang/AST/ASTContext.h" using namespace cir; using namespace clang; diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 5267d65e85ad8..55b440a4cc9b8 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -39,8 +39,8 @@ #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Value.h" #include "llvm/Support/AtomicOrdering.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/VirtualFileSystem.h" +#include "llvm/Support/raw_ostream.h" #include <cassert> #include <cstdint> #include <numeric> diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 0e6ae7e6d811e..dfb6f2ff65a7d 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -20,6 +20,7 @@ #include "EHScopeStack.h" #include "SanitizerHandler.h" #include "VarBypassDetector.h" +#include "clang/AST/Attr.h" #include "clang/AST/CharUnits.h" #include "clang/AST/CurrentSourceLocExprScope.h" #include "clang/AST/ExprCXX.h" @@ -44,7 +45,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Transforms/Utils/SanitizerStats.h" #include <optional> -#include "clang/AST/Attr.h" namespace llvm { class BasicBlock; diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 1c4e1cb110f26..53fb85db2af9f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -73,6 +73,7 @@ #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/TimeProfiler.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/TargetParser/AArch64TargetParser.h" #include "llvm/TargetParser/RISCVISAInfo.h" #include "llvm/TargetParser/Triple.h" @@ -81,7 +82,6 @@ #include "llvm/Transforms/Utils/BuildLibCalls.h" #include "llvm/Transforms/Utils/KCFIHash.h" #include "llvm/Transforms/Utils/ModuleUtils.h" -#include "llvm/Support/VirtualFileSystem.h" #include <optional> #include <set> diff --git a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp index 3854cbb73e249..01ba99e8d89db 100644 --- a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp +++ b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp @@ -11,14 +11,14 @@ // //===----------------------------------------------------------------------===// -#include "clang/Rewrite/Frontend/Rewriters.h" #include "clang/Basic/SourceManager.h" #include "clang/Frontend/PreprocessorOutputOptions.h" #include "clang/Lex/Pragma.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Rewrite/Frontend/Rewriters.h" #include "llvm/ADT/SmallString.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Path.h" +#include "llvm/Support/raw_ostream.h" #include <optional> using namespace clang; diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index fe54b8c083317..57ee3085bae6b 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -17,9 +17,9 @@ #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Locale.h" +#include "llvm/Support/Path.h" #include <algorithm> #include <optional> -#include "llvm/Support/Path.h" using namespace clang; diff --git a/clang/lib/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.cpp b/clang/lib/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.cpp index 3592f131e8217..6ae7518e0ed56 100644 --- a/clang/lib/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.cpp +++ b/clang/lib/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.cpp @@ -8,6 +8,7 @@ #include "clang/ScalableStaticAnalysis/Frontend/SourceTransformationFrontendAction.h" #include "clang/AST/ASTConsumer.h" +#include "clang/AST/ASTContext.h" #include "clang/Basic/DiagnosticFrontend.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/MultiplexConsumer.h" @@ -29,7 +30,6 @@ #include <string> #include <utility> #include <vector> -#include "clang/AST/ASTContext.h" using namespace clang; using namespace ssaf; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index e3e3d29f3273e..24321a20d09f1 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -124,6 +124,7 @@ #include "llvm/Support/TimeProfiler.h" #include "llvm/Support/Timer.h" #include "llvm/Support/VersionTuple.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Triple.h" #include <algorithm> @@ -142,7 +143,6 @@ #include <tuple> #include <utility> #include <vector> -#include "llvm/Support/VirtualFileSystem.h" using namespace clang; using namespace clang::serialization; diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 4db2bfb900ac9..43df387a10baf 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -105,6 +105,7 @@ #include "llvm/Support/SHA1.h" #include "llvm/Support/TimeProfiler.h" #include "llvm/Support/VersionTuple.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cassert> @@ -119,7 +120,6 @@ #include <tuple> #include <utility> #include <vector> -#include "llvm/Support/VirtualFileSystem.h" using namespace clang; using namespace clang::serialization; diff --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp index 8d85d5543e47d..afd2016b0f890 100644 --- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp @@ -24,8 +24,8 @@ #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/ConvertUTF.h" -#include "llvm/Support/JSON.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/JSON.h" #include "llvm/Support/Path.h" #include <memory> diff --git a/clang/lib/Testing/TestAST.cpp b/clang/lib/Testing/TestAST.cpp index af5eedf9beddb..6548a930a40f2 100644 --- a/clang/lib/Testing/TestAST.cpp +++ b/clang/lib/Testing/TestAST.cpp @@ -16,9 +16,9 @@ #include "llvm/Support/Error.h" #include "llvm/Support/VirtualFileSystem.h" +#include "clang/Lex/Preprocessor.h" #include "gtest/gtest.h" #include <string> -#include "clang/Lex/Preprocessor.h" namespace clang { namespace { diff --git a/clang/lib/Tooling/Syntax/Tokens.cpp b/clang/lib/Tooling/Syntax/Tokens.cpp index 0550dddf8d8ea..7db02b9a5394c 100644 --- a/clang/lib/Tooling/Syntax/Tokens.cpp +++ b/clang/lib/Tooling/Syntax/Tokens.cpp @@ -22,13 +22,13 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include <cassert> #include <optional> #include <string> #include <utility> #include <vector> -#include "llvm/Support/Path.h" using namespace clang; using namespace clang::syntax; diff --git a/clang/unittests/Analysis/MacroExpansionContextTest.cpp b/clang/unittests/Analysis/MacroExpansionContextTest.cpp index d180f3be3dc0a..2b9d3de70f0f3 100644 --- a/clang/unittests/Analysis/MacroExpansionContextTest.cpp +++ b/clang/unittests/Analysis/MacroExpansionContextTest.cpp @@ -22,8 +22,8 @@ #include "clang/Lex/PreprocessorOptions.h" #include "clang/Parse/Parser.h" #include "llvm/ADT/SmallString.h" -#include "gtest/gtest.h" #include "llvm/Support/VirtualFileSystem.h" +#include "gtest/gtest.h" // static bool HACK_EnableDebugInUnitTest = (::llvm::DebugFlag = true); diff --git a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp index 8457c1b16ad1c..562024ac96556 100644 --- a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp +++ b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp @@ -11,13 +11,13 @@ #include "clang/AST/ParentMapContext.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendAction.h" +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/ToolOutputFile.h" #include "gtest/gtest.h" #include <cassert> -#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" namespace clang { namespace cross_tu { diff --git a/clang/unittests/Frontend/CompilerInstanceTest.cpp b/clang/unittests/Frontend/CompilerInstanceTest.cpp index f4d47bdfbc676..f4377498d6ff6 100644 --- a/clang/unittests/Frontend/CompilerInstanceTest.cpp +++ b/clang/unittests/Frontend/CompilerInstanceTest.cpp @@ -12,6 +12,8 @@ #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/FrontendActions.h" #include "clang/Frontend/TextDiagnosticPrinter.h" +#include "clang/Lex/PPCallbacks.h" +#include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/Support/FileSystem.h" @@ -20,8 +22,6 @@ #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/VirtualFileSystem.h" #include "gtest/gtest.h" -#include "clang/Lex/Preprocessor.h" -#include "clang/Lex/PPCallbacks.h" using namespace llvm; using namespace clang; diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp index 845115cdfa906..3183b4bc491fd 100644 --- a/clang/unittests/Lex/HeaderSearchTest.cpp +++ b/clang/unittests/Lex/HeaderSearchTest.cpp @@ -17,10 +17,10 @@ #include "clang/Basic/TargetOptions.h" #include "clang/Lex/HeaderSearchOptions.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/VirtualFileSystem.h" #include "gtest/gtest.h" #include <memory> #include <string> -#include "llvm/Support/VirtualFileSystem.h" namespace clang { namespace { diff --git a/clang/unittests/Lex/NoTrivialPPDirectiveTracerTest.cpp b/clang/unittests/Lex/NoTrivialPPDirectiveTracerTest.cpp index 0833ac59dfc06..049bf599b4e23 100644 --- a/clang/unittests/Lex/NoTrivialPPDirectiveTracerTest.cpp +++ b/clang/unittests/Lex/NoTrivialPPDirectiveTracerTest.cpp @@ -18,10 +18,10 @@ #include "clang/Lex/ModuleLoader.h" #include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" +#include "llvm/Support/VirtualFileSystem.h" #include "gtest/gtest.h" #include <cstddef> #include <initializer_list> -#include "llvm/Support/VirtualFileSystem.h" using namespace clang; diff --git a/clang/unittests/Lex/PPCallbacksTest.cpp b/clang/unittests/Lex/PPCallbacksTest.cpp index 4f2c158f6a8ab..169734f80df47 100644 --- a/clang/unittests/Lex/PPCallbacksTest.cpp +++ b/clang/unittests/Lex/PPCallbacksTest.cpp @@ -6,7 +6,6 @@ // //===--------------------------------------------------------------===// -#include "clang/Lex/Preprocessor.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/Basic/Diagnostic.h" @@ -19,13 +18,14 @@ #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/ModuleLoader.h" +#include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" #include "clang/Parse/Parser.h" #include "clang/Sema/Sema.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/Path.h" -#include "gtest/gtest.h" #include "llvm/Support/VirtualFileSystem.h" +#include "gtest/gtest.h" using namespace clang; diff --git a/clang/unittests/Lex/PPDependencyDirectivesTest.cpp b/clang/unittests/Lex/PPDependencyDirectivesTest.cpp index 6a62b36241768..7b11fc163f6eb 100644 --- a/clang/unittests/Lex/PPDependencyDirectivesTest.cpp +++ b/clang/unittests/Lex/PPDependencyDirectivesTest.cpp @@ -19,10 +19,10 @@ #include "clang/Lex/ModuleLoader.h" #include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" #include <optional> -#include "llvm/Support/VirtualFileSystem.h" using namespace clang; diff --git a/clang/unittests/Tooling/ASTSelectionTest.cpp b/clang/unittests/Tooling/ASTSelectionTest.cpp index de4b1979f1ebd..d288992a72b99 100644 --- a/clang/unittests/Tooling/ASTSelectionTest.cpp +++ b/clang/unittests/Tooling/ASTSelectionTest.cpp @@ -6,11 +6,11 @@ // //===----------------------------------------------------------------------===// +#include "clang/Tooling/Refactoring/ASTSelection.h" #include "TestVisitor.h" +#include "clang/AST/ExprObjC.h" #include "clang/Basic/SourceManager.h" -#include "clang/Tooling/Refactoring/ASTSelection.h" #include <optional> -#include "clang/AST/ExprObjC.h" using namespace clang; using namespace tooling; diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp index 2453b1f03d802..471c71c701bc7 100644 --- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp @@ -12,6 +12,7 @@ #include "TreeTestBase.h" #include "clang/AST/ASTConsumer.h" +#include "clang/AST/ASTContext.h" #include "clang/Basic/LLVM.h" #include "clang/Driver/CreateInvocationFromArgs.h" #include "clang/Frontend/CompilerInstance.h" @@ -31,7 +32,6 @@ #include "llvm/Support/Error.h" #include "llvm/Testing/Annotations/Annotations.h" #include "gtest/gtest.h" -#include "clang/AST/ASTContext.h" using namespace clang; using namespace clang::syntax; diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.h b/clang/unittests/Tooling/Syntax/TreeTestBase.h index 780778030fb6d..bd9bb49ae7051 100644 --- a/clang/unittests/Tooling/Syntax/TreeTestBase.h +++ b/clang/unittests/Tooling/Syntax/TreeTestBase.h @@ -22,10 +22,10 @@ #include "clang/Tooling/Syntax/Tree.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ScopedPrinter.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Testing/Annotations/Annotations.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "llvm/Support/VirtualFileSystem.h" namespace clang { namespace syntax { >From 50fcaa4b4ec4e1a6cce547207d6a8f8a4f7cb397 Mon Sep 17 00:00:00 2001 From: Chandler Carruth <[email protected]> Date: Fri, 21 Aug 2026 01:53:19 +0000 Subject: [PATCH 3/3] fix include placement more this time Assisted-by: Antigravity with Gemini --- clang-tools-extra/clangd/ParsedAST.cpp | 2 +- clang-tools-extra/clangd/Preamble.h | 3 +-- clang/lib/AST/GlobalDecl.cpp | 1 + clang/lib/Testing/TestAST.cpp | 4 ++-- clang/unittests/Frontend/CompilerInvocationTest.cpp | 4 ++-- clang/unittests/Tooling/ASTSelectionTest.cpp | 1 + 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp index 164ab02abfba7..d84c577c3842e 100644 --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -50,6 +50,7 @@ #include "clang/Frontend/PrecompiledPreamble.h" #include "clang/Lex/Lexer.h" #include "clang/Lex/PPCallbacks.h" +#include "clang/Lex/PreprocessingRecord.h" #include "clang/Lex/Preprocessor.h" #include "clang/Sema/HeuristicResolver.h" #include "clang/Serialization/ASTWriter.h" @@ -80,7 +81,6 @@ #if CLANGD_TIDY_CHECKS #define CLANG_TIDY_DISABLE_STATIC_ANALYZER_CHECKS #include "../clang-tidy/ClangTidyForceLinker.h" -#include "clang/Lex/PreprocessingRecord.h" #endif namespace clang { diff --git a/clang-tools-extra/clangd/Preamble.h b/clang-tools-extra/clangd/Preamble.h index 9802f56d9962a..5513b683748ae 100644 --- a/clang-tools-extra/clangd/Preamble.h +++ b/clang-tools-extra/clangd/Preamble.h @@ -31,6 +31,7 @@ #include "clang-include-cleaner/Record.h" #include "support/Path.h" +#include "clang/AST/ASTContext.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetOptions.h" #include "clang/Frontend/CompilerInvocation.h" @@ -40,8 +41,6 @@ #include "clang/Tooling/CompilationDatabase.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" - -#include "clang/AST/ASTContext.h" #include <cstddef> #include <functional> #include <memory> diff --git a/clang/lib/AST/GlobalDecl.cpp b/clang/lib/AST/GlobalDecl.cpp index f520a45101d13..97746b68b2ad7 100644 --- a/clang/lib/AST/GlobalDecl.cpp +++ b/clang/lib/AST/GlobalDecl.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/AST/GlobalDecl.h" + #include "clang/AST/Attr.h" #include "clang/AST/DeclOpenACC.h" #include "clang/AST/DeclOpenMP.h" diff --git a/clang/lib/Testing/TestAST.cpp b/clang/lib/Testing/TestAST.cpp index 6548a930a40f2..4de02ed2b9042 100644 --- a/clang/lib/Testing/TestAST.cpp +++ b/clang/lib/Testing/TestAST.cpp @@ -7,16 +7,16 @@ //===----------------------------------------------------------------------===// #include "clang/Testing/TestAST.h" + #include "clang/Basic/Diagnostic.h" #include "clang/Basic/LangOptions.h" #include "clang/Frontend/FrontendActions.h" #include "clang/Frontend/TextDiagnostic.h" +#include "clang/Lex/Preprocessor.h" #include "clang/Testing/CommandLineArgs.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/Support/Error.h" #include "llvm/Support/VirtualFileSystem.h" - -#include "clang/Lex/Preprocessor.h" #include "gtest/gtest.h" #include <string> diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index ac881c3a3217c..8c6c1d58f7e59 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -7,15 +7,15 @@ //===----------------------------------------------------------------------===// #include "clang/Frontend/CompilerInvocation.h" + #include "clang/Basic/TargetOptions.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/TextDiagnosticBuffer.h" #include "clang/Lex/PreprocessorOptions.h" #include "clang/Serialization/ModuleFileExtension.h" +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "llvm/Support/VirtualFileSystem.h" #include "llvm/TargetParser/Host.h" - -#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/clang/unittests/Tooling/ASTSelectionTest.cpp b/clang/unittests/Tooling/ASTSelectionTest.cpp index d288992a72b99..b6a56ddba99b8 100644 --- a/clang/unittests/Tooling/ASTSelectionTest.cpp +++ b/clang/unittests/Tooling/ASTSelectionTest.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "clang/Tooling/Refactoring/ASTSelection.h" + #include "TestVisitor.h" #include "clang/AST/ExprObjC.h" #include "clang/Basic/SourceManager.h" _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
