mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/master' into master-next
This commit is contained in:
@@ -48,6 +48,7 @@ namespace {
|
||||
DeserializeSDK,
|
||||
GenerateNameCorrectionTemplate,
|
||||
FindUsr,
|
||||
GenerateEmptyBaseline,
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
@@ -173,7 +174,10 @@ Action(llvm::cl::desc("Mode:"), llvm::cl::init(ActionType::None),
|
||||
"Find USR for decls by given condition"),
|
||||
clEnumValN(ActionType::GenerateNameCorrectionTemplate,
|
||||
"generate-name-correction",
|
||||
"Generate name correction template")));
|
||||
"Generate name correction template"),
|
||||
clEnumValN(ActionType::GenerateEmptyBaseline,
|
||||
"generate-empty-baseline",
|
||||
"Generate an empty baseline")));
|
||||
|
||||
static llvm::cl::list<std::string>
|
||||
SDKJsonPaths("input-paths",
|
||||
@@ -1925,6 +1929,21 @@ void DiagnosisEmitter::diagnosis(NodePtr LeftRoot, NodePtr RightRoot,
|
||||
SDKNode::postorderVisit(LeftRoot, Emitter);
|
||||
}
|
||||
|
||||
static bool diagnoseRemovedExtensionMembers(const SDKNode *Node) {
|
||||
// If the removed decl is an extension, diagnose each member as being removed rather than
|
||||
// the extension itself has been removed.
|
||||
if (auto *DT= dyn_cast<SDKNodeDeclType>(Node)) {
|
||||
if (DT->isExtension()) {
|
||||
for (auto *C: DT->getChildren()) {
|
||||
auto *MD = cast<SDKNodeDecl>(C);
|
||||
MD->emitDiag(diag::removed_decl, MD->isDeprecated());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
|
||||
assert(Node->isAnnotatedAs(Anno));
|
||||
auto &Ctx = Node->getSDKContext();
|
||||
@@ -1992,8 +2011,9 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Node->emitDiag(diag::removed_decl, Node->isDeprecated());
|
||||
bool handled = diagnoseRemovedExtensionMembers(Node);
|
||||
if (!handled)
|
||||
Node->emitDiag(diag::removed_decl, Node->isDeprecated());
|
||||
return;
|
||||
}
|
||||
case NodeAnnotation::Rename: {
|
||||
@@ -2464,13 +2484,12 @@ static CheckerOptions getCheckOpts(int argc, char *argv[]) {
|
||||
return Opts;
|
||||
}
|
||||
|
||||
static SDKNodeRoot *getSDKRoot(const char *Main, SDKContext &Ctx,
|
||||
CheckerOptions Opts, bool IsBaseline) {
|
||||
static SDKNodeRoot *getSDKRoot(const char *Main, SDKContext &Ctx, bool IsBaseline) {
|
||||
CompilerInvocation Invok;
|
||||
llvm::StringSet<> Modules;
|
||||
if (prepareForDump(Main, Invok, Modules, IsBaseline))
|
||||
return nullptr;
|
||||
return getSDKNodeRoot(Ctx, Invok, Modules, Opts);
|
||||
return getSDKNodeRoot(Ctx, Invok, Modules);
|
||||
}
|
||||
|
||||
static bool hasBaselineInput() {
|
||||
@@ -2521,8 +2540,8 @@ int main(int argc, char *argv[]) {
|
||||
std::move(protocolWhitelist));
|
||||
else {
|
||||
SDKContext Ctx(Opts);
|
||||
return diagnoseModuleChange(Ctx, getSDKRoot(argv[0], Ctx, Opts, true),
|
||||
getSDKRoot(argv[0], Ctx, Opts, false),
|
||||
return diagnoseModuleChange(Ctx, getSDKRoot(argv[0], Ctx, true),
|
||||
getSDKRoot(argv[0], Ctx, false),
|
||||
options::OutputFile,
|
||||
std::move(protocolWhitelist));
|
||||
}
|
||||
@@ -2551,6 +2570,11 @@ int main(int argc, char *argv[]) {
|
||||
Store.addStorePath(Paths[I]);
|
||||
return deserializeNameCorrection(Store, options::OutputFile);
|
||||
}
|
||||
case ActionType::GenerateEmptyBaseline: {
|
||||
SDKContext Ctx(Opts);
|
||||
dumpSDKRoot(getEmptySDKNodeRoot(Ctx), options::OutputFile);
|
||||
return 0;
|
||||
}
|
||||
case ActionType::FindUsr: {
|
||||
if (options::SDKJsonPaths.size() != 1) {
|
||||
llvm::cl::PrintHelpMessage();
|
||||
|
||||
Reference in New Issue
Block a user