Skip to content

[5.5] cherry-pick recent ABI checker changes #39033

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 5 commits into from
Aug 27, 2021
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
11 changes: 11 additions & 0 deletions include/swift/APIDigester/ModuleAnalyzerNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Sema.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/FileSystem.h"
Expand Down Expand Up @@ -717,6 +718,12 @@ class SDKNodeDeclAccessor: public SDKNodeDeclAbstractFunc {
void jsonize(json::Output &Out) override;
};

class SDKNodeDeclImport: public SDKNodeDecl {
public:
SDKNodeDeclImport(SDKNodeInitInfo Info);
static bool classof(const SDKNode *N);
};

// The additional information we need for a type node in the digest.
// We use type node to represent entities more than types, e.g. parameters, so
// this struct is necessary to pass down to create a type node.
Expand Down Expand Up @@ -781,6 +788,8 @@ class SwiftDeclCollector: public VisibleDeclConsumer {
void lookupVisibleDecls(ArrayRef<ModuleDecl *> Modules);
};

void detectRename(SDKNode *L, SDKNode *R);

int dumpSwiftModules(const CompilerInvocation &InitInvok,
const llvm::StringSet<> &ModuleNames,
StringRef OutputDir,
Expand All @@ -799,6 +808,8 @@ int dumpSDKContent(const CompilerInvocation &InitInvok,
const llvm::StringSet<> &ModuleNames,
StringRef OutputFile, CheckerOptions Opts);

void dumpModuleContent(ModuleDecl *MD, StringRef OutputFile, bool ABI);

/// Mostly for testing purposes, this function de-serializes the SDK dump in
/// dumpPath and re-serialize them to OutputPath. If the tool performs correctly,
/// the contents in dumpPath and OutputPath should be identical.
Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ ERROR(error_mode_cannot_emit_module_summary,none,
"this mode does not support emitting module summary files", ())
ERROR(error_mode_cannot_emit_symbol_graph,none,
"this mode does not support emitting symbol graph files", ())
ERROR(error_mode_cannot_emit_abi_descriptor,none,
"this mode does not support emitting ABI descriptor", ())
ERROR(cannot_emit_ir_skipping_function_bodies,none,
"the -experimental-skip-*-function-bodies* flags do not support "
"emitting IR", ())
Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/DiagnosticsModuleDiffer.def
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ ERROR(not_inheriting_convenience_inits,none,"%0 no longer inherits convenience i

ERROR(enum_case_added,none,"%0 has been added as a new enum case", (StringRef))

ERROR(demangled_name_changed,none,"%0 has mangled name changing from '%1' to '%2'", (StringRef, StringRef, StringRef))

WARNING(cannot_read_allowlist,none,"cannot read breakage allowlist at '%0'", (StringRef))

#define UNDEFINE_DIAGNOSTIC_MACROS
Expand Down
5 changes: 5 additions & 0 deletions include/swift/AST/USRGeneration.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "swift/Basic/LLVM.h"

#include <string>

namespace swift {
class Decl;
class AbstractStorageDecl;
Expand Down Expand Up @@ -61,6 +63,9 @@ bool printExtensionUSR(const ExtensionDecl *ED, raw_ostream &OS);
/// \returns true if it failed, false on success.
bool printDeclUSR(const Decl *D, raw_ostream &OS);

/// Demangle a mangle-name-based USR to a human readable name.
std::string demangleUSR(StringRef mangled);

} // namespace ide
} // namespace swift

Expand Down
7 changes: 6 additions & 1 deletion include/swift/Basic/SupplementaryOutputPaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ struct SupplementaryOutputPaths {
/// The path to which we should emit module summary file.
std::string ModuleSummaryOutputPath;

/// The output path to generate ABI baseline.
std::string ABIDescriptorOutputPath;

SupplementaryOutputPaths() = default;
SupplementaryOutputPaths(const SupplementaryOutputPaths &) = default;

Expand Down Expand Up @@ -186,6 +189,8 @@ struct SupplementaryOutputPaths {
fn(LdAddCFilePath);
if (!ModuleSummaryOutputPath.empty())
fn(ModuleSummaryOutputPath);
if (!ABIDescriptorOutputPath.empty())
fn(ABIDescriptorOutputPath);
}

bool empty() const {
Expand All @@ -194,7 +199,7 @@ struct SupplementaryOutputPaths {
ReferenceDependenciesFilePath.empty() &&
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&
ModuleSourceInfoOutputPath.empty() && LdAddCFilePath.empty();
ModuleSourceInfoOutputPath.empty() && LdAddCFilePath.empty() && ABIDescriptorOutputPath.empty();
}
};
} // namespace swift
Expand Down
1 change: 1 addition & 0 deletions include/swift/Frontend/FrontendInputsAndOutputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class FrontendInputsAndOutputs {
bool hasModuleSourceInfoOutputPath() const;
bool hasModuleInterfaceOutputPath() const;
bool hasPrivateModuleInterfaceOutputPath() const;
bool hasABIDescriptorOutputPath() const;
bool hasModuleSummaryOutputPath() const;
bool hasTBDPath() const;

Expand Down
1 change: 1 addition & 0 deletions include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ class FrontendOptions {
static bool canActionEmitModuleDoc(ActionType);
static bool canActionEmitModuleSummary(ActionType);
static bool canActionEmitInterface(ActionType);
static bool canActionEmitABIDescriptor(ActionType);

public:
static bool doesActionGenerateSIL(ActionType);
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Frontend/ModuleInterfaceLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class ModuleInterfaceLoader : public SerializedModuleLoaderBase {
const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
const ClangImporterOptions &ClangOpts, StringRef CacheDir,
StringRef PrebuiltCacheDir, StringRef ModuleName, StringRef InPath,
StringRef OutPath, bool SerializeDependencyHashes,
StringRef OutPath, StringRef ABIOutputPath, bool SerializeDependencyHashes,
bool TrackSystemDependencies, ModuleInterfaceLoaderOptions Opts,
RequireOSSAModules_t RequireOSSAModules);
};
Expand Down
1 change: 1 addition & 0 deletions include/swift/IDE/DigesterEnums.def
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ NODE_KIND(DeclOperator, OperatorDecl)
NODE_KIND(DeclType, TypeDecl)
NODE_KIND(DeclVar, Var)
NODE_KIND(DeclTypeAlias, TypeAlias)
NODE_KIND(DeclImport, Import)
NODE_KIND(DeclAssociatedType, AssociatedType)
NODE_KIND_RANGE(Decl, DeclFunction, DeclAssociatedType)

Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def emit_fixits_path
: Separate<["-"], "emit-fixits-path">, MetaVarName<"<path>">,
HelpText<"Output compiler fixits as source edits to <path>">;

def emit_abi_descriptor_path
: Separate<["-"], "emit-abi-descriptor-path">, MetaVarName<"<path>">,
HelpText<"Output the ABI descriptor of current module to <path>">;

def serialize_module_interface_dependency_hashes
: Flag<["-"], "serialize-module-interface-dependency-hashes">,
Flags<[HelpHidden]>;
Expand Down
Loading