[LLVMdev] LLVM-2.7 to 2.8 subtle change: MemoryBuffer::getMemBuffer

Solomon Boulos sboulos at imageworks.com
Fri Oct 1 16:28:25 PDT 2010


Hi guys,

In porting our project over to LLVM-2.8 today I ran into a change that should probably go in the 2.8 release notes. After r100485, the MemoryBuffer::getMemBuffer went from:

  /// getMemBuffer - Open the specified memory range as a MemoryBuffer.  Note                                           
  /// that EndPtr[0] must be a null byte and be accessible!                                                             
  static MemoryBuffer *getMemBuffer(const char *StartPtr, const char *EndPtr,
                                    const char *BufferName = "");

to the current (after the StringRef change to BufferName too)

  /// getMemBuffer - Open the specified memory range as a MemoryBuffer.  Note                                           
  /// that EndPtr[0] must be a null byte and be accessible!                                                             
  static MemoryBuffer *getMemBuffer(StringRef InputData,
                                    StringRef BufferName = "");

Like the code in clang, our code was using MemoryBuffer::getMemBuffer(start, start + size) which unfortunately automatically translates into the pair of StringRef version (leading to a confusing error about an invalid header in the bitcode). Worse yet the doxygen comment isn't up to date either.

I assume there could be more const char* to StringRef related issues throughout the code like this one, but we don't seem to have triggered any others.

Solomon 






More information about the llvm-dev mailing list