[PATCH] D56870: [adt] Twine(nullptr) derefs the nullptr. Add a deleted Twine(std::nullptr_t)

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 18 10:44:29 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL351572: [adt] Twine(nullptr) derefs the nullptr. Add a deleted Twine(std::nullptr_t) (authored by dsanders, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56870/new/

https://reviews.llvm.org/D56870

Files:
  llvm/trunk/include/llvm/ADT/Twine.h
  llvm/trunk/include/llvm/IR/IRBuilder.h


Index: llvm/trunk/include/llvm/IR/IRBuilder.h
===================================================================
--- llvm/trunk/include/llvm/IR/IRBuilder.h
+++ llvm/trunk/include/llvm/IR/IRBuilder.h
@@ -1004,7 +1004,7 @@
   }
 
   Value *foldConstant(Instruction::BinaryOps Opc, Value *L,
-                      Value *R, const Twine &Name = nullptr) const {
+                      Value *R, const Twine &Name) const {
     auto *LC = dyn_cast<Constant>(L);
     auto *RC = dyn_cast<Constant>(R);
     return (LC && RC) ? Insert(Folder.CreateBinOp(Opc, LC, RC), Name) : nullptr;
Index: llvm/trunk/include/llvm/ADT/Twine.h
===================================================================
--- llvm/trunk/include/llvm/ADT/Twine.h
+++ llvm/trunk/include/llvm/ADT/Twine.h
@@ -274,6 +274,9 @@
 
       assert(isValid() && "Invalid twine!");
     }
+    /// Delete the implicit conversion from nullptr as Twine(const char *)
+    /// cannot take nullptr.
+    /*implicit*/ Twine(std::nullptr_t) = delete;
 
     /// Construct from an std::string.
     /*implicit*/ Twine(const std::string &Str) : LHSKind(StdStringKind) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56870.182560.patch
Type: text/x-patch
Size: 1119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190118/5972d31f/attachment.bin>


More information about the llvm-commits mailing list