Disallow StringRef assignment from temporary std::strings.
authorJordan Rose <jordan_rose@apple.com>
Mon, 7 Nov 2016 20:34:16 +0000 (20:34 +0000)
committerJordan Rose <jordan_rose@apple.com>
Mon, 7 Nov 2016 20:34:16 +0000 (20:34 +0000)
commitf1271c8d087273af381e2ae5e447c2314c4a1f74
treeff19f2990221c3f354a7a22057962a88a8337d41
parent7b48463d3d80509eeca2ed3fa23f7e41d0b954eb
Disallow StringRef assignment from temporary std::strings.

Similar to r283798, this prevents accidentally referring to temporary
storage that goes out of scope by the end of the statement:

  someStringRef = getStringByValue();
  someStringRef = (Twine("-") + otherString).str();

Note that once again the constructor still has this problem:

  StringRef someStringRef = getStringByValue();

because once again we occasionally rely on this in calls:

  takesStringRef(getStringByValue());
  takesStringRef(Twine("-") + otherString);

Still, it's a step.

llvm-svn: 286139
llvm/include/llvm/ADT/StringRef.h