Skip to content

Commit 4a9cda9

Browse files
authored
Merge pull request #27630 from ravikandhadai/minor-comment-fixes
2 parents 7d437ec + 05e24c0 commit 4a9cda9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/SILOptimizer/Mandatory/OSLogOptimization.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,9 @@ static ApplyInst *getAsOSLogMessageInit(SILInstruction *inst) {
783783
return nullptr;
784784
}
785785

786-
/// Return true iff this function is a protocol witness for
787-
/// ExpressibleByStringInterpolation.init(stringInterpolation:) in OSLogMessage.
788-
bool isAutoGeneratedInitOfOSLogMessage(SILFunction &fun) {
786+
/// Return true iff the SIL function \c fun is a method of the \c OSLogMessage
787+
/// type.
788+
bool isMethodOfOSLogMessage(SILFunction &fun) {
789789
DeclContext *declContext = fun.getDeclContext();
790790
if (!declContext)
791791
return false;
@@ -818,11 +818,15 @@ class OSLogOptimization : public SILFunctionTransform {
818818
return;
819819
}
820820

821-
// Skip the auto-generated (transparent) witness method of OSLogMessage,
822-
// which ends up invoking the OSLogMessage initializer:
823-
// "oslog.message.init_interpolation" but without an interpolated
824-
// string literal.
825-
if (isAutoGeneratedInitOfOSLogMessage(fun)) {
821+
// Skip methods of OSLogMessage type. This avoid unnecessary work and also
822+
// avoids falsely diagnosing the auto-generated (transparent) witness method
823+
// of OSLogMessage, which ends up invoking the OSLogMessage initializer:
824+
// "oslog.message.init_interpolation" without an interpolated string
825+
// literal that is expected by this pass.
826+
// TODO: this check can be eliminated if there is a separate pass for
827+
// diagnosing errors in the use of the OSLogMessage type, and this pass
828+
// bails out when a use of the type is not optimizable.
829+
if (isMethodOfOSLogMessage(fun)) {
826830
return;
827831
}
828832

0 commit comments

Comments
 (0)