Skip to content

Commit 9a93c18

Browse files
authored
Merge pull request #39033 from nkcsgexi/api-checker-5.5
[5.5] cherry-pick recent ABI checker changes
2 parents ce87bd8 + 4b4dee2 commit 9a93c18

32 files changed

+598
-323
lines changed

include/swift/APIDigester/ModuleAnalyzerNodes.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "clang/Sema/Lookup.h"
2424
#include "clang/Sema/Sema.h"
2525
#include "llvm/ADT/TinyPtrVector.h"
26+
#include "llvm/ADT/STLExtras.h"
2627
#include "llvm/Support/CommandLine.h"
2728
#include "llvm/Support/Compiler.h"
2829
#include "llvm/Support/FileSystem.h"
@@ -717,6 +718,12 @@ class SDKNodeDeclAccessor: public SDKNodeDeclAbstractFunc {
717718
void jsonize(json::Output &Out) override;
718719
};
719720

721+
class SDKNodeDeclImport: public SDKNodeDecl {
722+
public:
723+
SDKNodeDeclImport(SDKNodeInitInfo Info);
724+
static bool classof(const SDKNode *N);
725+
};
726+
720727
// The additional information we need for a type node in the digest.
721728
// We use type node to represent entities more than types, e.g. parameters, so
722729
// this struct is necessary to pass down to create a type node.
@@ -781,6 +788,8 @@ class SwiftDeclCollector: public VisibleDeclConsumer {
781788
void lookupVisibleDecls(ArrayRef<ModuleDecl *> Modules);
782789
};
783790

791+
void detectRename(SDKNode *L, SDKNode *R);
792+
784793
int dumpSwiftModules(const CompilerInvocation &InitInvok,
785794
const llvm::StringSet<> &ModuleNames,
786795
StringRef OutputDir,
@@ -799,6 +808,8 @@ int dumpSDKContent(const CompilerInvocation &InitInvok,
799808
const llvm::StringSet<> &ModuleNames,
800809
StringRef OutputFile, CheckerOptions Opts);
801810

811+
void dumpModuleContent(ModuleDecl *MD, StringRef OutputFile, bool ABI);
812+
802813
/// Mostly for testing purposes, this function de-serializes the SDK dump in
803814
/// dumpPath and re-serialize them to OutputPath. If the tool performs correctly,
804815
/// the contents in dumpPath and OutputPath should be identical.

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ ERROR(error_mode_cannot_emit_module_summary,none,
129129
"this mode does not support emitting module summary files", ())
130130
ERROR(error_mode_cannot_emit_symbol_graph,none,
131131
"this mode does not support emitting symbol graph files", ())
132+
ERROR(error_mode_cannot_emit_abi_descriptor,none,
133+
"this mode does not support emitting ABI descriptor", ())
132134
ERROR(cannot_emit_ir_skipping_function_bodies,none,
133135
"the -experimental-skip-*-function-bodies* flags do not support "
134136
"emitting IR", ())

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ ERROR(not_inheriting_convenience_inits,none,"%0 no longer inherits convenience i
8888

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

91+
ERROR(demangled_name_changed,none,"%0 has mangled name changing from '%1' to '%2'", (StringRef, StringRef, StringRef))
92+
9193
WARNING(cannot_read_allowlist,none,"cannot read breakage allowlist at '%0'", (StringRef))
9294

9395
#define UNDEFINE_DIAGNOSTIC_MACROS

include/swift/AST/USRGeneration.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include "swift/Basic/LLVM.h"
2323

24+
#include <string>
25+
2426
namespace swift {
2527
class Decl;
2628
class AbstractStorageDecl;
@@ -61,6 +63,9 @@ bool printExtensionUSR(const ExtensionDecl *ED, raw_ostream &OS);
6163
/// \returns true if it failed, false on success.
6264
bool printDeclUSR(const Decl *D, raw_ostream &OS);
6365

66+
/// Demangle a mangle-name-based USR to a human readable name.
67+
std::string demangleUSR(StringRef mangled);
68+
6469
} // namespace ide
6570
} // namespace swift
6671

include/swift/Basic/SupplementaryOutputPaths.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ struct SupplementaryOutputPaths {
153153
/// The path to which we should emit module summary file.
154154
std::string ModuleSummaryOutputPath;
155155

156+
/// The output path to generate ABI baseline.
157+
std::string ABIDescriptorOutputPath;
158+
156159
SupplementaryOutputPaths() = default;
157160
SupplementaryOutputPaths(const SupplementaryOutputPaths &) = default;
158161

@@ -186,6 +189,8 @@ struct SupplementaryOutputPaths {
186189
fn(LdAddCFilePath);
187190
if (!ModuleSummaryOutputPath.empty())
188191
fn(ModuleSummaryOutputPath);
192+
if (!ABIDescriptorOutputPath.empty())
193+
fn(ABIDescriptorOutputPath);
189194
}
190195

191196
bool empty() const {
@@ -194,7 +199,7 @@ struct SupplementaryOutputPaths {
194199
ReferenceDependenciesFilePath.empty() &&
195200
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
196201
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&
197-
ModuleSourceInfoOutputPath.empty() && LdAddCFilePath.empty();
202+
ModuleSourceInfoOutputPath.empty() && LdAddCFilePath.empty() && ABIDescriptorOutputPath.empty();
198203
}
199204
};
200205
} // namespace swift

include/swift/Frontend/FrontendInputsAndOutputs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class FrontendInputsAndOutputs {
256256
bool hasModuleSourceInfoOutputPath() const;
257257
bool hasModuleInterfaceOutputPath() const;
258258
bool hasPrivateModuleInterfaceOutputPath() const;
259+
bool hasABIDescriptorOutputPath() const;
259260
bool hasModuleSummaryOutputPath() const;
260261
bool hasTBDPath() const;
261262

include/swift/Frontend/FrontendOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ class FrontendOptions {
423423
static bool canActionEmitModuleDoc(ActionType);
424424
static bool canActionEmitModuleSummary(ActionType);
425425
static bool canActionEmitInterface(ActionType);
426+
static bool canActionEmitABIDescriptor(ActionType);
426427

427428
public:
428429
static bool doesActionGenerateSIL(ActionType);

include/swift/Frontend/ModuleInterfaceLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class ModuleInterfaceLoader : public SerializedModuleLoaderBase {
414414
const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
415415
const ClangImporterOptions &ClangOpts, StringRef CacheDir,
416416
StringRef PrebuiltCacheDir, StringRef ModuleName, StringRef InPath,
417-
StringRef OutPath, bool SerializeDependencyHashes,
417+
StringRef OutPath, StringRef ABIOutputPath, bool SerializeDependencyHashes,
418418
bool TrackSystemDependencies, ModuleInterfaceLoaderOptions Opts,
419419
RequireOSSAModules_t RequireOSSAModules);
420420
};

include/swift/IDE/DigesterEnums.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ NODE_KIND(DeclOperator, OperatorDecl)
7272
NODE_KIND(DeclType, TypeDecl)
7373
NODE_KIND(DeclVar, Var)
7474
NODE_KIND(DeclTypeAlias, TypeAlias)
75+
NODE_KIND(DeclImport, Import)
7576
NODE_KIND(DeclAssociatedType, AssociatedType)
7677
NODE_KIND_RANGE(Decl, DeclFunction, DeclAssociatedType)
7778

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def emit_fixits_path
6464
: Separate<["-"], "emit-fixits-path">, MetaVarName<"<path>">,
6565
HelpText<"Output compiler fixits as source edits to <path>">;
6666

67+
def emit_abi_descriptor_path
68+
: Separate<["-"], "emit-abi-descriptor-path">, MetaVarName<"<path>">,
69+
HelpText<"Output the ABI descriptor of current module to <path>">;
70+
6771
def serialize_module_interface_dependency_hashes
6872
: Flag<["-"], "serialize-module-interface-dependency-hashes">,
6973
Flags<[HelpHidden]>;

0 commit comments

Comments
 (0)