@@ -286,8 +286,31 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
286286 // We only care about macros, so skip everything else.
287287 if (generatedInfo->kind != GeneratedSourceInfo::ReplacedFunctionBody &&
288288 generatedInfo->kind != GeneratedSourceInfo::PrettyPrinted)
289- if (auto *MemBuf = SM.getLLVMSourceMgr ().getMemoryBuffer (BufferID))
289+ if (auto *MemBuf = SM.getLLVMSourceMgr ().getMemoryBuffer (BufferID)) {
290290 Source = MemBuf->getBuffer ();
291+ // This is copying the buffer twice, but Xcode depends on this
292+ // comment in the file.
293+ auto origRange = generatedInfo->originalSourceRange ;
294+ if (origRange.isValid ()) {
295+ std::string s;
296+ {
297+ llvm::raw_string_ostream buffer (s);
298+ buffer << MemBuf->getBuffer () << " \n " ;
299+ auto originalFilename =
300+ SM.getDisplayNameForLoc (origRange.getStart (), true );
301+ unsigned startLine, startColumn, endLine, endColumn;
302+ std::tie (startLine, startColumn) =
303+ SM.getPresumedLineAndColumnForLoc (origRange.getStart ());
304+ std::tie (endLine, endColumn) =
305+ SM.getPresumedLineAndColumnForLoc (origRange.getEnd ());
306+ buffer << " // original-source-range: "
307+ << DebugPrefixMap.remapPath (originalFilename) << " :"
308+ << startLine << " :" << startColumn << " -" << endLine
309+ << " :" << endColumn << " \n " ;
310+ }
311+ Source = BumpAllocatedString (s);
312+ }
313+ }
291314 }
292315 }
293316 Cached.File = getOrCreateFile (
0 commit comments