r211874 - Add a FIXME for an unfortunate issue in ConvertBackendLocation()

Alp Toker alp at nuanti.com
Thu Jun 26 23:02:00 PDT 2014


Author: alp
Date: Fri Jun 27 01:02:00 2014
New Revision: 211874

URL: http://llvm.org/viewvc/llvm-project?rev=211874&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=211874&r1=211873&r2=211874&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Jun 27 01:02:00 2014
@@ -267,13 +267,15 @@ static FullSourceLoc ConvertBackendLocat
   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);





More information about the cfe-commits mailing list