Rename "textual interface" to "parseable interface" (#19713)

We already have something called "module interfaces" -- it's the
generated interface view that you can see in Xcode, the interface
that's meant for developers using a library. Of course, that's also a
textual format. To reduce confusion, rename the new module stability
feature to "parseable [module] interfaces".
This commit is contained in:
Jordan Rose
2018-10-04 17:49:55 -07:00
committed by GitHub
parent 01c4c3c12b
commit 73d5ebaad2
55 changed files with 75 additions and 72 deletions

View File

@@ -121,7 +121,7 @@ ERROR(error_mode_cannot_emit_module,none,
ERROR(error_mode_cannot_emit_module_doc,none,
"this mode does not support emitting module documentation files", ())
ERROR(error_mode_cannot_emit_interface,none,
"this mode does not support emitting textual interface files", ())
"this mode does not support emitting parseable interface files", ())
WARNING(emit_reference_dependencies_without_primary_file,none,
"ignoring -emit-reference-dependencies (requires -primary-file)", ())
@@ -260,8 +260,8 @@ ERROR(error_invalid_debug_prefix_map, none,
ERROR(invalid_vfs_overlay_file,none,
"invalid virtual overlay file '%0'", (StringRef))
WARNING(textual_interface_scoped_import_unsupported,none,
"scoped imports are not yet supported in textual module interfaces",
WARNING(parseable_interface_scoped_import_unsupported,none,
"scoped imports are not yet supported in parseable module interfaces",
())
#ifndef DIAG_NO_UNDEF

View File

@@ -449,13 +449,13 @@ struct PrintOptions {
return result;
}
/// Retrieve the set of options suitable for stable textual interfaces.
/// Retrieve the set of options suitable for parseable module interfaces.
///
/// This is a format that will be parsed again later, so the output must be
/// consistent and well-formed.
///
/// \see swift::emitModuleInterface
static PrintOptions printTextualInterfaceFile();
/// \see swift::emitParseableInterface
static PrintOptions printParseableInterfaceFile();
static PrintOptions printModuleInterface();
static PrintOptions printTypeInterface(Type T);

View File

@@ -113,16 +113,16 @@ struct SupplementaryOutputPaths {
/// \sa swift::writeTBDFile
std::string TBDPath;
/// The path to which we should emit a textual module interface, which can be
/// used by a client source file to import this module.
/// The path to which we should emit a parseable 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::emitModuleInterface
std::string ModuleInterfaceOutputPath;
/// \sa swift::emitParseableInterface
std::string ParseableInterfaceOutputPath;
SupplementaryOutputPaths() = default;
SupplementaryOutputPaths(const SupplementaryOutputPaths &) = default;
@@ -132,7 +132,7 @@ struct SupplementaryOutputPaths {
ModuleDocOutputPath.empty() && DependenciesFilePath.empty() &&
ReferenceDependenciesFilePath.empty() &&
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
TBDPath.empty() && ModuleInterfaceOutputPath.empty();
TBDPath.empty() && ParseableInterfaceOutputPath.empty();
}
};
} // namespace swift

View File

@@ -341,10 +341,10 @@ private:
StringRef workingDirectory,
CommandOutput *Output) const;
void chooseTextualInterfacePath(Compilation &C, const JobAction *JA,
StringRef workingDirectory,
llvm::SmallString<128> &buffer,
CommandOutput *output) const;
void chooseParseableInterfacePath(Compilation &C, const JobAction *JA,
StringRef workingDirectory,
llvm::SmallString<128> &buffer,
CommandOutput *output) const;
void chooseRemappingOutputPath(Compilation &C, const TypeToPathMap *OutputMap,
CommandOutput *Output) const;

View File

@@ -338,10 +338,10 @@ public:
/// if not in that mode.
std::string getTBDPathForWholeModule() const;
/// 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 getModuleInterfaceOutputPathForWholeModule() const;
/// ParseableInterfaceOutputPath only makes sense in whole module compilation
/// mode, so return the ParseableInterfaceOutputPath when in that mode and
/// fail an assert if not in that mode.
std::string getParseableInterfaceOutputPathForWholeModule() const;
};
/// A class which manages the state and execution of the compiler.

View File

@@ -235,7 +235,7 @@ public:
bool hasLoadedModuleTracePath() const;
bool hasModuleOutputPath() const;
bool hasModuleDocOutputPath() const;
bool hasModuleInterfaceOutputPath() const;
bool hasParseableInterfaceOutputPath() const;
bool hasTBDPath() const;
bool hasDependencyTrackerPath() const;

View File

@@ -65,7 +65,7 @@ def emit_fixits_path
def emit_interface_path
: Separate<["-"], "emit-interface-path">, MetaVarName<"<path>">,
HelpText<"Output textual interface file to <path>">;
HelpText<"Output parseable interface file to <path>">;
def tbd_install_name
: Separate<["-"], "tbd-install_name">, MetaVarName<"<path>">,

View File

@@ -302,7 +302,7 @@ def emit_module_path_EQ : Joined<["-"], "emit-module-path=">,
def experimental_emit_interface : Flag<["-"], "experimental-emit-interface">,
Flags<[NoInteractiveOption, HelpHidden]>,
HelpText<"Test out the textual interfaces feature">;
HelpText<"Test out the parseable interfaces feature">;
def emit_objc_header : Flag<["-"], "emit-objc-header">,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>,

View File

@@ -79,7 +79,7 @@ static bool contributesToParentTypeStorage(const AbstractStorageDecl *ASD) {
return !ND->isResilient() && ASD->hasStorage() && !ASD->isStatic();
}
PrintOptions PrintOptions::printTextualInterfaceFile() {
PrintOptions PrintOptions::printParseableInterfaceFile() {
PrintOptions result;
result.PrintLongAttrsOnSeparateLines = true;
result.TypeDefinitions = true;
@@ -100,7 +100,7 @@ PrintOptions PrintOptions::printTextualInterfaceFile() {
printer << " " << AFD->getInlinableBodyText(scratch);
};
class ShouldPrintForTextualInterface : public ShouldPrintChecker {
class ShouldPrintForParseableInterface : public ShouldPrintChecker {
bool shouldPrint(const Decl *D, const PrintOptions &options) override {
// Skip anything that isn't 'public' or '@usableFromInline'.
if (auto *VD = dyn_cast<ValueDecl>(D)) {
@@ -143,7 +143,7 @@ PrintOptions PrintOptions::printTextualInterfaceFile() {
}
};
result.CurrentPrintabilityChecker =
std::make_shared<ShouldPrintForTextualInterface>();
std::make_shared<ShouldPrintForParseableInterface>();
// FIXME: We don't really need 'public' on everything; we could just change
// the default to 'public' and mark the 'internal' things.

View File

@@ -2474,7 +2474,7 @@ Job *Driver::buildJobsForAction(Compilation &C, const JobAction *JA,
Output.get());
if (C.getArgs().hasArg(options::OPT_experimental_emit_interface))
chooseTextualInterfacePath(C, JA, workingDirectory, Buf, Output.get());
chooseParseableInterfacePath(C, JA, workingDirectory, Buf, Output.get());
if (C.getArgs().hasArg(options::OPT_update_code) && isa<CompileJobAction>(JA))
chooseRemappingOutputPath(C, OutputMap, Output.get());
@@ -2772,7 +2772,7 @@ void Driver::chooseRemappingOutputPath(Compilation &C,
}
}
void Driver::chooseTextualInterfacePath(Compilation &C, const JobAction *JA,
void Driver::chooseParseableInterfacePath(Compilation &C, const JobAction *JA,
StringRef workingDirectory,
llvm::SmallString<128> &buffer,
CommandOutput *output) const {

View File

@@ -496,7 +496,7 @@ bool ArgsToFrontendOptionsConverter::checkUnusedSupplementaryOutputPaths()
return true;
}
if (!FrontendOptions::canActionEmitInterface(Opts.RequestedAction) &&
Opts.InputsAndOutputs.hasModuleInterfaceOutputPath()) {
Opts.InputsAndOutputs.hasParseableInterfaceOutputPath()) {
Diags.diagnose(SourceLoc(), diag::error_mode_cannot_emit_interface);
return true;
}

View File

@@ -294,13 +294,13 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
auto loadedModuleTrace = getSupplementaryFilenamesFromArguments(
options::OPT_emit_loaded_module_trace_path);
auto TBD = getSupplementaryFilenamesFromArguments(options::OPT_emit_tbd_path);
auto moduleInterfaceOutput = getSupplementaryFilenamesFromArguments(
auto parseableInterfaceOutput = getSupplementaryFilenamesFromArguments(
options::OPT_emit_interface_path);
if (!objCHeaderOutput || !moduleOutput || !moduleDocOutput ||
!dependenciesFile || !referenceDependenciesFile ||
!serializedDiagnostics || !fixItsOutput || !loadedModuleTrace || !TBD ||
!moduleInterfaceOutput) {
!parseableInterfaceOutput) {
return None;
}
std::vector<SupplementaryOutputPaths> result;
@@ -318,7 +318,7 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
sop.FixItsOutputPath = (*fixItsOutput)[i];
sop.LoadedModuleTracePath = (*loadedModuleTrace)[i];
sop.TBDPath = (*TBD)[i];
sop.ModuleInterfaceOutputPath = (*moduleInterfaceOutput)[i];
sop.ParseableInterfaceOutputPath = (*parseableInterfaceOutput)[i];
result.push_back(sop);
}
@@ -395,7 +395,8 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
defaultSupplementaryOutputPathExcludingExtension);
// There is no non-path form of -emit-interface-path
auto moduleInterfaceOutputPath = pathsFromArguments.ModuleInterfaceOutputPath;
auto parseableInterfaceOutputPath =
pathsFromArguments.ParseableInterfaceOutputPath;
ID emitModuleOption;
std::string moduleExtension;
@@ -418,7 +419,7 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
sop.FixItsOutputPath = fixItsOutputPath;
sop.LoadedModuleTracePath = loadedModuleTracePath;
sop.TBDPath = tbdPath;
sop.ModuleInterfaceOutputPath = moduleInterfaceOutputPath;
sop.ParseableInterfaceOutputPath = parseableInterfaceOutputPath;
return sop;
}
@@ -493,7 +494,8 @@ createFromTypeToPathMap(const TypeToPathMap *map) {
{file_types::TY_SerializedDiagnostics, paths.SerializedDiagnosticsPath},
{file_types::TY_ModuleTrace, paths.LoadedModuleTracePath},
{file_types::TY_TBD, paths.TBDPath},
{file_types::TY_SwiftModuleInterfaceFile,paths.ModuleInterfaceOutputPath}
{file_types::TY_SwiftModuleInterfaceFile,
paths.ParseableInterfaceOutputPath}
};
for (const std::pair<file_types::ID, std::string &> &typeAndString :
typesAndStrings) {

View File

@@ -110,12 +110,12 @@ std::string CompilerInvocation::getTBDPathForWholeModule() const {
}
std::string
CompilerInvocation::getModuleInterfaceOutputPathForWholeModule() const {
CompilerInvocation::getParseableInterfaceOutputPathForWholeModule() const {
assert(getFrontendOptions().InputsAndOutputs.isWholeModule() &&
"ModuleInterfaceOutputPath only makes sense when the whole module can "
"be seen");
"ParseableInterfaceOutputPath only makes sense when the whole module "
"can be seen");
return getPrimarySpecificPathsForAtMostOnePrimary()
.SupplementaryOutputs.ModuleInterfaceOutputPath;
.SupplementaryOutputs.ParseableInterfaceOutputPath;
}
void CompilerInstance::createSILModule() {

View File

@@ -435,10 +435,10 @@ bool FrontendInputsAndOutputs::hasModuleDocOutputPath() const {
return outs.ModuleDocOutputPath;
});
}
bool FrontendInputsAndOutputs::hasModuleInterfaceOutputPath() const {
bool FrontendInputsAndOutputs::hasParseableInterfaceOutputPath() const {
return hasSupplementaryOutputPath(
[](const SupplementaryOutputPaths &outs) -> const std::string & {
return outs.ModuleInterfaceOutputPath;
return outs.ParseableInterfaceOutputPath;
});
}
bool FrontendInputsAndOutputs::hasTBDPath() const {

View File

@@ -124,7 +124,7 @@ void FrontendOptions::forAllOutputPaths(
input.getPrimarySpecificPaths().SupplementaryOutputs;
const std::string *outputs[] = {&outs.ModuleOutputPath,
&outs.ModuleDocOutputPath,
&outs.ModuleInterfaceOutputPath,
&outs.ParseableInterfaceOutputPath,
&outs.ObjCHeaderOutputPath};
for (const std::string *next : outputs) {
if (!next->empty())

View File

@@ -3,7 +3,7 @@ add_swift_library(swiftFrontendTool STATIC
ImportedModules.cpp
ReferenceDependencies.cpp
TBD.cpp
TextualInterfaceGeneration.cpp
ParseableInterfaceGeneration.cpp
DEPENDS
swift-syntax-generated-headers SwiftOptions
LINK_LIBRARIES

View File

@@ -24,7 +24,7 @@
#include "ImportedModules.h"
#include "ReferenceDependencies.h"
#include "TBD.h"
#include "TextualInterfaceGeneration.h"
#include "ParseableInterfaceGeneration.h"
#include "swift/Subsystems.h"
#include "swift/AST/ASTScope.h"
@@ -356,19 +356,20 @@ static bool printAsObjCIfNeeded(StringRef outputPath, ModuleDecl *M,
});
}
/// Prints the stable textual interface for \p M to \p outputPath.
/// Prints the stable parseable interface for \p M to \p outputPath.
///
/// ...unless \p outputPath is empty, in which case it does nothing.
///
/// \returns true if there were any errors
///
/// \see swift::emitModuleInterface
static bool printModuleInterfaceIfNeeded(StringRef outputPath, ModuleDecl *M) {
/// \see swift::emitParseableInterface
static bool printParseableInterfaceIfNeeded(StringRef outputPath,
ModuleDecl *M) {
if (outputPath.empty())
return false;
return atomicallyWritingToTextFile(outputPath, M->getDiags(),
[M](raw_ostream &out) -> bool {
return swift::emitModuleInterface(out, M);
return swift::emitParseableInterface(out, M);
});
}
@@ -888,9 +889,9 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
Instance.getMainModule(), opts.ImplicitObjCHeaderPath, moduleIsPublic);
}
if (opts.InputsAndOutputs.hasModuleInterfaceOutputPath()) {
hadAnyError |= printModuleInterfaceIfNeeded(
Invocation.getModuleInterfaceOutputPathForWholeModule(),
if (opts.InputsAndOutputs.hasParseableInterfaceOutputPath()) {
hadAnyError |= printParseableInterfaceIfNeeded(
Invocation.getParseableInterfaceOutputPathForWholeModule(),
Instance.getMainModule());
}

View File

@@ -1,4 +1,4 @@
//===--- TextualInterfaceGeneration.cpp - swiftinterface files ------------===//
//===--- ParseableInterfaceGeneration.cpp - swiftinterface files ----------===//
//
// This source file is part of the Swift.org open source project
//
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
#include "TextualInterfaceGeneration.h"
#include "ParseableInterfaceGeneration.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/Decl.h"
@@ -21,7 +21,7 @@
using namespace swift;
/// Diagnose any scoped imports in \p imports, i.e. those with a non-empty
/// access path. These are not yet supported by textual interfaces, since the
/// access path. These are not yet supported by parseable interfaces, since the
/// information about the declaration kind is not preserved through the binary
/// serialization that happens as an intermediate step in non-whole-module
/// builds.
@@ -33,7 +33,7 @@ static void diagnoseScopedImports(DiagnosticEngine &diags,
if (importPair.first.empty())
continue;
diags.diagnose(importPair.first.front().second,
diag::textual_interface_scoped_import_unsupported);
diag::parseable_interface_scoped_import_unsupported);
}
}
@@ -80,12 +80,12 @@ static void printImports(raw_ostream &out, ModuleDecl *M) {
}
}
bool swift::emitModuleInterface(raw_ostream &out, ModuleDecl *M) {
bool swift::emitParseableInterface(raw_ostream &out, ModuleDecl *M) {
assert(M);
printImports(out, M);
const PrintOptions printOptions = PrintOptions::printTextualInterfaceFile();
const PrintOptions printOptions = PrintOptions::printParseableInterfaceFile();
SmallVector<Decl *, 16> topLevelDecls;
M->getTopLevelDecls(topLevelDecls);
for (const Decl *D : topLevelDecls) {

View File

@@ -1,4 +1,4 @@
//===--- TextualInterfaceGeneration.h - swiftinterface files ----*- C++ -*-===//
//===--- ParseableInterfaceGeneration.h - swiftinterface files --*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_FRONTENDTOOL_TEXTUALINTERFACEGENERATION_H
#define SWIFT_FRONTENDTOOL_TEXTUALINTERFACEGENERATION_H
#ifndef SWIFT_FRONTENDTOOL_PARSEABLEINTERFACEGENERATION_H
#define SWIFT_FRONTENDTOOL_PARSEABLEINTERFACEGENERATION_H
#include "swift/Basic/LLVM.h"
@@ -19,7 +19,7 @@ namespace swift {
class ModuleDecl;
/// Emit a stable, textual interface for \p M, which can be used by a client
/// Emit a stable, parseable interface for \p M, which can be used by a client
/// source file to import this module.
///
/// Unlike a serialized module, the textual format generated by
@@ -32,7 +32,7 @@ class ModuleDecl;
/// \return true if an error occurred
///
/// \sa swift::serialize
bool emitModuleInterface(raw_ostream &out, ModuleDecl *M);
bool emitParseableInterface(raw_ostream &out, ModuleDecl *M);
} // end namespace swift

View File

@@ -4273,7 +4273,7 @@ bool Parser::parseGetSet(ParseDeclOptions Flags,
assert(Tok.is(tok::l_brace));
// Properties in protocols use a very limited syntax.
// SIL mode and textual interfaces use the same syntax.
// SIL mode and parseable interfaces use the same syntax.
// Otherwise, we have a normal var or subscript declaration and we need
// parse the full complement of specifiers, along with their bodies.
bool parsingLimitedSyntax = Flags.contains(PD_InProtocol) ||
@@ -4396,7 +4396,7 @@ bool Parser::parseGetSet(ParseDeclOptions Flags,
// It's okay not to have a body if there's an external asm name.
if (!Tok.is(tok::l_brace)) {
// Accessors don't need bodies in textual interfaces
// Accessors don't need bodies in parseable interfaces
if (SF.Kind == SourceFileKind::Interface)
continue;
// _silgen_name'd accessors don't need bodies.
@@ -6404,7 +6404,7 @@ parseDeclDeinit(ParseDeclOptions Flags, DeclAttributes &Attributes) {
switch (SF.Kind) {
case SourceFileKind::Interface:
case SourceFileKind::SIL:
// It's okay to have no body for SIL code or textual interfaces.
// It's okay to have no body for SIL code or parseable interfaces.
break;
case SourceFileKind::Library:
case SourceFileKind::Main:

View File

@@ -2583,7 +2583,7 @@ public:
// Static/class declarations require an initializer unless in a
// protocol.
if (var->isStatic() && !isa<ProtocolDecl>(varDC)) {
// ...but don't enforce this for SIL or textual interface files.
// ...but don't enforce this for SIL or parseable interface files.
switch (varDC->getParentSourceFile()->Kind) {
case SourceFileKind::Interface:
case SourceFileKind::SIL:
@@ -3123,7 +3123,7 @@ public:
return false;
}
// Declarations in SIL and textual interface files don't require
// Declarations in SIL and parseable interface files don't require
// definitions.
if (auto sourceFile = decl->getDeclContext()->getParentSourceFile()) {
switch (sourceFile->Kind) {
@@ -5181,7 +5181,7 @@ static void diagnoseClassWithoutInitializers(TypeChecker &tc,
void TypeChecker::maybeDiagnoseClassWithoutInitializers(ClassDecl *classDecl) {
if (auto *SF = classDecl->getParentSourceFile()) {
// Allow classes without initializers in SIL and textual interface files.
// Allow classes without initializers in SIL and parseable interface files.
switch (SF->Kind) {
case SourceFileKind::SIL:
case SourceFileKind::Interface:
@@ -5316,7 +5316,7 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
if (decl->isInvalid())
return;
// Don't add implicit constructors in textual interfaces.
// Don't add implicit constructors in parseable interfaces.
if (auto *SF = decl->getParentSourceFile()) {
if (SF->Kind == SourceFileKind::Interface) {
decl->setAddedImplicitInitializers();

View File

@@ -1092,7 +1092,7 @@ bool WitnessChecker::findBestWitness(
}
if (numViable == 0) {
// Assume any missing value witnesses for a conformance in a textual
// Assume any missing value witnesses for a conformance in a parseable
// interface can be treated as opaque.
// FIXME: ...but we should do something better about types.
if (conformance && !conformance->isInvalid()) {

View File

@@ -25,6 +25,6 @@
// RESOLVE_IMPORTS_NO_OBJC_HEADER: error: this mode does not support emitting Objective-C headers{{$}}
// RUN: not %target-swift-frontend -parse -emit-interface-path %t %s 2>&1 | %FileCheck -check-prefix=PARSE_NO_INTERFACE %s
// PARSE_NO_INTERFACE: error: this mode does not support emitting textual interface files{{$}}
// PARSE_NO_INTERFACE: error: this mode does not support emitting parseable interface files{{$}}
// RUN: not %target-swift-frontend -emit-silgen -emit-interface-path %t %s 2>&1 | %FileCheck -check-prefix=SILGEN_NO_INTERFACE %s
// SILGEN_NO_INTERFACE: error: this mode does not support emitting textual interface files{{$}}
// SILGEN_NO_INTERFACE: error: this mode does not support emitting parseable interface files{{$}}

View File

@@ -5,7 +5,7 @@
@_exported import empty
import B.B2
import func C.c // expected-warning {{scoped imports are not yet supported in textual module interfaces}}
import func C.c // expected-warning {{scoped imports are not yet supported in parseable module interfaces}}
import D
// CHECK-NOT: import