Skip to content

Commit

Permalink
Merge pull request swiftlang#61804 from tshortli/break-cycle-frontend…
Browse files Browse the repository at this point in the history
…-ide

IDE: Move compiler invocation utils to break CMake cycle with Frontend
  • Loading branch information
swift-ci authored Oct 30, 2022
2 parents e44dd4c + d663c11 commit c11647f
Show file tree
Hide file tree
Showing 11 changed files with 450 additions and 404 deletions.
25 changes: 4 additions & 21 deletions include/swift/IDE/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@
#ifndef SWIFT_IDE_UTILS_H
#define SWIFT_IDE_UTILS_H

#include "llvm/ADT/PointerIntPair.h"
#include "swift/Basic/LLVM.h"
#include "swift/AST/ASTNode.h"
#include "swift/AST/ASTPrinter.h"
#include "swift/AST/DeclNameLoc.h"
#include "swift/AST/Effects.h"
#include "swift/AST/Module.h"
#include "swift/AST/ASTPrinter.h"
#include "swift/Frontend/FrontendOptions.h"
#include "swift/Basic/LLVM.h"
#include "swift/IDE/SourceEntityWalker.h"
#include "swift/Parse/Token.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <functional>
#include <memory>
#include <string>
#include <functional>
#include <vector>

namespace llvm {
Expand All @@ -41,10 +40,8 @@ namespace clang {
}

namespace swift {
class ModuleDecl;
class ValueDecl;
class ASTContext;
class CompilerInvocation;
class SourceFile;
class TypeDecl;
class SourceLoc;
Expand Down Expand Up @@ -84,20 +81,6 @@ SourceCompleteResult
isSourceInputComplete(std::unique_ptr<llvm::MemoryBuffer> MemBuf, SourceFileKind SFKind);
SourceCompleteResult isSourceInputComplete(StringRef Text, SourceFileKind SFKind);

bool initCompilerInvocation(
CompilerInvocation &Invocation, ArrayRef<const char *> OrigArgs,
FrontendOptions::ActionType Action, DiagnosticEngine &Diags,
StringRef UnresolvedPrimaryFile,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
const std::string &swiftExecutablePath,
const std::string &runtimeResourcePath,
const std::string &diagnosticDocumentationPath, time_t sessionTimestamp,
std::string &Error);

bool initInvocationByClangArguments(ArrayRef<const char *> ArgList,
CompilerInvocation &Invok,
std::string &Error);

/// Visits all overridden declarations exhaustively from VD, including protocol
/// conformances and clang declarations.
void walkOverriddenDecls(const ValueDecl *VD,
Expand Down
1 change: 0 additions & 1 deletion include/swift/IDETool/CompileInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
namespace swift {

class CompilerInstance;
class CompilerInvocation;
class DiagnosticConsumer;

namespace ide {
Expand Down
41 changes: 41 additions & 0 deletions include/swift/IDETool/CompilerInvocation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//===--- CompilerInvocation.h ---------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_IDE_COMPILERINVOCATION_H
#define SWIFT_IDE_COMPILERINVOCATION_H

#include "swift/Frontend/Frontend.h"

namespace swift {

class CompilerInvocation;

namespace ide {

bool initCompilerInvocation(
CompilerInvocation &Invocation, ArrayRef<const char *> OrigArgs,
FrontendOptions::ActionType Action, DiagnosticEngine &Diags,
StringRef UnresolvedPrimaryFile,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
const std::string &swiftExecutablePath,
const std::string &runtimeResourcePath,
const std::string &diagnosticDocumentationPath, time_t sessionTimestamp,
std::string &Error);

bool initInvocationByClangArguments(ArrayRef<const char *> ArgList,
CompilerInvocation &Invok,
std::string &Error);

} // namespace ide
} // namespace swift

#endif // SWIFT_IDE_COMPILERINVOCATION_H
2 changes: 1 addition & 1 deletion lib/Frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ add_dependencies(swiftFrontend
target_link_libraries(swiftFrontend PRIVATE
swiftAST
swiftConstExtract
swiftIDE
swiftSIL
swiftMigrator
swiftOption
swiftSILGen
swiftSILOptimizer
Expand Down
1 change: 1 addition & 0 deletions lib/FrontendTool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ target_link_libraries(swiftFrontendTool PRIVATE
swiftImmediate
swiftIndex
swiftIRGen
swiftMigrator
swiftOption
swiftPrintAsClang
swiftSerialization
Expand Down
Loading

0 comments on commit c11647f

Please sign in to comment.