summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-06-27 06:02:00 +0000
committerAlp Toker <alp@nuanti.com>2014-06-27 06:02:00 +0000
commit602e633a37d50865953ffcc41b0520edc58778a8 (patch)
tree8de8898e338022c508a1a2d45c1ab3ae14dea2f5
parent3f48d22b9ea26f03a28b54cb3c4bcd920b3496a7 (diff)
downloadclang-602e633a37d50865953ffcc41b0520edc58778a8.tar.gz
clang-602e633a37d50865953ffcc41b0520edc58778a8.tar.bz2
clang-602e633a37d50865953ffcc41b0520edc58778a8.tar.xz
Add a FIXME for an unfortunate issue in ConvertBackendLocation()
This function is copying the entire file contents into memory repeatedly and allocating new file IDs *each time* a source location is processed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211874 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CodeGenAction.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp
index 2b7fab3beb..1a092fcedb 100644
--- a/lib/CodeGen/CodeGenAction.cpp
+++ b/lib/CodeGen/CodeGenAction.cpp
@@ -267,13 +267,15 @@ static FullSourceLoc ConvertBackendLocation(const llvm::SMDiagnostic &D,
LSM.getMemoryBuffer(LSM.FindBufferContainingLoc(D.getLoc()));
// Create the copy and transfer ownership to clang::SourceManager.
+ // TODO: Avoid copying files into memory.
llvm::MemoryBuffer *CBuf =
llvm::MemoryBuffer::getMemBufferCopy(LBuf->getBuffer(),
LBuf->getBufferIdentifier());
+ // FIXME: Keep a file ID map instead of creating new IDs for each location.
FileID FID = CSM.createFileID(CBuf);
// Translate the offset into the file.
- unsigned Offset = D.getLoc().getPointer() - LBuf->getBufferStart();
+ unsigned Offset = D.getLoc().getPointer() - LBuf->getBufferStart();
SourceLocation NewLoc =
CSM.getLocForStartOfFile(FID).getLocWithOffset(Offset);
return FullSourceLoc(NewLoc, CSM);