Skip to content

Commit c11647f

Browse files
authored
Merge pull request #61804 from tshortli/break-cycle-frontend-ide
IDE: Move compiler invocation utils to break CMake cycle with Frontend
2 parents e44dd4c + d663c11 commit c11647f

File tree

11 files changed

+450
-404
lines changed

11 files changed

+450
-404
lines changed

include/swift/IDE/Utils.h

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@
1313
#ifndef SWIFT_IDE_UTILS_H
1414
#define SWIFT_IDE_UTILS_H
1515

16-
#include "llvm/ADT/PointerIntPair.h"
17-
#include "swift/Basic/LLVM.h"
1816
#include "swift/AST/ASTNode.h"
17+
#include "swift/AST/ASTPrinter.h"
1918
#include "swift/AST/DeclNameLoc.h"
2019
#include "swift/AST/Effects.h"
2120
#include "swift/AST/Module.h"
22-
#include "swift/AST/ASTPrinter.h"
23-
#include "swift/Frontend/FrontendOptions.h"
21+
#include "swift/Basic/LLVM.h"
2422
#include "swift/IDE/SourceEntityWalker.h"
2523
#include "swift/Parse/Token.h"
24+
#include "llvm/ADT/PointerIntPair.h"
2625
#include "llvm/ADT/StringRef.h"
2726
#include "llvm/Support/VirtualFileSystem.h"
27+
#include <functional>
2828
#include <memory>
2929
#include <string>
30-
#include <functional>
3130
#include <vector>
3231

3332
namespace llvm {
@@ -41,10 +40,8 @@ namespace clang {
4140
}
4241

4342
namespace swift {
44-
class ModuleDecl;
4543
class ValueDecl;
4644
class ASTContext;
47-
class CompilerInvocation;
4845
class SourceFile;
4946
class TypeDecl;
5047
class SourceLoc;
@@ -84,20 +81,6 @@ SourceCompleteResult
8481
isSourceInputComplete(std::unique_ptr<llvm::MemoryBuffer> MemBuf, SourceFileKind SFKind);
8582
SourceCompleteResult isSourceInputComplete(StringRef Text, SourceFileKind SFKind);
8683

87-
bool initCompilerInvocation(
88-
CompilerInvocation &Invocation, ArrayRef<const char *> OrigArgs,
89-
FrontendOptions::ActionType Action, DiagnosticEngine &Diags,
90-
StringRef UnresolvedPrimaryFile,
91-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
92-
const std::string &swiftExecutablePath,
93-
const std::string &runtimeResourcePath,
94-
const std::string &diagnosticDocumentationPath, time_t sessionTimestamp,
95-
std::string &Error);
96-
97-
bool initInvocationByClangArguments(ArrayRef<const char *> ArgList,
98-
CompilerInvocation &Invok,
99-
std::string &Error);
100-
10184
/// Visits all overridden declarations exhaustively from VD, including protocol
10285
/// conformances and clang declarations.
10386
void walkOverriddenDecls(const ValueDecl *VD,

include/swift/IDETool/CompileInstance.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
namespace swift {
2525

2626
class CompilerInstance;
27-
class CompilerInvocation;
2827
class DiagnosticConsumer;
2928

3029
namespace ide {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===--- CompilerInvocation.h ---------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2022 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_IDE_COMPILERINVOCATION_H
14+
#define SWIFT_IDE_COMPILERINVOCATION_H
15+
16+
#include "swift/Frontend/Frontend.h"
17+
18+
namespace swift {
19+
20+
class CompilerInvocation;
21+
22+
namespace ide {
23+
24+
bool initCompilerInvocation(
25+
CompilerInvocation &Invocation, ArrayRef<const char *> OrigArgs,
26+
FrontendOptions::ActionType Action, DiagnosticEngine &Diags,
27+
StringRef UnresolvedPrimaryFile,
28+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
29+
const std::string &swiftExecutablePath,
30+
const std::string &runtimeResourcePath,
31+
const std::string &diagnosticDocumentationPath, time_t sessionTimestamp,
32+
std::string &Error);
33+
34+
bool initInvocationByClangArguments(ArrayRef<const char *> ArgList,
35+
CompilerInvocation &Invok,
36+
std::string &Error);
37+
38+
} // namespace ide
39+
} // namespace swift
40+
41+
#endif // SWIFT_IDE_COMPILERINVOCATION_H

lib/Frontend/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ add_dependencies(swiftFrontend
1919
target_link_libraries(swiftFrontend PRIVATE
2020
swiftAST
2121
swiftConstExtract
22+
swiftIDE
2223
swiftSIL
23-
swiftMigrator
2424
swiftOption
2525
swiftSILGen
2626
swiftSILOptimizer

lib/FrontendTool/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ target_link_libraries(swiftFrontendTool PRIVATE
2020
swiftImmediate
2121
swiftIndex
2222
swiftIRGen
23+
swiftMigrator
2324
swiftOption
2425
swiftPrintAsClang
2526
swiftSerialization

0 commit comments

Comments
 (0)