mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[rbi] Use interned StringRefs for diagnostics instead of SmallString<64>.
This makes the code easier to write and also prevents any lifetime issues from a
diagnostic outliving the SmallString due to diagnostic transactions.
(cherry picked from commit 010fa39f31)
This commit is contained in:
@@ -990,11 +990,11 @@ NOTE(regionbasedisolation_type_use_after_send_callee, none,
|
||||
(Type, StringRef, const ValueDecl *, StringRef))
|
||||
|
||||
NOTE(regionbasedisolation_named_info_send_yields_race, none,
|
||||
"sending %1%0 to %2 callee risks causing data races between %2 and local %3 uses",
|
||||
(Identifier, StringRef, StringRef, StringRef))
|
||||
"sending %select{%2 |}0%1 to %3 callee risks causing data races between %3 and local %4 uses",
|
||||
(bool, Identifier, StringRef, StringRef, StringRef))
|
||||
NOTE(regionbasedisolation_named_info_send_yields_race_callee, none,
|
||||
"sending %1%0 to %2 %kind3 risks causing data races between %2 and local %4 uses",
|
||||
(Identifier, StringRef, StringRef, const ValueDecl *, StringRef))
|
||||
"sending %select{%2 |}0%1 to %3 %kind4 risks causing data races between %3 and local %5 uses",
|
||||
(bool, Identifier, StringRef, StringRef, const ValueDecl *, StringRef))
|
||||
|
||||
// Use after send closure.
|
||||
NOTE(regionbasedisolation_type_isolated_capture_yields_race, none,
|
||||
@@ -1010,8 +1010,8 @@ NOTE(regionbasedisolation_named_value_used_after_explicit_sending, none,
|
||||
"%0 used after being passed as a 'sending' parameter; Later uses could race",
|
||||
(Identifier))
|
||||
NOTE(regionbasedisolation_named_isolated_closure_yields_race, none,
|
||||
"%0%1 is captured by a %2 closure. %2 uses in closure may race against later %3 uses",
|
||||
(StringRef, Identifier, StringRef, StringRef))
|
||||
"%select{%1 |}0%2 is captured by a %3 closure. %3 uses in closure may race against later %4 uses",
|
||||
(bool, StringRef, Identifier, StringRef, StringRef))
|
||||
|
||||
NOTE(regionbasedisolation_typed_use_after_sending, none,
|
||||
"Passing value of non-Sendable type %0 as a 'sending' argument risks causing races in between local and caller code",
|
||||
@@ -1024,19 +1024,19 @@ NOTE(regionbasedisolation_typed_use_after_sending_callee, none,
|
||||
// Sending Never Sendable Emitter
|
||||
|
||||
NOTE(regionbasedisolation_named_send_never_sendable, none,
|
||||
"sending %1%0 to %2 callee risks causing data races between %2 and %3 uses",
|
||||
(Identifier, StringRef, StringRef, StringRef))
|
||||
"sending %select{%2 |}0%1 to %3 callee risks causing data races between %3 and %4 uses",
|
||||
(bool, Identifier, StringRef, StringRef, StringRef))
|
||||
NOTE(regionbasedisolation_named_send_never_sendable_callee, none,
|
||||
"sending %1%0 to %2 %kind3 risks causing data races between %2 and %4 uses",
|
||||
(Identifier, StringRef, StringRef, const ValueDecl *, StringRef))
|
||||
"sending %select{%2 |}0%1 to %3 %kind4 risks causing data races between %3 and %5 uses",
|
||||
(bool, Identifier, StringRef, StringRef, const ValueDecl *, StringRef))
|
||||
|
||||
NOTE(regionbasedisolation_named_send_into_sending_param, none,
|
||||
"%0%1 is passed as a 'sending' parameter; Uses in callee may race with "
|
||||
"later %0uses",
|
||||
(StringRef, Identifier))
|
||||
"%select{%1 |}0%2 is passed as a 'sending' parameter; Uses in callee may race with "
|
||||
"later %1 uses",
|
||||
(bool, StringRef, Identifier))
|
||||
NOTE(regionbasedisolation_named_nosend_send_into_result, none,
|
||||
"%0%1 cannot be a 'sending' result. %2 uses may race with caller uses",
|
||||
(StringRef, Identifier, StringRef))
|
||||
"%select{%1 |}0%2 cannot be a 'sending' result. %3 uses may race with caller uses",
|
||||
(bool, StringRef, Identifier, StringRef))
|
||||
NOTE(regionbasedisolation_typed_tns_passed_to_sending, none,
|
||||
"Passing %0 value of non-Sendable type %1 as a 'sending' parameter risks "
|
||||
"causing races inbetween %0 uses and uses reachable from the callee",
|
||||
@@ -1098,10 +1098,10 @@ NOTE(regionbasedisolation_inout_sending_must_be_reinitialized, none,
|
||||
"'inout sending' parameter must be reinitialized before function exit with a non-actor isolated value",
|
||||
())
|
||||
ERROR(regionbasedisolation_inout_sending_cannot_be_actor_isolated, none,
|
||||
"'inout sending' parameter %0 cannot be %1at end of function",
|
||||
"'inout sending' parameter %0 cannot be %1 at end of function",
|
||||
(Identifier, StringRef))
|
||||
NOTE(regionbasedisolation_inout_sending_cannot_be_actor_isolated_note, none,
|
||||
"%1%0 risks causing races in between %1uses and caller uses since caller assumes value is not actor isolated",
|
||||
"%1 %0 risks causing races in between %1 uses and caller uses since caller assumes value is not actor isolated",
|
||||
(Identifier, StringRef))
|
||||
|
||||
//===
|
||||
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
private:
|
||||
bool isOperatorSlow() const;
|
||||
};
|
||||
|
||||
|
||||
class DeclName;
|
||||
class DeclNameRef;
|
||||
class ObjCSelector;
|
||||
|
||||
@@ -380,8 +380,16 @@ public:
|
||||
/// form of diagnostic than other cases.
|
||||
void printForCodeDiagnostic(SILFunction *fn, llvm::raw_ostream &os) const;
|
||||
|
||||
/// Overload of printForCodeDiagnostics that returns an interned StringRef
|
||||
/// owned by the AST.
|
||||
StringRef printForCodeDiagnostic(SILFunction *fn) const;
|
||||
|
||||
void printForDiagnostics(SILFunction *fn, llvm::raw_ostream &os) const;
|
||||
|
||||
/// Overload of printForDiagnostics that returns an interned StringRef owned
|
||||
/// by the AST.
|
||||
StringRef printForDiagnostics(SILFunction *fn) const;
|
||||
|
||||
SWIFT_DEBUG_DUMPER(dumpForDiagnostics(SILFunction *fn)) {
|
||||
printForDiagnostics(fn, llvm::dbgs());
|
||||
llvm::dbgs() << '\n';
|
||||
@@ -579,6 +587,12 @@ public:
|
||||
SILFunction *fn, ActorIsolation iso, llvm::raw_ostream &os,
|
||||
StringRef openingQuotationMark = "'", bool asNoun = false);
|
||||
|
||||
/// Overload for printActorIsolationForDiagnostics that produces a StringRef.
|
||||
static StringRef
|
||||
printActorIsolationForDiagnostics(SILFunction *fn, ActorIsolation iso,
|
||||
StringRef openingQuotationMark = "'",
|
||||
bool asNoun = false);
|
||||
|
||||
void Profile(llvm::FoldingSetNodeID &id) const;
|
||||
|
||||
private:
|
||||
@@ -648,6 +662,10 @@ public:
|
||||
innerInfo.printForDiagnostics(fn, os);
|
||||
}
|
||||
|
||||
StringRef printForDiagnostics(SILFunction *fn) const {
|
||||
return innerInfo.printForDiagnostics(fn);
|
||||
}
|
||||
|
||||
SWIFT_DEBUG_DUMPER(dumpForDiagnostics(SILFunction *fn)) {
|
||||
innerInfo.dumpForDiagnostics(fn);
|
||||
}
|
||||
@@ -656,6 +674,10 @@ public:
|
||||
innerInfo.printForCodeDiagnostic(fn, os);
|
||||
}
|
||||
|
||||
StringRef printForCodeDiagnostic(SILFunction *fn) const {
|
||||
return innerInfo.printForCodeDiagnostic(fn);
|
||||
}
|
||||
|
||||
void printForOneLineLogging(SILFunction *fn, llvm::raw_ostream &os) const {
|
||||
innerInfo.printForOneLineLogging(fn, os);
|
||||
}
|
||||
|
||||
@@ -686,37 +686,24 @@ public:
|
||||
.limitBehaviorIf(getBehaviorLimit());
|
||||
|
||||
// Then emit the note with greater context.
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
if (!namedValuesIsolationInfo.isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
namedValuesIsolationInfo.printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
namedValuesIsolationInfo.printForDiagnostics(getFunction());
|
||||
auto calleeIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation());
|
||||
auto callerIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation());
|
||||
|
||||
bool isDisconnected = namedValuesIsolationInfo.isDisconnected();
|
||||
if (auto callee = getSendingCallee()) {
|
||||
diagnoseNote(
|
||||
loc, diag::regionbasedisolation_named_info_send_yields_race_callee,
|
||||
name, descriptiveKindStr, calleeIsolationStr, callee.value(),
|
||||
callerIsolationStr);
|
||||
isDisconnected, name, descriptiveKindStr, calleeIsolationStr,
|
||||
callee.value(), callerIsolationStr);
|
||||
} else {
|
||||
diagnoseNote(loc, diag::regionbasedisolation_named_info_send_yields_race,
|
||||
name, descriptiveKindStr, calleeIsolationStr,
|
||||
isDisconnected, name, descriptiveKindStr, calleeIsolationStr,
|
||||
callerIsolationStr);
|
||||
}
|
||||
emitRequireInstDiagnostics();
|
||||
@@ -733,33 +720,20 @@ public:
|
||||
.limitBehaviorIf(getBehaviorLimit());
|
||||
|
||||
// Then emit the note with greater context.
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
if (!namedValuesIsolationInfo.isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
namedValuesIsolationInfo.printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
namedValuesIsolationInfo.printForDiagnostics(getFunction());
|
||||
auto calleeIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation());
|
||||
auto callerIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation());
|
||||
bool isDisconnected = namedValuesIsolationInfo.isDisconnected();
|
||||
|
||||
diagnoseNote(loc,
|
||||
diag::regionbasedisolation_named_info_send_yields_race_callee,
|
||||
name, descriptiveKindStr, calleeIsolationStr, callee,
|
||||
callerIsolationStr);
|
||||
isDisconnected, name, descriptiveKindStr, calleeIsolationStr,
|
||||
callee, callerIsolationStr);
|
||||
emitRequireInstDiagnostics();
|
||||
}
|
||||
|
||||
@@ -782,19 +756,12 @@ public:
|
||||
.highlight(loc.getSourceRange())
|
||||
.limitBehaviorIf(getBehaviorLimit());
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
auto calleeIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation());
|
||||
auto callerIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation());
|
||||
|
||||
if (auto callee = getSendingCallee()) {
|
||||
diagnoseNote(loc, diag::regionbasedisolation_type_use_after_send_callee,
|
||||
@@ -848,32 +815,19 @@ public:
|
||||
.highlight(loc.getSourceRange())
|
||||
.limitBehaviorIf(getBehaviorLimit());
|
||||
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
if (!namedValuesIsolationInfo.isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
namedValuesIsolationInfo.printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
|
||||
diagnoseNote(
|
||||
loc, diag::regionbasedisolation_named_isolated_closure_yields_race,
|
||||
descriptiveKindStr, name, calleeIsolationStr, callerIsolationStr)
|
||||
auto descriptiveKindStr =
|
||||
namedValuesIsolationInfo.printForDiagnostics(getFunction());
|
||||
auto calleeIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation());
|
||||
auto callerIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation());
|
||||
bool isDisconnected = namedValuesIsolationInfo.isDisconnected();
|
||||
diagnoseNote(loc,
|
||||
diag::regionbasedisolation_named_isolated_closure_yields_race,
|
||||
isDisconnected, descriptiveKindStr, name, calleeIsolationStr,
|
||||
callerIsolationStr)
|
||||
.highlight(loc.getSourceRange());
|
||||
emitRequireInstDiagnostics();
|
||||
}
|
||||
@@ -886,19 +840,12 @@ public:
|
||||
.highlight(loc.getSourceRange())
|
||||
.limitBehaviorIf(getBehaviorLimit());
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation(), os);
|
||||
}
|
||||
auto calleeIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation());
|
||||
auto callerIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCallerIsolation());
|
||||
|
||||
diagnoseNote(loc,
|
||||
diag::regionbasedisolation_type_isolated_capture_yields_race,
|
||||
@@ -1438,18 +1385,11 @@ public:
|
||||
.highlight(loc.getSourceRange())
|
||||
.limitBehaviorIf(getBehaviorLimit());
|
||||
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), crossing.getCalleeIsolation(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
auto calleeIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), crossing.getCalleeIsolation());
|
||||
|
||||
if (auto callee = getSendingCallee()) {
|
||||
diagnoseNote(
|
||||
@@ -1466,32 +1406,20 @@ public:
|
||||
void emitNamedFunctionArgumentClosure(SILLocation loc, Identifier name,
|
||||
ApplyIsolationCrossing crossing) {
|
||||
emitNamedOnlyError(loc, name);
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
if (!getIsolationRegionInfo().isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), crossing.getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), crossing.getCallerIsolation(), os);
|
||||
}
|
||||
|
||||
diagnoseNote(
|
||||
loc, diag::regionbasedisolation_named_isolated_closure_yields_race,
|
||||
descriptiveKindStr, name, calleeIsolationStr, callerIsolationStr)
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
auto calleeIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), crossing.getCalleeIsolation());
|
||||
auto callerIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), crossing.getCallerIsolation());
|
||||
bool isDisconnected = getIsolationRegionInfo().isDisconnected();
|
||||
diagnoseNote(loc,
|
||||
diag::regionbasedisolation_named_isolated_closure_yields_race,
|
||||
isDisconnected, descriptiveKindStr, name, calleeIsolationStr,
|
||||
callerIsolationStr)
|
||||
.highlight(loc.getSourceRange());
|
||||
}
|
||||
|
||||
@@ -1502,11 +1430,8 @@ public:
|
||||
.highlight(loc.getSourceRange())
|
||||
.limitBehaviorIf(getBehaviorLimit());
|
||||
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
|
||||
if (auto callee = getSendingCallee()) {
|
||||
diagnoseNote(
|
||||
@@ -1524,12 +1449,8 @@ public:
|
||||
void emitClosureErrorWithCapturedActor(Operand *partialApplyOp,
|
||||
Operand *actualUse,
|
||||
SILArgument *fArg) {
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().getIsolationInfo().printForCodeDiagnostic(
|
||||
getFunction(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForCodeDiagnostic(getFunction());
|
||||
|
||||
diagnoseError(partialApplyOp,
|
||||
diag::regionbasedisolation_typed_tns_passed_sending_closure,
|
||||
@@ -1537,12 +1458,8 @@ public:
|
||||
.limitBehaviorIf(getDiagnosticBehaviorLimitForOperands(
|
||||
actualUse->getFunction(), {actualUse}));
|
||||
|
||||
descriptiveKindStr.clear();
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().getIsolationInfo().printForDiagnostics(
|
||||
getFunction(), os);
|
||||
}
|
||||
descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
diagnoseNote(actualUse, diag::regionbasedisolation_closure_captures_actor,
|
||||
fArg->getDecl()->getName(), descriptiveKindStr);
|
||||
}
|
||||
@@ -1557,12 +1474,8 @@ public:
|
||||
void emitSendingClosureParamDirectlyIsolated(Operand *partialApplyOp,
|
||||
Operand *actualUse,
|
||||
SILArgument *fArg) {
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().getIsolationInfo().printForCodeDiagnostic(
|
||||
getFunction(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForCodeDiagnostic(getFunction());
|
||||
|
||||
diagnoseError(partialApplyOp,
|
||||
diag::regionbasedisolation_typed_tns_passed_sending_closure,
|
||||
@@ -1586,11 +1499,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
descriptiveKindStr.clear();
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
|
||||
auto diag = diag::
|
||||
regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_value;
|
||||
@@ -1607,11 +1517,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo()->printForCodeDiagnostic(getFunction(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo()->printForCodeDiagnostic(getFunction());
|
||||
|
||||
auto emitMainError = [&] {
|
||||
auto behaviorLimit = getDiagnosticBehaviorLimitForOperands(
|
||||
@@ -1643,11 +1550,8 @@ public:
|
||||
}
|
||||
|
||||
emitMainError();
|
||||
descriptiveKindStr.clear();
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
auto diag = diag::
|
||||
regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_value_region;
|
||||
diagnoseNote(actualUseInfo->first, diag, descriptiveKindStr,
|
||||
@@ -1688,11 +1592,8 @@ public:
|
||||
"Should never be disconnected?!");
|
||||
emitNamedOnlyError(loc, name);
|
||||
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
|
||||
diagnoseNote(loc, diag::regionbasedisolation_named_send_nt_asynclet_capture,
|
||||
name, descriptiveKindStr);
|
||||
@@ -1701,34 +1602,22 @@ public:
|
||||
void emitNamedIsolation(SILLocation loc, Identifier name,
|
||||
ApplyIsolationCrossing isolationCrossing) {
|
||||
emitNamedOnlyError(loc, name);
|
||||
SmallString<64> descriptiveKindStr;
|
||||
SmallString<64> descriptiveKindStrWithSpace;
|
||||
{
|
||||
if (!getIsolationRegionInfo().isDisconnected()) {
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
descriptiveKindStrWithSpace = descriptiveKindStr;
|
||||
descriptiveKindStrWithSpace.push_back(' ');
|
||||
}
|
||||
}
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
auto calleeIsolationStr =
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing.getCalleeIsolation());
|
||||
bool isDisconnected = getIsolationRegionInfo().isDisconnected();
|
||||
|
||||
if (auto callee = getSendingCallee()) {
|
||||
diagnoseNote(loc,
|
||||
diag::regionbasedisolation_named_send_never_sendable_callee,
|
||||
name, descriptiveKindStrWithSpace, calleeIsolationStr,
|
||||
isDisconnected, name, descriptiveKindStr, calleeIsolationStr,
|
||||
callee.value(), descriptiveKindStr);
|
||||
} else {
|
||||
diagnoseNote(loc, diag::regionbasedisolation_named_send_never_sendable,
|
||||
name, descriptiveKindStrWithSpace, calleeIsolationStr,
|
||||
isDisconnected, name, descriptiveKindStr, calleeIsolationStr,
|
||||
descriptiveKindStr);
|
||||
}
|
||||
}
|
||||
@@ -1736,34 +1625,21 @@ public:
|
||||
void emitNamedSendingNeverSendableToSendingParam(SILLocation loc,
|
||||
Identifier varName) {
|
||||
emitNamedOnlyError(loc, varName);
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
if (!getIsolationRegionInfo().isDisconnected()) {
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
bool isDisconnected = getIsolationRegionInfo().isDisconnected();
|
||||
auto diag = diag::regionbasedisolation_named_send_into_sending_param;
|
||||
diagnoseNote(loc, diag, descriptiveKindStr, varName);
|
||||
diagnoseNote(loc, diag, isDisconnected, descriptiveKindStr, varName);
|
||||
}
|
||||
|
||||
void emitNamedSendingReturn(SILLocation loc, Identifier varName) {
|
||||
emitNamedOnlyError(loc, varName);
|
||||
SmallString<64> descriptiveKindStr;
|
||||
SmallString<64> descriptiveKindStrWithSpace;
|
||||
{
|
||||
if (!getIsolationRegionInfo().isDisconnected()) {
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
descriptiveKindStrWithSpace = descriptiveKindStr;
|
||||
descriptiveKindStrWithSpace.push_back(' ');
|
||||
}
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
getIsolationRegionInfo().printForDiagnostics(getFunction());
|
||||
bool isDisconnected = getIsolationRegionInfo().isDisconnected();
|
||||
auto diag = diag::regionbasedisolation_named_nosend_send_into_result;
|
||||
diagnoseNote(loc, diag, descriptiveKindStrWithSpace, varName,
|
||||
diagnoseNote(loc, diag, isDisconnected, descriptiveKindStr, varName,
|
||||
descriptiveKindStr);
|
||||
}
|
||||
|
||||
@@ -2078,7 +1954,6 @@ bool SentNeverSendableDiagnosticInferrer::run() {
|
||||
return true;
|
||||
|
||||
// See if we can infer a name from the value.
|
||||
SmallString<64> resultingName;
|
||||
if (auto varName = inferNameHelper(op->get())) {
|
||||
diagnosticEmitter.emitNamedSendingNeverSendableToSendingParam(
|
||||
loc, *varName);
|
||||
@@ -2119,7 +1994,6 @@ bool SentNeverSendableDiagnosticInferrer::run() {
|
||||
}
|
||||
|
||||
// See if we can infer a name from the value.
|
||||
SmallString<64> resultingName;
|
||||
if (auto name = inferNameHelper(op->get())) {
|
||||
diagnosticEmitter.emitNamedIsolation(loc, *name, *isolation);
|
||||
return true;
|
||||
@@ -2167,7 +2041,6 @@ bool SentNeverSendableDiagnosticInferrer::run() {
|
||||
}) &&
|
||||
"All result info must be the same... if that changes... update "
|
||||
"this code!");
|
||||
SmallString<64> resultingName;
|
||||
if (auto name = inferNameHelper(op->get())) {
|
||||
diagnosticEmitter.emitNamedSendingReturn(loc, *name);
|
||||
return true;
|
||||
@@ -2316,12 +2189,8 @@ void InOutSendingNotDisconnectedDiagnosticEmitter::emit() {
|
||||
}
|
||||
|
||||
// Then emit the note with greater context.
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
actorIsolatedRegionInfo.printForDiagnostics(getFunction(), os);
|
||||
os << ' ';
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
actorIsolatedRegionInfo.printForDiagnostics(getFunction());
|
||||
|
||||
diagnoseError(
|
||||
functionExitingInst,
|
||||
@@ -2476,11 +2345,8 @@ static SILValue findOutParameter(SILValue v) {
|
||||
|
||||
void AssignIsolatedIntoSendingResultDiagnosticEmitter::emit() {
|
||||
// Then emit the note with greater context.
|
||||
SmallString<64> descriptiveKindStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(descriptiveKindStr);
|
||||
isolatedValueIsolationRegionInfo.printForDiagnostics(getFunction(), os);
|
||||
}
|
||||
auto descriptiveKindStr =
|
||||
isolatedValueIsolationRegionInfo.printForDiagnostics(getFunction());
|
||||
|
||||
// Grab the var name if we can find it.
|
||||
if (auto varName = VariableNameInferrer::inferName(srcOperand->get())) {
|
||||
@@ -2724,19 +2590,10 @@ void NonSendableIsolationCrossingResultDiagnosticEmitter::emit() {
|
||||
if (!isolationCrossing)
|
||||
return emitUnknownPatternError();
|
||||
|
||||
SmallString<64> calleeIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(calleeIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing->getCalleeIsolation(), os);
|
||||
}
|
||||
|
||||
SmallString<64> callerIsolationStr;
|
||||
{
|
||||
llvm::raw_svector_ostream os(callerIsolationStr);
|
||||
SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing->getCallerIsolation(), os);
|
||||
}
|
||||
auto calleeIsolationStr = SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing->getCalleeIsolation());
|
||||
auto callerIsolationStr = SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
getFunction(), isolationCrossing->getCallerIsolation());
|
||||
|
||||
auto type = getType();
|
||||
if (getCalledDecl()) {
|
||||
|
||||
@@ -1244,6 +1244,19 @@ void SILIsolationInfo::printOptions(llvm::raw_ostream &os) const {
|
||||
llvm::interleave(data, os, ", ");
|
||||
}
|
||||
|
||||
StringRef SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
SILFunction *fn, ActorIsolation iso, StringRef openingQuotationMark,
|
||||
bool asNoun) {
|
||||
SmallString<64> string;
|
||||
{
|
||||
llvm::raw_svector_ostream os(string);
|
||||
printActorIsolationForDiagnostics(fn, iso, os, openingQuotationMark,
|
||||
asNoun);
|
||||
}
|
||||
|
||||
return fn->getASTContext().getIdentifier(string).str();
|
||||
}
|
||||
|
||||
void SILIsolationInfo::printActorIsolationForDiagnostics(
|
||||
SILFunction *fn, ActorIsolation iso, llvm::raw_ostream &os,
|
||||
StringRef openingQuotationMark, bool asNoun) {
|
||||
@@ -1400,6 +1413,16 @@ void SILIsolationInfo::Profile(llvm::FoldingSetNodeID &id) const {
|
||||
}
|
||||
}
|
||||
|
||||
StringRef SILIsolationInfo::printForDiagnostics(SILFunction *fn) const {
|
||||
SmallString<64> string;
|
||||
{
|
||||
llvm::raw_svector_ostream os(string);
|
||||
printForDiagnostics(fn, os);
|
||||
}
|
||||
|
||||
return fn->getASTContext().getIdentifier(string).str();
|
||||
}
|
||||
|
||||
void SILIsolationInfo::printForDiagnostics(SILFunction *fn,
|
||||
llvm::raw_ostream &os) const {
|
||||
switch (Kind(*this)) {
|
||||
@@ -1459,6 +1482,16 @@ void SILIsolationInfo::printForDiagnostics(SILFunction *fn,
|
||||
}
|
||||
}
|
||||
|
||||
StringRef SILIsolationInfo::printForCodeDiagnostic(SILFunction *fn) const {
|
||||
SmallString<64> string;
|
||||
{
|
||||
llvm::raw_svector_ostream os(string);
|
||||
printForCodeDiagnostic(fn, os);
|
||||
}
|
||||
|
||||
return fn->getASTContext().getIdentifier(string).str();
|
||||
}
|
||||
|
||||
void SILIsolationInfo::printForCodeDiagnostic(SILFunction *fn,
|
||||
llvm::raw_ostream &os) const {
|
||||
switch (Kind(*this)) {
|
||||
|
||||
Reference in New Issue
Block a user