diff --git a/lib/PrintAsClang/DeclAndTypePrinter.cpp b/lib/PrintAsClang/DeclAndTypePrinter.cpp index ea84364f60407..c8e4b50c87744 100644 --- a/lib/PrintAsClang/DeclAndTypePrinter.cpp +++ b/lib/PrintAsClang/DeclAndTypePrinter.cpp @@ -1574,7 +1574,7 @@ class DeclAndTypePrinter::Implementation } os << "\n"; if (representation.isObjCxxOnly()) - os << "#endif\n"; + os << "#endif // defined(__OBJC__)\n"; return representation; } @@ -1684,7 +1684,7 @@ class DeclAndTypePrinter::Implementation FD->getParameters(), funcTy->isThrowing(), funcTy); os << "}\n"; if (result.isObjCxxOnly()) - os << "#endif\n"; + os << "#endif // defined(__OBJC__)\n"; } enum class PrintLeadingSpace : bool { diff --git a/lib/PrintAsClang/PrintAsClang.cpp b/lib/PrintAsClang/PrintAsClang.cpp index 26be623ed744b..a24d1f405aac7 100644 --- a/lib/PrintAsClang/PrintAsClang.cpp +++ b/lib/PrintAsClang/PrintAsClang.cpp @@ -55,7 +55,7 @@ static void emitObjCConditional(raw_ostream &out, out << "#else\n"; nonObjCCase(); } - out << "#endif\n"; + out << "#endif // defined(__OBJC__)\n"; } static void emitExternC(raw_ostream &out, diff --git a/lib/PrintAsClang/PrintClangFunction.cpp b/lib/PrintAsClang/PrintClangFunction.cpp index 2d35051cbe57d..91a3b2d4c3328 100644 --- a/lib/PrintAsClang/PrintClangFunction.cpp +++ b/lib/PrintAsClang/PrintClangFunction.cpp @@ -1686,7 +1686,7 @@ void DeclAndTypeClangFunctionPrinter::printCxxMethod( if (!isDefinition) { os << ";\n"; if (result.isObjCxxOnly()) - os << "#endif\n"; + os << "#endif // defined(__OBJC__)\n"; return; } @@ -1699,7 +1699,7 @@ void DeclAndTypeClangFunctionPrinter::printCxxMethod( dispatchInfo); os << " }\n"; if (result.isObjCxxOnly()) - os << "#endif\n"; + os << "#endif // defined(__OBJC__)\n"; } /// Returns true if the given property name like `isEmpty` can be remapped diff --git a/lib/PrintAsClang/PrintClangValueType.cpp b/lib/PrintAsClang/PrintClangValueType.cpp index d9d900605eab9..3bf640e85e760 100644 --- a/lib/PrintAsClang/PrintClangValueType.cpp +++ b/lib/PrintAsClang/PrintClangValueType.cpp @@ -737,7 +737,7 @@ void ClangValueTypePrinter::printTypeGenericTraits( os << "} // namespace\n"; os << "#pragma clang diagnostic pop\n"; if (objCxxOnly) - os << "#endif // #if defined(__OBJC__)\n"; + os << "#endif // defined(__OBJC__)\n"; os << "} // namespace swift\n"; os << "\n"; printer.printModuleNamespaceStart(*moduleContext); diff --git a/test/PrintAsObjC/Inputs/comments-expected-output.h b/test/PrintAsObjC/Inputs/comments-expected-output.h index 1b84ee3a21d26..6b57ae5fe42bc 100644 --- a/test/PrintAsObjC/Inputs/comments-expected-output.h +++ b/test/PrintAsObjC/Inputs/comments-expected-output.h @@ -412,7 +412,7 @@ SWIFT_CLASS("_TtC8comments13UnorderedList") - (void)f0; @end -#endif +#endif // defined(__OBJC__) #if __has_attribute(external_source_symbol) # pragma clang attribute pop #endif