Skip to content

Commit 175b409

Browse files
committed
AST: Fewer headers include Expr.h, Module.h, Stmt.h
1 parent 3753207 commit 175b409

23 files changed

+59
-29
lines changed

include/swift/AST/Stmt.h

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "swift/AST/Availability.h"
2121
#include "swift/AST/AvailabilitySpec.h"
2222
#include "swift/AST/ASTNode.h"
23-
#include "swift/AST/Expr.h"
2423
#include "swift/AST/IfConfigClause.h"
2524
#include "swift/AST/TypeAlignments.h"
2625
#include "swift/Basic/NullablePtr.h"

include/swift/Frontend/FrontendInputsAndOutputs.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#ifndef SWIFT_FRONTEND_FRONTENDINPUTS_H
1414
#define SWIFT_FRONTEND_FRONTENDINPUTS_H
1515

16-
#include "swift/AST/Module.h"
1716
#include "swift/Basic/PrimarySpecificPaths.h"
1817
#include "swift/Basic/SupplementaryOutputPaths.h"
1918
#include "swift/Frontend/InputFile.h"
@@ -29,6 +28,8 @@ class MemoryBuffer;
2928

3029
namespace swift {
3130

31+
class DiagnosticEngine;
32+
3233
/// Information about all the inputs and outputs to the frontend.
3334

3435
class FrontendInputsAndOutputs {

include/swift/Frontend/FrontendOptions.h

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#ifndef SWIFT_FRONTEND_FRONTENDOPTIONS_H
1414
#define SWIFT_FRONTEND_FRONTENDOPTIONS_H
1515

16-
#include "swift/AST/Module.h"
1716
#include "swift/Frontend/FrontendInputsAndOutputs.h"
1817
#include "swift/Frontend/InputFile.h"
1918
#include "llvm/ADT/Hashing.h"

include/swift/IRGen/Linking.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SWIFT_IRGEN_LINKING_H
1515

1616
#include "swift/AST/Decl.h"
17+
#include "swift/AST/Module.h"
1718
#include "swift/AST/ProtocolAssociations.h"
1819
#include "swift/AST/ProtocolConformance.h"
1920
#include "swift/AST/Types.h"

include/swift/Parse/Parser.h

+9-11
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919

2020
#include "swift/AST/ASTContext.h"
2121
#include "swift/AST/ASTNode.h"
22-
#include "swift/AST/DiagnosticsParse.h"
2322
#include "swift/AST/Expr.h"
23+
#include "swift/AST/DiagnosticsParse.h"
2424
#include "swift/AST/LayoutConstraint.h"
25-
#include "swift/AST/Module.h"
2625
#include "swift/AST/Pattern.h"
2726
#include "swift/AST/Stmt.h"
2827
#include "swift/Basic/OptionSet.h"
@@ -42,17 +41,18 @@ namespace llvm {
4241
}
4342

4443
namespace swift {
44+
class CodeCompletionCallbacks;
4545
class DefaultArgumentInitializer;
46+
class DelayedParsingCallbacks;
4647
class DiagnosticEngine;
48+
class Expr;
4749
class Lexer;
48-
class ScopeInfo;
49-
struct TypeLoc;
50-
class TupleType;
50+
class PersistentParserState;
5151
class SILParserTUStateBase;
52+
class ScopeInfo;
5253
class SourceManager;
53-
class PersistentParserState;
54-
class CodeCompletionCallbacks;
55-
class DelayedParsingCallbacks;
54+
class TupleType;
55+
struct TypeLoc;
5656

5757
struct EnumElementInfo;
5858

@@ -181,9 +181,7 @@ class Parser {
181181
return L->isCodeCompletion() && !CodeCompletion;
182182
}
183183

184-
bool allowTopLevelCode() const {
185-
return SF.isScriptMode();
186-
}
184+
bool allowTopLevelCode() const;
187185

188186
const std::vector<Token> &getSplitTokens() { return SplitTokens; }
189187

include/swift/SIL/SILFunction.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
#ifndef SWIFT_SIL_SILFUNCTION_H
1818
#define SWIFT_SIL_SILFUNCTION_H
1919

20+
#include "swift/AST/ASTNode.h"
2021
#include "swift/AST/ResilienceExpansion.h"
2122
#include "swift/Basic/ProfileCounter.h"
2223
#include "swift/SIL/SILBasicBlock.h"
2324
#include "swift/SIL/SILDebugScope.h"
2425
#include "swift/SIL/SILLinkage.h"
2526
#include "swift/SIL/SILPrintContext.h"
26-
#include "swift/SIL/SILProfiler.h"
2727
#include "llvm/ADT/StringMap.h"
2828

2929
/// The symbol name used for the program entry point function.
@@ -35,6 +35,7 @@ namespace swift {
3535
class ASTContext;
3636
class SILInstruction;
3737
class SILModule;
38+
class SILProfiler;
3839

3940
enum IsBare_t { IsNotBare, IsBare };
4041
enum IsTransparent_t { IsNotTransparent, IsTransparent };
@@ -266,10 +267,7 @@ class SILFunction
266267
Profiler = InheritedProfiler;
267268
}
268269

269-
void createProfiler(ASTNode Root, ForDefinition_t forDefinition) {
270-
assert(!Profiler && "Function already has a profiler");
271-
Profiler = SILProfiler::create(Module, forDefinition, Root);
272-
}
270+
void createProfiler(ASTNode Root, ForDefinition_t forDefinition);
273271

274272
void discardProfiler() { Profiler = nullptr; }
275273

include/swift/SIL/SILModule.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "swift/AST/ASTContext.h"
2121
#include "swift/AST/Builtins.h"
22-
#include "swift/AST/Module.h"
2322
#include "swift/AST/SILLayout.h"
2423
#include "swift/AST/SILOptions.h"
2524
#include "swift/Basic/LangOptions.h"
@@ -58,8 +57,10 @@ class Output;
5857
namespace swift {
5958
class AnyFunctionType;
6059
class ASTContext;
60+
class FileUnit;
6161
class FuncDecl;
6262
class KeyPathPattern;
63+
class ModuleDecl;
6364
class SILUndef;
6465
class SourceFile;
6566
class SerializedSILLoader;
@@ -345,15 +346,12 @@ class SILModule {
345346
/// later parse SIL bodies directly into, without converting from an AST.
346347
static std::unique_ptr<SILModule>
347348
createEmptyModule(ModuleDecl *M, SILOptions &Options,
348-
bool WholeModule = false) {
349-
return std::unique_ptr<SILModule>(
350-
new SILModule(M, Options, M, WholeModule));
351-
}
349+
bool WholeModule = false);
352350

353351
/// Get the Swift module associated with this SIL module.
354352
ModuleDecl *getSwiftModule() const { return TheSwiftModule; }
355353
/// Get the AST context used for type uniquing etc. by this SIL module.
356-
ASTContext &getASTContext() const { return TheSwiftModule->getASTContext(); }
354+
ASTContext &getASTContext() const;
357355
SourceManager &getSourceManager() const { return getASTContext().SourceMgr; }
358356

359357
/// Get the Swift DeclContext associated with this SIL module.

include/swift/SIL/SILProfiler.h

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#define SWIFT_SIL_PROFILER_H
2020

2121
#include "swift/AST/ASTNode.h"
22-
#include "swift/AST/Stmt.h"
2322
#include "swift/Basic/ProfileCounter.h"
2423
#include "swift/SIL/SILAllocated.h"
2524
#include "swift/SIL/SILDeclRef.h"

lib/Frontend/ArgsToFrontendInputsConverter.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#include "swift/AST/DiagnosticConsumer.h"
1717
#include "swift/AST/DiagnosticEngine.h"
1818
#include "swift/Frontend/FrontendOptions.h"
19+
#include "llvm/ADT/SetVector.h"
1920
#include "llvm/Option/ArgList.h"
21+
#include <set>
2022

2123
namespace swift {
2224

lib/Parse/Parser.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "swift/Subsystems.h"
1919
#include "swift/AST/ASTWalker.h"
2020
#include "swift/AST/DiagnosticsParse.h"
21+
#include "swift/AST/Module.h"
2122
#include "swift/AST/PrettyStackTrace.h"
2223
#include "swift/Basic/Defer.h"
2324
#include "swift/Basic/SourceManager.h"
@@ -500,6 +501,10 @@ Parser::~Parser() {
500501
delete SyntaxContext;
501502
}
502503

504+
bool Parser::allowTopLevelCode() const {
505+
return SF.isScriptMode();
506+
}
507+
503508
const Token &Parser::peekToken() {
504509
return L->peekNextToken();
505510
}

lib/SIL/Bridging.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/AST/Decl.h"
2222
#include "swift/AST/DiagnosticsSIL.h"
2323
#include "swift/AST/ProtocolConformance.h"
24+
#include "swift/AST/Module.h"
2425
#include "clang/AST/DeclObjC.h"
2526
#include "llvm/Support/Debug.h"
2627
#include "llvm/Support/ErrorHandling.h"

lib/SIL/DynamicCasts.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "swift/AST/Module.h"
1314
#include "swift/AST/Types.h"
1415
#include "swift/SIL/SILArgument.h"
1516
#include "swift/SIL/SILBuilder.h"

lib/SIL/SILFunction.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "swift/SIL/SILModule.h"
14-
#include "swift/SIL/SILFunction.h"
13+
#include "swift/SIL/SILArgument.h"
1514
#include "swift/SIL/SILBasicBlock.h"
15+
#include "swift/SIL/SILFunction.h"
1616
#include "swift/SIL/SILInstruction.h"
17-
#include "swift/SIL/SILArgument.h"
17+
#include "swift/SIL/SILModule.h"
18+
#include "swift/SIL/SILProfiler.h"
1819
#include "swift/SIL/CFG.h"
1920
#include "swift/SIL/PrettyStackTrace.h"
2021
#include "swift/AST/GenericEnvironment.h"
@@ -139,6 +140,11 @@ SILFunction::~SILFunction() {
139140
"Function cannot be deleted while function_ref's still exist");
140141
}
141142

143+
void SILFunction::createProfiler(ASTNode Root, ForDefinition_t forDefinition) {
144+
assert(!Profiler && "Function already has a profiler");
145+
Profiler = SILProfiler::create(Module, forDefinition, Root);
146+
}
147+
142148
bool SILFunction::hasForeignBody() const {
143149
if (!hasClangNode()) return false;
144150
return SILDeclRef::isClangGenerated(getClangNode());

lib/SIL/SILFunctionType.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "swift/AST/DiagnosticsSIL.h"
2323
#include "swift/AST/ForeignInfo.h"
2424
#include "swift/AST/GenericEnvironment.h"
25+
#include "swift/AST/Module.h"
2526
#include "swift/AST/ProtocolConformance.h"
2627
#include "swift/Basic/StringExtras.h"
2728
#include "swift/SIL/SILModule.h"

lib/SIL/SILModule.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ SILModule::~SILModule() {
113113
F.dropAllReferences();
114114
}
115115

116+
std::unique_ptr<SILModule>
117+
SILModule::createEmptyModule(ModuleDecl *M, SILOptions &Options,
118+
bool WholeModule) {
119+
return std::unique_ptr<SILModule>(
120+
new SILModule(M, Options, M, WholeModule));
121+
}
122+
123+
ASTContext &SILModule::getASTContext() const {
124+
return TheSwiftModule->getASTContext();
125+
}
126+
116127
void *SILModule::allocate(unsigned Size, unsigned Align) const {
117128
if (getASTContext().LangOpts.UseMalloc)
118129
return AlignedAlloc(Size, Align);

lib/SIL/SILProfiler.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include "swift/SIL/SILProfiler.h"
1414
#include "swift/AST/ASTWalker.h"
1515
#include "swift/AST/Decl.h"
16+
#include "swift/AST/Expr.h"
17+
#include "swift/AST/Module.h"
18+
#include "swift/AST/Stmt.h"
1619
#include "swift/Parse/Lexer.h"
1720
#include "swift/SIL/FormalLinkage.h"
1821
#include "swift/SIL/SILModule.h"

lib/SILGen/SILGen.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "swift/SIL/PrettyStackTrace.h"
3030
#include "swift/SIL/SILArgument.h"
3131
#include "swift/SIL/SILDebugScope.h"
32+
#include "swift/SIL/SILProfiler.h"
3233
#include "swift/Subsystems.h"
3334
#include "llvm/ProfileData/InstrProfReader.h"
3435
#include "llvm/Support/Debug.h"

lib/SILGen/SILGenFunction.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "Scope.h"
2121
#include "swift/AST/Initializer.h"
2222
#include "swift/SIL/SILArgument.h"
23+
#include "swift/SIL/SILProfiler.h"
2324
#include "swift/SIL/SILUndef.h"
2425

2526
using namespace swift;

lib/SILOptimizer/Transforms/Outliner.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define DEBUG_TYPE "sil-outliner"
1414

1515
#include "swift/AST/ASTMangler.h"
16+
#include "swift/AST/Module.h"
1617
#include "swift/AST/ProtocolConformance.h"
1718
#include "swift/AST/Types.h"
1819
#include "swift/Demangling/Demangler.h"

lib/SILOptimizer/Transforms/PerformanceInliner.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#define DEBUG_TYPE "sil-inliner"
14+
#include "swift/AST/Module.h"
1415
#include "swift/SIL/OptimizationRemark.h"
1516
#include "swift/SILOptimizer/Analysis/SideEffectAnalysis.h"
1617
#include "swift/SILOptimizer/PassManager/Passes.h"

lib/SILOptimizer/Utils/CastOptimizer.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "swift/SILOptimizer/Utils/CastOptimizer.h"
2020
#include "swift/AST/GenericSignature.h"
21+
#include "swift/AST/Module.h"
2122
#include "swift/AST/SubstitutionMap.h"
2223
#include "swift/SIL/BasicBlockUtils.h"
2324
#include "swift/SIL/DebugUtils.h"

lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "swift/AST/Module.h"
1314
#include "swift/SILOptimizer/Utils/PerformanceInlinerUtils.h"
1415
#include "swift/Strings.h"
1516

lib/Sema/SourceLoader.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "swift/Sema/SourceLoader.h"
1919
#include "swift/Subsystems.h"
2020
#include "swift/AST/DiagnosticsSema.h"
21+
#include "swift/AST/Module.h"
2122
#include "swift/Parse/DelayedParsingCallbacks.h"
2223
#include "swift/Parse/PersistentParserState.h"
2324
#include "swift/Basic/SourceManager.h"

0 commit comments

Comments
 (0)