]> granicus.if.org Git - llvm/commit
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)
commitd75c17840807eb766ddaece87f32a9bd083093fa
treeb49a7608709dd8b2edde359b0fab5e1a7950efe3
parent7e34ddb6ca83485ff0f21b847e4ddb4230422f6b
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286139 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/StringRef.h