Skip to content

Commit 27d37ee

Browse files
committed
[clang][NFC] Clean up Sema headers
When various `Sema*.h` and `Sema*.cpp` files were created, cleanup of `Sema.h` includes and forward declarations was left for the later. Now's the time. This commit touches `Sema.h` and Sema components: 1. Unused includes are removed. 2. Unused forward declarations are removed. 3. Missing includes are added (those files are largely IWYU-clean now). 4. Includes were converted into forward declarations where possible. As this commit focuses on headers, all changes to `.cpp` files were minimal, and were aiming at keeping everything buildable.
1 parent 0da2ba8 commit 27d37ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+178
-181
lines changed

clang/include/clang/AST/Attr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class ParamIdx {
372372
static_assert(sizeof(ParamIdx) == sizeof(ParamIdx::SerialType),
373373
"ParamIdx does not fit its serialization type");
374374

375-
#include "clang/AST/Attrs.inc"
375+
#include "clang/AST/Attrs.inc" // IWYU pragma: export
376376

377377
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
378378
const Attr *At) {

clang/include/clang/Sema/Sema.h

Lines changed: 57 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -15,161 +15,143 @@
1515
#define LLVM_CLANG_SEMA_SEMA_H
1616

1717
#include "clang/APINotes/APINotesManager.h"
18-
#include "clang/AST/ASTConcept.h"
1918
#include "clang/AST/ASTFwd.h"
2019
#include "clang/AST/Attr.h"
21-
#include "clang/AST/Availability.h"
22-
#include "clang/AST/ComparisonCategories.h"
20+
#include "clang/AST/AttrIterator.h"
21+
#include "clang/AST/CharUnits.h"
22+
#include "clang/AST/DeclBase.h"
23+
#include "clang/AST/DeclCXX.h"
2324
#include "clang/AST/DeclTemplate.h"
2425
#include "clang/AST/DeclarationName.h"
2526
#include "clang/AST/Expr.h"
2627
#include "clang/AST/ExprCXX.h"
2728
#include "clang/AST/ExprConcepts.h"
28-
#include "clang/AST/ExprObjC.h"
2929
#include "clang/AST/ExternalASTSource.h"
30-
#include "clang/AST/LocInfoType.h"
31-
#include "clang/AST/MangleNumberingContext.h"
32-
#include "clang/AST/NSAPI.h"
33-
#include "clang/AST/PrettyPrinter.h"
30+
#include "clang/AST/NestedNameSpecifier.h"
31+
#include "clang/AST/OperationKinds.h"
3432
#include "clang/AST/StmtCXX.h"
33+
#include "clang/AST/Type.h"
3534
#include "clang/AST/TypeLoc.h"
36-
#include "clang/AST/TypeOrdering.h"
37-
#include "clang/Basic/BitmaskEnum.h"
35+
#include "clang/Basic/AttrSubjectMatchRules.h"
3836
#include "clang/Basic/Builtins.h"
37+
#include "clang/Basic/CapturedStmt.h"
3938
#include "clang/Basic/Cuda.h"
40-
#include "clang/Basic/DarwinSDKInfo.h"
39+
#include "clang/Basic/DiagnosticSema.h"
40+
#include "clang/Basic/ExceptionSpecificationType.h"
4141
#include "clang/Basic/ExpressionTraits.h"
42-
#include "clang/Basic/IdentifierTable.h"
42+
#include "clang/Basic/LLVM.h"
43+
#include "clang/Basic/Lambda.h"
44+
#include "clang/Basic/LangOptions.h"
4345
#include "clang/Basic/Module.h"
4446
#include "clang/Basic/OpenCLOptions.h"
47+
#include "clang/Basic/OperatorKinds.h"
48+
#include "clang/Basic/PartialDiagnostic.h"
4549
#include "clang/Basic/PragmaKinds.h"
50+
#include "clang/Basic/SourceLocation.h"
4651
#include "clang/Basic/Specifiers.h"
4752
#include "clang/Basic/TemplateKinds.h"
53+
#include "clang/Basic/TokenKinds.h"
4854
#include "clang/Basic/TypeTraits.h"
4955
#include "clang/Sema/AnalysisBasedWarnings.h"
5056
#include "clang/Sema/Attr.h"
5157
#include "clang/Sema/CleanupInfo.h"
5258
#include "clang/Sema/DeclSpec.h"
5359
#include "clang/Sema/ExternalSemaSource.h"
5460
#include "clang/Sema/IdentifierResolver.h"
55-
#include "clang/Sema/ObjCMethodList.h"
5661
#include "clang/Sema/Ownership.h"
62+
#include "clang/Sema/ParsedAttr.h"
5763
#include "clang/Sema/Redeclaration.h"
5864
#include "clang/Sema/Scope.h"
5965
#include "clang/Sema/SemaBase.h"
60-
#include "clang/Sema/SemaConcept.h"
61-
#include "clang/Sema/SemaDiagnostic.h"
6266
#include "clang/Sema/TypoCorrection.h"
6367
#include "clang/Sema/Weak.h"
68+
#include "llvm/ADT/APInt.h"
6469
#include "llvm/ADT/ArrayRef.h"
70+
#include "llvm/ADT/BitmaskEnum.h"
71+
#include "llvm/ADT/DenseMap.h"
72+
#include "llvm/ADT/DenseSet.h"
73+
#include "llvm/ADT/FloatingPointMode.h"
74+
#include "llvm/ADT/FoldingSet.h"
75+
#include "llvm/ADT/MapVector.h"
76+
#include "llvm/ADT/PointerIntPair.h"
77+
#include "llvm/ADT/PointerUnion.h"
78+
#include "llvm/ADT/STLExtras.h"
6579
#include "llvm/ADT/STLForwardCompat.h"
80+
#include "llvm/ADT/STLFunctionalExtras.h"
6681
#include "llvm/ADT/SetVector.h"
6782
#include "llvm/ADT/SmallBitVector.h"
6883
#include "llvm/ADT/SmallPtrSet.h"
6984
#include "llvm/ADT/SmallSet.h"
7085
#include "llvm/ADT/SmallVector.h"
7186
#include "llvm/ADT/StringExtras.h"
87+
#include "llvm/ADT/StringMap.h"
7288
#include "llvm/ADT/TinyPtrVector.h"
89+
#include "llvm/Support/Allocator.h"
90+
#include "llvm/Support/Compiler.h"
91+
#include "llvm/Support/Error.h"
92+
#include "llvm/Support/ErrorHandling.h"
93+
#include <cassert>
94+
#include <climits>
95+
#include <cstddef>
96+
#include <cstdint>
7397
#include <deque>
98+
#include <functional>
99+
#include <iterator>
74100
#include <memory>
75101
#include <optional>
76102
#include <string>
77103
#include <tuple>
104+
#include <type_traits>
105+
#include <utility>
78106
#include <vector>
79107

80108
namespace llvm {
81-
class APSInt;
82-
template <typename ValueT, typename ValueInfoT> class DenseSet;
83-
class SmallBitVector;
84109
struct InlineAsmIdentifierInfo;
85110
} // namespace llvm
86111

87112
namespace clang {
88113
class ADLResult;
114+
class APValue;
115+
struct ASTConstraintSatisfaction;
89116
class ASTConsumer;
90117
class ASTContext;
118+
class ASTDeclReader;
91119
class ASTMutationListener;
92120
class ASTReader;
93121
class ASTWriter;
94-
class ArrayType;
95-
class ParsedAttr;
96-
class BindingDecl;
97-
class BlockDecl;
98-
class CapturedDecl;
99122
class CXXBasePath;
100123
class CXXBasePaths;
101-
class CXXBindTemporaryExpr;
102-
typedef SmallVector<CXXBaseSpecifier *, 4> CXXCastPath;
103-
class CXXConstructorDecl;
104-
class CXXConversionDecl;
105-
class CXXDeleteExpr;
106-
class CXXDestructorDecl;
107124
class CXXFieldCollector;
108-
class CXXMemberCallExpr;
109-
class CXXMethodDecl;
110-
class CXXScopeSpec;
111-
class CXXTemporary;
112-
class CXXTryStmt;
113-
class CallExpr;
114-
class ClassTemplateDecl;
115-
class ClassTemplatePartialSpecializationDecl;
116-
class ClassTemplateSpecializationDecl;
117-
class VarTemplatePartialSpecializationDecl;
118125
class CodeCompleteConsumer;
119-
class CodeCompletionAllocator;
120-
class CodeCompletionTUInfo;
121-
class CodeCompletionResult;
122-
class CoroutineBodyStmt;
123-
class Decl;
124-
class DeclAccessPair;
125-
class DeclContext;
126-
class DeclRefExpr;
127-
class DeclaratorDecl;
126+
enum class ComparisonCategoryType : unsigned char;
127+
class ConstraintSatisfaction;
128+
class DarwinSDKInfo;
129+
class DeclGroupRef;
128130
class DeducedTemplateArgument;
131+
struct DeductionFailureInfo;
129132
class DependentDiagnostic;
130-
class DesignatedInitExpr;
131133
class Designation;
132-
class EnableIfAttr;
133-
class EnumConstantDecl;
134-
class Expr;
135-
class ExtVectorType;
136-
class FormatAttr;
137-
class FriendDecl;
138-
class FunctionDecl;
139-
class FunctionProtoType;
140-
class FunctionTemplateDecl;
134+
class IdentifierInfo;
141135
class ImplicitConversionSequence;
142136
typedef MutableArrayRef<ImplicitConversionSequence> ConversionSequenceList;
143-
class InitListExpr;
144137
class InitializationKind;
145138
class InitializationSequence;
146139
class InitializedEntity;
147-
class IntegerLiteral;
148-
class LabelStmt;
149-
class LambdaExpr;
150-
class LangOptions;
140+
enum class LangAS : unsigned int;
151141
class LocalInstantiationScope;
152142
class LookupResult;
153-
class MacroInfo;
143+
class MangleNumberingContext;
154144
typedef ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> ModuleIdPath;
155145
class ModuleLoader;
156146
class MultiLevelTemplateArgumentList;
157-
class NamedDecl;
158-
class ObjCImplementationDecl;
147+
struct NormalizedConstraint;
159148
class ObjCInterfaceDecl;
160149
class ObjCMethodDecl;
161-
class ObjCProtocolDecl;
162150
struct OverloadCandidate;
163151
enum class OverloadCandidateParamOrder : char;
164152
enum OverloadCandidateRewriteKind : unsigned;
165153
class OverloadCandidateSet;
166-
class OverloadExpr;
167-
class ParenListExpr;
168-
class ParmVarDecl;
169154
class Preprocessor;
170-
class PseudoDestructorTypeStorage;
171-
class PseudoObjectExpr;
172-
class QualType;
173155
class SemaAMDGPU;
174156
class SemaARM;
175157
class SemaAVR;
@@ -196,41 +178,19 @@ class SemaSystemZ;
196178
class SemaWasm;
197179
class SemaX86;
198180
class StandardConversionSequence;
199-
class Stmt;
200-
class StringLiteral;
201-
class SwitchStmt;
202181
class TemplateArgument;
203-
class TemplateArgumentList;
204182
class TemplateArgumentLoc;
205-
class TemplateDecl;
206183
class TemplateInstantiationCallback;
207-
class TemplateParameterList;
208184
class TemplatePartialOrderingContext;
209-
class TemplateTemplateParmDecl;
185+
class TemplateSpecCandidateSet;
210186
class Token;
211-
class TypeAliasDecl;
212-
class TypedefDecl;
213-
class TypedefNameDecl;
214-
class TypeLoc;
187+
class TypeConstraint;
215188
class TypoCorrectionConsumer;
216-
class UnqualifiedId;
217-
class UnresolvedLookupExpr;
218-
class UnresolvedMemberExpr;
219189
class UnresolvedSetImpl;
220190
class UnresolvedSetIterator;
221-
class UsingDecl;
222-
class UsingShadowDecl;
223-
class ValueDecl;
224-
class VarDecl;
225-
class VarTemplateSpecializationDecl;
226-
class VisibilityAttr;
227191
class VisibleDeclConsumer;
228-
class IndirectFieldDecl;
229-
struct DeductionFailureInfo;
230-
class TemplateSpecCandidateSet;
231192

232193
namespace sema {
233-
class AccessedEntity;
234194
class BlockScopeInfo;
235195
class Capture;
236196
class CapturedRegionScopeInfo;
@@ -240,8 +200,6 @@ class DelayedDiagnostic;
240200
class DelayedDiagnosticPool;
241201
class FunctionScopeInfo;
242202
class LambdaScopeInfo;
243-
class PossiblyUnreachableDiag;
244-
class RISCVIntrinsicManager;
245203
class SemaPPCallbacks;
246204
class TemplateDeductionInfo;
247205
} // namespace sema

clang/include/clang/Sema/SemaAMDGPU.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
#ifndef LLVM_CLANG_SEMA_SEMAAMDGPU_H
1414
#define LLVM_CLANG_SEMA_SEMAAMDGPU_H
1515

16-
#include "clang/AST/Attr.h"
17-
#include "clang/AST/DeclBase.h"
18-
#include "clang/AST/Expr.h"
19-
#include "clang/Basic/AttributeCommonInfo.h"
20-
#include "clang/Sema/ParsedAttr.h"
16+
#include "clang/AST/ASTFwd.h"
2117
#include "clang/Sema/SemaBase.h"
2218

2319
namespace clang {
20+
class AttributeCommonInfo;
21+
class ParsedAttr;
22+
2423
class SemaAMDGPU : public SemaBase {
2524
public:
2625
SemaAMDGPU(Sema &S);

clang/include/clang/Sema/SemaARM.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313
#ifndef LLVM_CLANG_SEMA_SEMAARM_H
1414
#define LLVM_CLANG_SEMA_SEMAARM_H
1515

16-
#include "clang/AST/DeclBase.h"
17-
#include "clang/AST/Expr.h"
18-
#include "clang/Basic/TargetInfo.h"
16+
#include "clang/AST/ASTFwd.h"
1917
#include "clang/Sema/SemaBase.h"
20-
#include "llvm/ADT/SmallVector.h"
18+
#include "llvm/ADT/StringRef.h"
2119
#include <tuple>
2220

21+
namespace llvm {
22+
template <typename T, unsigned N> class SmallVector;
23+
} // namespace llvm
24+
2325
namespace clang {
2426
class ParsedAttr;
27+
class TargetInfo;
2528

2629
class SemaARM : public SemaBase {
2730
public:
@@ -60,10 +63,10 @@ class SemaARM : public SemaBase {
6063
unsigned ExpectedFieldNum, bool AllowName);
6164
bool BuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall);
6265

63-
bool MveAliasValid(unsigned BuiltinID, StringRef AliasName);
64-
bool CdeAliasValid(unsigned BuiltinID, StringRef AliasName);
65-
bool SveAliasValid(unsigned BuiltinID, StringRef AliasName);
66-
bool SmeAliasValid(unsigned BuiltinID, StringRef AliasName);
66+
bool MveAliasValid(unsigned BuiltinID, llvm::StringRef AliasName);
67+
bool CdeAliasValid(unsigned BuiltinID, llvm::StringRef AliasName);
68+
bool SveAliasValid(unsigned BuiltinID, llvm::StringRef AliasName);
69+
bool SmeAliasValid(unsigned BuiltinID, llvm::StringRef AliasName);
6770
void handleBuiltinAliasAttr(Decl *D, const ParsedAttr &AL);
6871
void handleNewAttr(Decl *D, const ParsedAttr &AL);
6972
void handleCmseNSEntryAttr(Decl *D, const ParsedAttr &AL);

clang/include/clang/Sema/SemaAVR.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#ifndef LLVM_CLANG_SEMA_SEMAAVR_H
1414
#define LLVM_CLANG_SEMA_SEMAAVR_H
1515

16+
#include "clang/AST/ASTFwd.h"
1617
#include "clang/Sema/SemaBase.h"
1718

1819
namespace clang {
19-
class Decl;
2020
class ParsedAttr;
2121

2222
class SemaAVR : public SemaBase {

clang/include/clang/Sema/SemaBPF.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
#ifndef LLVM_CLANG_SEMA_SEMABPF_H
1414
#define LLVM_CLANG_SEMA_SEMABPF_H
1515

16-
#include "clang/AST/Decl.h"
17-
#include "clang/AST/DeclBase.h"
18-
#include "clang/AST/Expr.h"
16+
#include "clang/AST/ASTFwd.h"
1917
#include "clang/Sema/SemaBase.h"
2018

2119
namespace clang {

clang/include/clang/Sema/SemaCUDA.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,34 @@
1313
#ifndef LLVM_CLANG_SEMA_SEMACUDA_H
1414
#define LLVM_CLANG_SEMA_SEMACUDA_H
1515

16-
#include "clang/AST/Decl.h"
17-
#include "clang/AST/DeclCXX.h"
16+
#include "clang/AST/ASTFwd.h"
17+
#include "clang/AST/DeclAccessPair.h"
1818
#include "clang/AST/Redeclarable.h"
1919
#include "clang/Basic/Cuda.h"
20+
#include "clang/Basic/LLVM.h"
2021
#include "clang/Basic/SourceLocation.h"
2122
#include "clang/Sema/Lookup.h"
2223
#include "clang/Sema/Ownership.h"
23-
#include "clang/Sema/ParsedAttr.h"
24-
#include "clang/Sema/Scope.h"
25-
#include "clang/Sema/ScopeInfo.h"
2624
#include "clang/Sema/SemaBase.h"
2725
#include "llvm/ADT/DenseMap.h"
26+
#include "llvm/ADT/DenseMapInfo.h"
27+
#include "llvm/ADT/DenseSet.h"
28+
#include "llvm/ADT/Hashing.h"
2829
#include "llvm/ADT/SmallVector.h"
2930
#include <string>
31+
#include <utility>
3032

3133
namespace clang {
34+
namespace sema {
35+
class Capture;
36+
} // namespace sema
3237

38+
class ASTReader;
39+
class ASTWriter;
3340
enum class CUDAFunctionTarget;
41+
enum class CXXSpecialMemberKind;
42+
class ParsedAttributesView;
43+
class Scope;
3444

3545
class SemaCUDA : public SemaBase {
3646
public:

0 commit comments

Comments
 (0)