@@ -286,8 +286,31 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
286
286
// We only care about macros, so skip everything else.
287
287
if (generatedInfo->kind != GeneratedSourceInfo::ReplacedFunctionBody &&
288
288
generatedInfo->kind != GeneratedSourceInfo::PrettyPrinted)
289
- if (auto *MemBuf = SM.getLLVMSourceMgr ().getMemoryBuffer (BufferID))
289
+ if (auto *MemBuf = SM.getLLVMSourceMgr ().getMemoryBuffer (BufferID)) {
290
290
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
+ }
291
314
}
292
315
}
293
316
Cached.File = getOrCreateFile (
0 commit comments