[llvm-commits] [llvm] r125228 - in /llvm/trunk: include/llvm/Support/PathV2.h lib/Support/Unix/PathV2.inc

Kevin Enderby enderby at apple.com
Wed Feb 9 14:41:47 PST 2011


Hi Doug,

Looks like two of the returns with arguments are causing problems for the build bots:

/Users/buildslave/zorg/buildbot/smooshlab/slave/build.llvm-gcc-i386-darwin9/llvm.src/lib/Support/Unix/PathV2.inc: In function 'void llvm::sys::path::canonical(const char*, llvm::SmallVectorImpl<char>&)':
/Users/buildslave/zorg/buildbot/smooshlab/slave/build.llvm-gcc-i386-darwin9/llvm.src/lib/Support/Unix/PathV2.inc:525: error: return-statement with a value, in function returning 'void'
/Users/buildslave/zorg/buildbot/smooshlab/slave/build.llvm-gcc-i386-darwin9/llvm.src/lib/Support/Unix/PathV2.inc:531: error: return-statement with a value, in function returning 'void'
On Feb 9, 2011, at 2:11 PM, Douglas Gregor wrote:

> Author: dgregor
> Date: Wed Feb  9 16:11:23 2011
> New Revision: 125228
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=125228&view=rev
> Log:
> Add llvm::sys::path::canonical(), which provides the canonicalized
> name of a path, after resolving symbolic links and eliminating excess
> path elements such as "foo/../" and "./".
> 
> This routine still needs a Windows implementation, but I don't have a
> Windows machine available. Help? Please?
> 
> Modified:
>    llvm/trunk/include/llvm/Support/PathV2.h
>    llvm/trunk/lib/Support/Unix/PathV2.inc
> 
> Modified: llvm/trunk/include/llvm/Support/PathV2.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV2.h?rev=125228&r1=125227&r2=125228&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/PathV2.h (original)
> +++ llvm/trunk/include/llvm/Support/PathV2.h Wed Feb  9 16:11:23 2011
> @@ -244,6 +244,15 @@
> /// @result The stem of \a path.
> const StringRef stem(StringRef path);
> 
> +/// Convert path to a canonical form, resolving symbolic links and removing
> +/// unnecessary path elements (e.g., "foo/../", "./"). 
> +///
> +/// @param path A path that is going to be canonicalized by resolving symlinks
> +/// and removing unnecessary path elements (e.g., "./").
> +///
> +/// @param buffer The resulting canonical path.
> +void canonical(const char *path, SmallVectorImpl<char> &result);
> +  
> /// @brief Get extension.
> ///
> /// If filename contains a dot but not solely one or two dots, result is the
> 
> Modified: llvm/trunk/lib/Support/Unix/PathV2.inc
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=125228&r1=125227&r2=125228&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/Unix/PathV2.inc (original)
> +++ llvm/trunk/lib/Support/Unix/PathV2.inc Wed Feb  9 16:11:23 2011
> @@ -503,5 +503,35 @@
> }
> 
> } // end namespace fs
> +
> +namespace path {
> +
> +void canonical(const char *path, SmallVectorImpl<char> &buffer) {
> +  buffer.resize(PATH_MAX);
> +  char *result = realpath(path, buffer.data());
> +  if (result) {
> +    buffer.resize(strlen(result));
> +    return;
> +  }
> +
> +  // A common extension is to support memory allocation of the result when
> +  // passing NULL as the second argument.
> +  result = realpath(path, 0);
> +  if (result) {
> +    size_t length = strlen(result);
> +    buffer.resize(length);
> +    memcpy(buffer.data(), result, length);
> +    free(result);
> +    return buffer.data();
> +  }
> +
> +  size_t length = strlen(path);
> +  buffer.resize(length);
> +  memcpy(buffer.data(), path, length);
> +  return path;
> +}
> +
> +} // end namespace path
> +
> } // end namespace sys
> } // end namespace llvm
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110209/27aa64fa/attachment.html>


More information about the llvm-commits mailing list