[llvm-commits] [llvm] r118089 - in /llvm/trunk: include/llvm/System/Path.h lib/System/Path.cpp lib/System/Unix/Path.inc lib/System/Win32/Path.inc

Mikhail Glushenkov foldr at codedgers.com
Tue Nov 2 15:18:37 PDT 2010


Author: foldr
Date: Tue Nov  2 17:18:37 2010
New Revision: 118089

URL: http://llvm.org/viewvc/llvm-project?rev=118089&view=rev
Log:
appendSuffix: don't append a dot when the suffix is empty.

Additionally, move the implementation of appendSuffix to Path.cpp: it is
platform-independent.

Modified:
    llvm/trunk/include/llvm/System/Path.h
    llvm/trunk/lib/System/Path.cpp
    llvm/trunk/lib/System/Unix/Path.inc
    llvm/trunk/lib/System/Win32/Path.inc

Modified: llvm/trunk/include/llvm/System/Path.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=118089&r1=118088&r2=118089&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/Path.h (original)
+++ llvm/trunk/include/llvm/System/Path.h Tue Nov  2 17:18:37 2010
@@ -454,7 +454,8 @@
       /// The precondition for this function is that the Path reference a file
       /// name (i.e. isFile() returns true). If the Path is not a file, no
       /// action is taken and the function returns false. If the path would
-      /// become invalid for the host operating system, false is returned.
+      /// become invalid for the host operating system, false is returned. When
+      /// the \p suffix is empty, no action is performed.
       /// @returns false if the suffix could not be added, true if it was.
       /// @brief Adds a period and the \p suffix to the end of the pathname.
       bool appendSuffix(StringRef suffix);

Modified: llvm/trunk/lib/System/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Path.cpp?rev=118089&r1=118088&r2=118089&view=diff
==============================================================================
--- llvm/trunk/lib/System/Path.cpp (original)
+++ llvm/trunk/lib/System/Path.cpp Tue Nov  2 17:18:37 2010
@@ -196,6 +196,21 @@
 }
 
 bool
+Path::appendSuffix(StringRef suffix) {
+  if (!suffix.empty()) {
+    std::string save(path);
+    path.append(".");
+    path.append(suffix);
+    if (!isValid()) {
+      path = save;
+      return false;
+    }
+  }
+
+  return true;
+}
+
+bool
 Path::isBitcodeFile() const {
   std::string actualMagic;
   if (!getMagicNumber(actualMagic, 4))

Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=118089&r1=118088&r2=118089&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Tue Nov  2 17:18:37 2010
@@ -638,18 +638,6 @@
 }
 
 bool
-Path::appendSuffix(StringRef suffix) {
-  std::string save(path);
-  path.append(".");
-  path.append(suffix);
-  if (!isValid()) {
-    path = save;
-    return false;
-  }
-  return true;
-}
-
-bool
 Path::eraseSuffix() {
   std::string save = path;
   size_t dotpos = path.rfind('.',path.size());

Modified: llvm/trunk/lib/System/Win32/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=118089&r1=118088&r2=118089&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/Path.inc (original)
+++ llvm/trunk/lib/System/Win32/Path.inc Tue Nov  2 17:18:37 2010
@@ -552,18 +552,6 @@
 }
 
 bool
-Path::appendSuffix(StringRef suffix) {
-  std::string save(path);
-  path.append(".");
-  path.append(suffix);
-  if (!isValid()) {
-    path = save;
-    return false;
-  }
-  return true;
-}
-
-bool
 Path::eraseSuffix() {
   size_t dotpos = path.rfind('.',path.size());
   size_t slashpos = path.rfind('/',path.size());





More information about the llvm-commits mailing list