Index: include/llvm/ADT/StringRef.h
===================================================================
--- include/llvm/ADT/StringRef.h	(révision 131339)
+++ include/llvm/ADT/StringRef.h	(copie de travail)
@@ -46,7 +46,16 @@
     // integer works around this bug.
     static size_t min(size_t a, size_t b) { return a < b ? a : b; }
     static size_t max(size_t a, size_t b) { return a > b ? a : b; }
-
+    
+    // Workaround memcmp issue with null pointers (undefined behavior)
+    // by providing a specialized version
+    static int memcmp(const char *Lhs, const char *Rhs, size_t Length) {
+      if (Length == 0) { return 0; }
+      assert(Lhs && "memcmp - Lhs should be non-null when Length is not 0");
+      assert(Rhs && "memcmp - Rhs should be non-null when Length is not 0");
+      return ::memcmp(Lhs,Rhs,Length);
+    }
+    
   public:
     /// @name Constructors
     /// @{
@@ -56,7 +65,10 @@
 
     /// Construct a string ref from a cstring.
     /*implicit*/ StringRef(const char *Str)
-      : Data(Str), Length(::strlen(Str)) {}
+      : Data(Str), Length() {
+        assert(Str && "StringRef cannot be built from a NULL argument");
+        Length = ::strlen(Str); // invoking strlen(NULL) is undefined behavior
+      }
 
     /// Construct a string ref from a pointer and length.
     /*implicit*/ StringRef(const char *data, size_t length)
