Skip to content

NFC: Excise ParseableInterface from code #27175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
"Path to the directory that contains Swift tools that are executable on the build machine")

option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
option(SWIFT_ENABLE_MODULE_INTERFACES
"Generate .swiftinterface files alongside .swiftmodule files"
TRUE)

Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/StandaloneOverlay.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ set(SWIFT_NATIVE_CLANG_TOOLS_PATH "${TOOLCHAIN_DIR}/usr/bin" CACHE STRING
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${TOOLCHAIN_DIR}/usr/bin" CACHE STRING
"Path to Swift tools that are executable on the build machine.")

option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
option(SWIFT_ENABLE_MODULE_INTERFACES
"Generate .swiftinterface files alongside .swiftmodule files."
TRUE)

Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ function(_compile_swift_files
set(sibopt_file "${module_base}.O.sib")
set(sibgen_file "${module_base}.sibgen")

if(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES)
if(SWIFT_ENABLE_MODULE_INTERFACES)
set(interface_file "${module_base}.swiftinterface")
list(APPEND swift_module_flags
"-emit-parseable-module-interface-path" "${interface_file}")
"-emit-module-interface-path" "${interface_file}")
endif()

# If we have extra regexp flags, check if we match any of the regexps. If so
Expand Down
9 changes: 6 additions & 3 deletions include/swift/AST/PrintOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,17 @@ struct PrintOptions {
return result;
}

/// Retrieve the set of options suitable for parseable module interfaces.
/// Retrieve the set of options suitable for module interfaces.
///
/// This is a format that will be parsed again later, so the output must be
/// consistent and well-formed.
///
/// \see swift::emitParseableInterface
static PrintOptions printParseableInterfaceFile(bool preferTypeRepr);
/// \see swift::emitSwiftInterface
static PrintOptions printSwiftInterfaceFile(bool preferTypeRepr);

/// Retrieve the set of options suitable for "Generated Interfaces", which
/// are a prettified representation of the public API of a module, to be
/// displayed to users in an editor.
static PrintOptions printModuleInterface();
static PrintOptions printTypeInterface(Type T);

Expand Down
3 changes: 1 addition & 2 deletions include/swift/Basic/FileTypes.def
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ TYPE("dependencies", Dependencies, "d", "")
TYPE("autolink", AutolinkFile, "autolink", "")
TYPE("swiftmodule", SwiftModuleFile, "swiftmodule", "")
TYPE("swiftdoc", SwiftModuleDocFile, "swiftdoc", "")
TYPE("swiftinterface", SwiftParseableInterfaceFile, \
"swiftinterface", "")
TYPE("swiftinterface", SwiftModuleInterfaceFile, "swiftinterface", "")
TYPE("assembly", Assembly, "s", "")
TYPE("raw-sil", RawSIL, "sil", "")
TYPE("raw-sib", RawSIB, "sib", "")
Expand Down
8 changes: 4 additions & 4 deletions include/swift/Basic/SupplementaryOutputPaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ struct SupplementaryOutputPaths {
/// \sa swift::writeTBDFile
std::string TBDPath;

/// The path to which we should emit a parseable module interface, which can
/// The path to which we should emit a module interface, which can
/// be used by a client source file to import this module.
///
/// This format is similar to the binary format used for #ModuleOutputPath,
/// but is intended to be stable across compiler versions.
///
/// Currently only makes sense when the compiler has whole-module knowledge.
///
/// \sa swift::emitParseableInterface
std::string ParseableInterfaceOutputPath;
/// \sa swift::emitSwiftInterface
std::string ModuleInterfaceOutputPath;

SupplementaryOutputPaths() = default;
SupplementaryOutputPaths(const SupplementaryOutputPaths &) = default;
Expand All @@ -132,7 +132,7 @@ struct SupplementaryOutputPaths {
ModuleDocOutputPath.empty() && DependenciesFilePath.empty() &&
ReferenceDependenciesFilePath.empty() &&
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
TBDPath.empty() && ParseableInterfaceOutputPath.empty();
TBDPath.empty() && ModuleInterfaceOutputPath.empty();
}
};
} // namespace swift
Expand Down
8 changes: 4 additions & 4 deletions include/swift/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ class Driver {
StringRef workingDirectory,
CommandOutput *Output) const;

void chooseParseableInterfacePath(Compilation &C, const JobAction *JA,
StringRef workingDirectory,
llvm::SmallString<128> &buffer,
CommandOutput *output) const;
void chooseModuleInterfacePath(Compilation &C, const JobAction *JA,
StringRef workingDirectory,
llvm::SmallString<128> &buffer,
CommandOutput *output) const;

void chooseRemappingOutputPath(Compilation &C, const TypeToPathMap *OutputMap,
CommandOutput *Output) const;
Expand Down
14 changes: 7 additions & 7 deletions include/swift/Frontend/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "swift/ClangImporter/ClangImporter.h"
#include "swift/ClangImporter/ClangImporterOptions.h"
#include "swift/Frontend/FrontendOptions.h"
#include "swift/Frontend/ParseableInterfaceSupport.h"
#include "swift/Frontend/ModuleInterfaceSupport.h"
#include "swift/Migrator/MigratorOptions.h"
#include "swift/Parse/CodeCompletionCallbacks.h"
#include "swift/Parse/Parser.h"
Expand Down Expand Up @@ -78,7 +78,7 @@ class CompilerInvocation {
SILOptions SILOpts;
IRGenOptions IRGenOpts;
TBDGenOptions TBDGenOpts;
ParseableInterfaceOptions ParseableInterfaceOpts;
ModuleInterfaceOptions ModuleInterfaceOpts;
/// The \c SyntaxParsingCache to use when parsing the main file of this
/// invocation
SyntaxParsingCache *MainFileSyntaxParsingCache = nullptr;
Expand Down Expand Up @@ -208,8 +208,8 @@ class CompilerInvocation {
TBDGenOptions &getTBDGenOptions() { return TBDGenOpts; }
const TBDGenOptions &getTBDGenOptions() const { return TBDGenOpts; }

ParseableInterfaceOptions &getParseableInterfaceOptions() { return ParseableInterfaceOpts; }
const ParseableInterfaceOptions &getParseableInterfaceOptions() const { return ParseableInterfaceOpts; }
ModuleInterfaceOptions &getModuleInterfaceOptions() { return ModuleInterfaceOpts; }
const ModuleInterfaceOptions &getModuleInterfaceOptions() const { return ModuleInterfaceOpts; }

ClangImporterOptions &getClangImporterOptions() { return ClangImporterOpts; }
const ClangImporterOptions &getClangImporterOptions() const {
Expand Down Expand Up @@ -353,10 +353,10 @@ class CompilerInvocation {
/// if not in that mode.
std::string getTBDPathForWholeModule() const;

/// ParseableInterfaceOutputPath only makes sense in whole module compilation
/// mode, so return the ParseableInterfaceOutputPath when in that mode and
/// ModuleInterfaceOutputPath only makes sense in whole module compilation
/// mode, so return the ModuleInterfaceOutputPath when in that mode and
/// fail an assert if not in that mode.
std::string getParseableInterfaceOutputPathForWholeModule() const;
std::string getModuleInterfaceOutputPathForWholeModule() const;

SerializationOptions
computeSerializationOptions(const SupplementaryOutputPaths &outs,
Expand Down
4 changes: 2 additions & 2 deletions include/swift/Frontend/FrontendInputsAndOutputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class FrontendInputsAndOutputs {

private:
friend class ArgsToFrontendOptionsConverter;
friend class ParseableInterfaceBuilder;
friend class ModuleInterfaceBuilder;
void setMainAndSupplementaryOutputs(
ArrayRef<std::string> outputFiles,
ArrayRef<SupplementaryOutputPaths> supplementaryOutputs);
Expand Down Expand Up @@ -235,7 +235,7 @@ class FrontendInputsAndOutputs {
bool hasLoadedModuleTracePath() const;
bool hasModuleOutputPath() const;
bool hasModuleDocOutputPath() const;
bool hasParseableInterfaceOutputPath() const;
bool hasModuleInterfaceOutputPath() const;
bool hasTBDPath() const;

bool hasDependencyTrackerPath() const;
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class FrontendOptions {
/// The path to which we should store indexing data, if any.
std::string IndexStorePath;

/// The path to look in when loading a parseable interface file, to see if a
/// The path to look in when loading a module interface file, to see if a
/// binary module has already been built for use by the compiler.
std::string PrebuiltModuleCachePath;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- ParseableInterfaceModuleLoader.h - Loads .swiftinterface files ---===//
//===-------- ModuleInterfaceLoader.h - Loads .swiftinterface files -------===//
//
// This source file is part of the Swift.org open source project
//
Expand All @@ -10,10 +10,10 @@
//
//===----------------------------------------------------------------------===//
///
/// \file This implements the logic for loading and building parseable module
/// \file This implements the logic for loading and building module
/// interfaces.
///
/// === Loading Parseable Modules ===
/// === Loading Module Interfaces ===
///
/// If there is a .swiftinterface file corresponding to a given module name
/// present in the frontend's search paths, then this module loader will look in
Expand Down Expand Up @@ -79,18 +79,19 @@
/// installed 2 forwarding modules. For the other 2 frameworks, we'll have
/// compiled the interfaces and put them in the module cache.
///
/// ┌─────┐
/// ┌─────────────────────────────┤ SDK ├─────────────────────────┐
/// │ ┌────────────────┐ └─────┘ ┌────────────────┐ │
/// │ ┌───────┤ Framework Dirs ├────────┐ ┌┤ Prebuilt Cache ├┐ │
/// │ │ └────────────────┘ │ │└────────────────┘│ │
/// │ │ ┌───┐ ┌───┐ ┌───┐ ┌───┐ │ │ ┌───┐ ┌───┐ │ │
/// │ │ │ I │ │ I │ │ I │ │ I │◀─┼───┼───│ P │ │ P │◀═╗│ │
/// │ │ └───┘ └───┘ └───┘ └───┘ │ │ └───┘ └───┘ ║│ │
/// │ │ ▲ ▲ ▲ │ │ ▲ │ ║│ │
/// │ └────┼───────┼───────┼────────────┘ └─────╫──────┼────╫┘ │
/// │ │ │ └──────────────────────╫──────┘ ║ │
/// └───────┼───────┼──────────────────────────────╫───────────╫──┘
/// ┌─────┐
/// ┌────────────────┤ SDK ├───────────────┐
/// │ └─────┘ │
/// │ ┌────────────────┐ │ ┌────────────────┐
/// │ ┌───────┤ Framework Dirs ├────────┐ │ ┌┤ Prebuilt Cache ├┐
/// │ │ └────────────────┘ │ │ │└────────────────┘│
/// │ │ ┌───┐ ┌───┐ ┌───┐ ┌───┐ │ │ │ ┌───┐ ┌───┐ │
/// │ │ │ I │ │ I │ │ I │ │ I │◀─┼─┼─┼───│ P │ │ P │◀═╗│
/// │ │ └───┘ └───┘ └───┘ └───┘ │ │ │ └───┘ └───┘ ║│
/// │ │ ▲ ▲ ▲ │ │ │ ▲ │ ║│
/// │ └────┼───────┼───────┼────────────┘ │ └─────╫──────┼────╫┘
/// │ │ │ └──────────────┼───────╫──────┘ ║
/// └───────┼───────┼──────────────────────┘ ║ ║
/// │ │ ┌───────────────┐ ║ ║
/// │ ┌────┼───┤ Module Cache ├────────┐ ║ ║
/// │ │ │ └───────────────┘ │ ║ ║
Expand All @@ -103,19 +104,19 @@
///
//===----------------------------------------------------------------------===//

#ifndef SWIFT_FRONTEND_PARSEABLEINTERFACEMODULELOADER_H
#define SWIFT_FRONTEND_PARSEABLEINTERFACEMODULELOADER_H
#ifndef SWIFT_FRONTEND_MODULEINTERFACELOADER_H
#define SWIFT_FRONTEND_MODULEINTERFACELOADER_H

#include "swift/Basic/LLVM.h"
#include "swift/Frontend/ParseableInterfaceSupport.h"
#include "swift/Frontend/ModuleInterfaceSupport.h"
#include "swift/Serialization/SerializedModuleLoader.h"

namespace clang {
class CompilerInstance;
}

namespace unittest {
class ParseableInterfaceModuleLoaderTest;
class ModuleInterfaceLoaderTest;
}

namespace swift {
Expand All @@ -127,9 +128,9 @@ class SearchPathOptions;
/// \c CompilerInstance to convert .swiftinterface files to .swiftmodule
/// files on the fly, caching the resulting .swiftmodules in the module cache
/// directory, and loading the serialized .swiftmodules from there.
class ParseableInterfaceModuleLoader : public SerializedModuleLoaderBase {
friend class unittest::ParseableInterfaceModuleLoaderTest;
explicit ParseableInterfaceModuleLoader(
class ModuleInterfaceLoader : public SerializedModuleLoaderBase {
friend class unittest::ModuleInterfaceLoaderTest;
explicit ModuleInterfaceLoader(
ASTContext &ctx, StringRef cacheDir, StringRef prebuiltCacheDir,
DependencyTracker *tracker, ModuleLoadingMode loadMode,
ArrayRef<std::string> PreferInterfaceForModules,
Expand All @@ -154,13 +155,13 @@ class ParseableInterfaceModuleLoader : public SerializedModuleLoaderBase {
bool isCached(StringRef DepPath) override;

public:
static std::unique_ptr<ParseableInterfaceModuleLoader>
static std::unique_ptr<ModuleInterfaceLoader>
create(ASTContext &ctx, StringRef cacheDir, StringRef prebuiltCacheDir,
DependencyTracker *tracker, ModuleLoadingMode loadMode,
ArrayRef<std::string> PreferInterfaceForModules = {},
bool RemarkOnRebuildFromInterface = false) {
return std::unique_ptr<ParseableInterfaceModuleLoader>(
new ParseableInterfaceModuleLoader(ctx, cacheDir, prebuiltCacheDir,
return std::unique_ptr<ModuleInterfaceLoader>(
new ModuleInterfaceLoader(ctx, cacheDir, prebuiltCacheDir,
tracker, loadMode,
PreferInterfaceForModules,
RemarkOnRebuildFromInterface));
Expand All @@ -186,7 +187,7 @@ class ParseableInterfaceModuleLoader : public SerializedModuleLoaderBase {

/// Extract the specified-or-defaulted -module-cache-path that winds up in
/// the clang importer, for reuse as the .swiftmodule cache path when
/// building a ParseableInterfaceModuleLoader.
/// building a ModuleInterfaceLoader.
std::string
getModuleCachePathFromClang(const clang::CompilerInstance &Instance);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- ParseableInterfaceSupport.h - swiftinterface files -----*- C++ -*-===//
//===------ ModuleInterfaceSupport.h - swiftinterface files -----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
Expand All @@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_FRONTEND_PARSEABLEINTERFACESUPPORT_H
#define SWIFT_FRONTEND_PARSEABLEINTERFACESUPPORT_H
#ifndef SWIFT_FRONTEND_MODULEINTERFACESUPPORT_H
#define SWIFT_FRONTEND_MODULEINTERFACESUPPORT_H

#include "swift/Basic/LLVM.h"
#include "swift/Basic/Version.h"
Expand All @@ -26,23 +26,23 @@ namespace swift {
class ModuleDecl;

/// Options for controlling the generation of the .swiftinterface output.
struct ParseableInterfaceOptions {
struct ModuleInterfaceOptions {
/// Should we prefer printing TypeReprs when writing out types in a module
/// interface, or should we fully-qualify them?
bool PreserveTypesAsWritten = false;

/// Copy of all the command-line flags passed at .swiftinterface
/// generation time, re-applied to CompilerInvocation when reading
/// back .swiftinterface and reconstructing .swiftmodule.
std::string ParseableInterfaceFlags;
std::string Flags;
};

extern version::Version InterfaceFormatVersion;

llvm::Regex getSwiftInterfaceFormatVersionRegex();
llvm::Regex getSwiftInterfaceModuleFlagsRegex();

/// Emit a stable, parseable interface for \p M, which can be used by a client
/// Emit a stable module interface for \p M, which can be used by a client
/// source file to import this module, subject to options given by \p Opts.
///
/// Unlike a serialized module, the textual format generated by
Expand All @@ -55,9 +55,9 @@ llvm::Regex getSwiftInterfaceModuleFlagsRegex();
/// \return true if an error occurred
///
/// \sa swift::serialize
bool emitParseableInterface(raw_ostream &out,
ParseableInterfaceOptions const &Opts,
ModuleDecl *M);
bool emitSwiftInterface(raw_ostream &out,
ModuleInterfaceOptions const &Opts,
ModuleDecl *M);

} // end namespace swift

Expand Down
2 changes: 1 addition & 1 deletion include/swift/Parse/Lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Lexer {
Token NextToken;

/// The kind of source we're lexing. This either enables special behavior for
/// parseable interfaces, or enables things like the 'sil' keyword if lexing
/// module interfaces, or enables things like the 'sil' keyword if lexing
/// a .sil file.
const LexerMode LexMode;

Expand Down
2 changes: 1 addition & 1 deletion include/swift/Serialization/SerializationOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace swift {
StringRef GroupInfoPath;
StringRef ImportedHeader;
StringRef ModuleLinkName;
StringRef ParseableInterface;
StringRef ModuleInterface;
ArrayRef<std::string> ExtraClangOptions;

/// Describes a single-file dependency for this module, along with the
Expand Down
8 changes: 4 additions & 4 deletions include/swift/Serialization/SerializedModuleLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ namespace swift {
class ModuleFile;
class LazyResolver;

/// Spceifies how to load modules when both a parseable interface and serialized
/// Spceifies how to load modules when both a module interface and serialized
/// AST are present, or whether to disallow one format or the other altogether.
enum class ModuleLoadingMode {
PreferParseable,
PreferInterface,
PreferSerialized,
OnlyParseable,
OnlyInterface,
OnlySerialized
};

/// Common functionality shared between \c SerializedModuleLoader and
/// \c ParseableInterfaceModuleLoader.
/// \c ModuleInterfaceLoader.
class SerializedModuleLoaderBase : public ModuleLoader {
/// A { module, generation # } pair.
using LoadedModulePair = std::pair<std::unique_ptr<ModuleFile>, unsigned>;
Expand Down
Loading