[llvm] r212305 - Modify LTOModule::isTargetMatch to take a StringRef instead of a MemoryBuffer.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Jul 4 06:31:53 PDT 2014


> -/// isTargetMatch - Returns 'true' if the memory buffer is for the specified
> -/// target triple.
> -bool LTOModule::isTargetMatch(MemoryBuffer *buffer, const char *triplePrefix) {
> -  std::string Triple = getBitcodeTargetTriple(buffer, getGlobalContext());
> -  delete buffer;
> -  return strncmp(Triple.c_str(), triplePrefix, strlen(triplePrefix)) == 0;
> +/// Returns 'true' if the bitcode BC is for the specified target triple.
> +bool LTOModule::isTargetMatch(StringRef BC, const char *TriplePrefix) {
> +  std::unique_ptr<MemoryBuffer> Buffer(
> +      MemoryBuffer::getMemBuffer(BC, "", false));
> +  std::string Triple = getBitcodeTargetTriple(Buffer.get(), getGlobalContext());
> +  return strncmp(Triple.c_str(), TriplePrefix, strlen(TriplePrefix)) == 0;
>  }
>

Sorry, I didn't noticed the lower level API would require a
MemoryBuffer to be created from the StringRef. That is really
undesirable since MemoryBuffer has to be heap allocated.

Cheers,
Rafael



More information about the llvm-commits mailing list