[ADT] Delete the Twine assignment operator
authorReid Kleckner <reid@kleckner.net>
Thu, 29 May 2014 17:12:05 +0000 (17:12 +0000)
committerReid Kleckner <reid@kleckner.net>
Thu, 29 May 2014 17:12:05 +0000 (17:12 +0000)
This makes it slightly harder to misuse Twines.  It is still possible to
refer to destroyed temporaries with the regular constructors, though.

Patch by Marco Alesiani!

llvm-svn: 209832

llvm/include/llvm/ADT/Twine.h

index a54fd74..4be3ee6 100644 (file)
@@ -182,6 +182,10 @@ namespace llvm {
       assert(isValid() && "Invalid twine!");
     }
 
+    /// Since the intended use of twines is as temporary objects, assignments
+    /// when concatenating might cause undefined behavior or stack corruptions
+    Twine &operator=(const Twine &Other) LLVM_DELETED_FUNCTION;
+
     /// isNull - Check for the null twine.
     bool isNull() const {
       return getLHSKind() == NullKind;