mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ABI Checker: use lower-cased decl keywords to be consistent with source. NFC
This commit is contained in:
@@ -65,7 +65,7 @@ raw_ostream &operator<<(raw_ostream &Out, const NodeAnnotation Value);
|
||||
// Redefine << so that we can output the name of the node kind.
|
||||
raw_ostream &operator<<(raw_ostream &Out, const SDKNodeKind Value);
|
||||
|
||||
StringRef getDeclKindStr(const DeclKind Value);
|
||||
StringRef getDeclKindStr(const DeclKind Value, bool lower);
|
||||
|
||||
// Redefine << so that we can output the name of decl kind.
|
||||
raw_ostream &operator<<(raw_ostream &Out, const DeclKind Value);
|
||||
|
||||
@@ -39,7 +39,7 @@ operator<<(raw_ostream &Out, const NodeAnnotation Value) {
|
||||
llvm_unreachable("Undefined SDK node kind.");
|
||||
}
|
||||
|
||||
StringRef swift::ide::api::getDeclKindStr(const DeclKind Value) {
|
||||
static StringRef getDeclKindStrRaw(const DeclKind Value) {
|
||||
switch (Value) {
|
||||
#define DECL(X, PARENT) case DeclKind::X: return #X;
|
||||
#include "swift/AST/DeclNodes.def"
|
||||
@@ -47,9 +47,22 @@ StringRef swift::ide::api::getDeclKindStr(const DeclKind Value) {
|
||||
llvm_unreachable("Unhandled DeclKind in switch.");
|
||||
}
|
||||
|
||||
raw_ostream &swift::ide::api::operator<<(raw_ostream &Out,
|
||||
const DeclKind Value) {
|
||||
return Out << getDeclKindStr(Value);
|
||||
StringRef swift::ide::api::getDeclKindStr(const DeclKind Value, bool lower) {
|
||||
if (lower) {
|
||||
switch (Value) {
|
||||
#define DECL(X, PARENT) case DeclKind::X: { \
|
||||
static std::string lowered = StringRef(#X).lower(); \
|
||||
return lowered; \
|
||||
}
|
||||
#include "swift/AST/DeclNodes.def"
|
||||
}
|
||||
} else {
|
||||
return getDeclKindStrRaw(Value);
|
||||
}
|
||||
}
|
||||
|
||||
raw_ostream &swift::ide::api::operator<<(raw_ostream &Out, const DeclKind Value) {
|
||||
return Out << getDeclKindStrRaw(Value);
|
||||
}
|
||||
|
||||
Optional<SDKNodeKind> swift::ide::api::parseSDKNodeKind(StringRef Content) {
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
// RUN: echo "public func foo() {}" > %t.mod1/Foo.swift
|
||||
// RUN: echo "public func bar() {}" > %t.mod2/Foo.swift
|
||||
|
||||
// RUN: echo "Foo: Func foo() has been removed" > %t/incomplete-allowlist.txt
|
||||
// RUN: echo "Foo: Func foo() has been removed" > %t/complete-allowlist.txt
|
||||
// RUN: echo "Foo: Func bar() is a new API without @available attribute" >> %t/complete-allowlist.txt
|
||||
// RUN: echo "Foo: func foo() has been removed" > %t/incomplete-allowlist.txt
|
||||
// RUN: echo "Foo: func foo() has been removed" > %t/complete-allowlist.txt
|
||||
// RUN: echo "Foo: func bar() is a new API without @available attribute" >> %t/complete-allowlist.txt
|
||||
|
||||
// RUN: %target-swift-frontend -disable-objc-attr-requires-foundation-module -emit-module -o %t.mod1/Foo.swiftmodule %t.mod1/Foo.swift -parse-as-library -enable-library-evolution -emit-module-source-info -emit-module-source-info-path %t.mod1/Foo.swiftsourceinfo -emit-module-interface-path %t.mod1/Foo.swiftinterface -module-name Foo -swift-version 5
|
||||
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
// RUN: not %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module cake -I %t.mod2 -I %S/Inputs/APINotesLeft -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -o %t.result -compiler-style-diags 2> %t.abi.compiler.diags
|
||||
// RUN: %FileCheck %s < %t.abi.compiler.diags
|
||||
|
||||
// CHECK: cake_current/cake.swift:39:15: error: cake: Struct C6 is now with @frozen
|
||||
// CHECK: cake_current/cake.swift:41:13: error: cake: Enum IceKind is now without @frozen
|
||||
// CHECK: cake_current/cake.swift:39:15: error: cake: struct C6 is now with @frozen
|
||||
// CHECK: cake_current/cake.swift:41:13: error: cake: enum IceKind is now without @frozen
|
||||
|
||||
@@ -419,10 +419,12 @@ StringRef SDKNodeDecl::getScreenInfo() const {
|
||||
if (auto *TD = dyn_cast<SDKNodeDeclType>(this)) {
|
||||
IsExtension = TD->isExternal();
|
||||
}
|
||||
if (IsExtension)
|
||||
OS << "Extension";
|
||||
else
|
||||
OS << getDeclKind();
|
||||
|
||||
// There is no particular reasons why we don't use lower-cased keyword names
|
||||
// in non-CompilerStyle mode. This is to be backward compatible so clients
|
||||
// don't need to update existing known breakages.
|
||||
OS << getDeclKindStr(IsExtension? DeclKind::Extension : getDeclKind(),
|
||||
getSDKContext().getOpts().CompilerStyle);
|
||||
OS << " " << getFullyQualifiedName();
|
||||
return Ctx.buffer(OS.str());
|
||||
}
|
||||
|
||||
@@ -154,6 +154,7 @@ struct CheckerOptions {
|
||||
bool PrintModule;
|
||||
bool SwiftOnly;
|
||||
bool SkipOSCheck;
|
||||
bool CompilerStyle;
|
||||
bool Migrator;
|
||||
StringRef LocationFilter;
|
||||
std::vector<std::string> ToolArgs;
|
||||
|
||||
@@ -794,7 +794,8 @@ void swift::ide::api::SDKNodeDeclType::diagnose(SDKNode *Right) {
|
||||
return;
|
||||
auto Loc = R->getLoc();
|
||||
if (getDeclKind() != R->getDeclKind()) {
|
||||
emitDiag(Loc, diag::decl_kind_changed, getDeclKindStr(R->getDeclKind()));
|
||||
emitDiag(Loc, diag::decl_kind_changed, getDeclKindStr(R->getDeclKind(),
|
||||
getSDKContext().getOpts().CompilerStyle));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -986,7 +987,8 @@ void swift::ide::api::SDKNodeDeclOperator::diagnose(SDKNode *Right) {
|
||||
return;
|
||||
auto Loc = RO->getLoc();
|
||||
if (getDeclKind() != RO->getDeclKind()) {
|
||||
emitDiag(Loc, diag::decl_kind_changed, getDeclKindStr(RO->getDeclKind()));
|
||||
emitDiag(Loc, diag::decl_kind_changed, getDeclKindStr(RO->getDeclKind(),
|
||||
getSDKContext().getOpts().CompilerStyle));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2121,7 +2123,8 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
|
||||
if (auto *Added = findAddedDecl(Node)) {
|
||||
if (Node->getDeclKind() != DeclKind::Constructor) {
|
||||
Node->emitDiag(Added->getLoc(), diag::moved_decl,
|
||||
Ctx.buffer((Twine(getDeclKindStr(Added->getDeclKind())) + " " +
|
||||
Ctx.buffer((Twine(getDeclKindStr(Added->getDeclKind(),
|
||||
Ctx.getOpts().CompilerStyle)) + " " +
|
||||
Added->getFullyQualifiedName()).str()));
|
||||
return;
|
||||
}
|
||||
@@ -2133,7 +2136,8 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
|
||||
[&](TypeMemberDiffItem &Item) { return Item.usr == Node->getUsr(); });
|
||||
if (It != MemberChanges.end()) {
|
||||
Node->emitDiag(SourceLoc(), diag::renamed_decl,
|
||||
Ctx.buffer((Twine(getDeclKindStr(Node->getDeclKind())) + " " +
|
||||
Ctx.buffer((Twine(getDeclKindStr(Node->getDeclKind(),
|
||||
Ctx.getOpts().CompilerStyle)) + " " +
|
||||
It->newTypeName + "." + It->newPrintedName).str()));
|
||||
return;
|
||||
}
|
||||
@@ -2190,7 +2194,8 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
|
||||
DiagLoc = CD->getLoc();
|
||||
}
|
||||
Node->emitDiag(DiagLoc, diag::renamed_decl,
|
||||
Ctx.buffer((Twine(getDeclKindStr(Node->getDeclKind())) + " " +
|
||||
Ctx.buffer((Twine(getDeclKindStr(Node->getDeclKind(),
|
||||
Ctx.getOpts().CompilerStyle)) + " " +
|
||||
Node->getAnnotateComment(NodeAnnotation::RenameNewName)).str()));
|
||||
return;
|
||||
}
|
||||
@@ -2701,6 +2706,8 @@ static CheckerOptions getCheckOpts(int argc, char *argv[]) {
|
||||
// the checking logics are language-specific.
|
||||
Opts.SwiftOnly = options::Abi || options::SwiftOnly;
|
||||
Opts.SkipOSCheck = options::DisableOSChecks;
|
||||
Opts.CompilerStyle = options::CompilerStyleDiags ||
|
||||
!options::SerializedDiagPath.empty();
|
||||
for (int i = 1; i < argc; ++i)
|
||||
Opts.ToolArgs.push_back(argv[i]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user