On Darwin, the string header file isn't 64-bit clean. The use of
authorBill Wendling <isanbard@gmail.com>
Sat, 17 May 2008 09:10:40 +0000 (09:10 +0000)
committerBill Wendling <isanbard@gmail.com>
Sat, 17 May 2008 09:10:40 +0000 (09:10 +0000)
"-Wshorten-64-to-32 -Werror" will cause a failure when compiling this complex
program:

#include <string>

class Path {
  mutable std::string path;
public:
  bool operator == (const Path &that) {
    return path == that.path;
  }
};

Using strcmp gets us past this annoying error.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51218 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Path.h

index ba251a9dbbc825d5266b0463f99eb2a78098dc4e..00e4ea3af01edd911f2cf4c4aeb6a9cde2c0c0ca 100644 (file)
@@ -206,14 +206,14 @@ namespace sys {
       /// @returns true if \p this and \p that refer to the same thing.
       /// @brief Equality Operator
       bool operator==(const Path &that) const {
-        return path == that.path;
+        return strcmp(path.c_str(), that.path.c_str()) == 0;
       }
 
       /// Compares \p this Path with \p that Path for inequality.
       /// @returns true if \p this and \p that refer to different things.
       /// @brief Inequality Operator
       bool operator!=(const Path &that) const {
-        return path != that.path;
+        return strcmp(path.c_str(), that.path.c_str()) != 0;
       }
 
       /// Determines if \p this Path is less than \p that Path. This is required
@@ -223,7 +223,7 @@ namespace sys {
       /// @returns true if \p this path is lexicographically less than \p that.
       /// @brief Less Than Operator
       bool operator<(const Path& that) const {
-        return path < that.path;
+        return strcmp(path.c_str(), that.path.c_str()) < 0;
       }
 
     /// @}