[llvm] Correct lie in contract (PR #82517)

Dave Abrahams via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 09:40:34 PST 2024


https://github.com/dabrahams updated https://github.com/llvm/llvm-project/pull/82517

>From 3f0835884362a3912457940cc32a35b0673add8f Mon Sep 17 00:00:00 2001
From: Dave Abrahams <dabrahams at adobe.com>
Date: Wed, 21 Feb 2024 10:23:23 -0800
Subject: [PATCH 1/2] Correct lie in contract

The method asserts when passed a null pointer.
---
 llvm/include/llvm/IR/GlobalVariable.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/IR/GlobalVariable.h b/llvm/include/llvm/IR/GlobalVariable.h
index bcaf8e91432ba9..d76db8463c9dfa 100644
--- a/llvm/include/llvm/IR/GlobalVariable.h
+++ b/llvm/include/llvm/IR/GlobalVariable.h
@@ -146,8 +146,8 @@ class GlobalVariable : public GlobalObject, public ilist_node<GlobalVariable> {
     assert(hasInitializer() && "GV doesn't have initializer!");
     return static_cast<Constant*>(Op<0>().get());
   }
-  /// setInitializer - Sets the initializer for this global variable, removing
-  /// any existing initializer if InitVal==NULL.  If this GV has type T*, the
+  /// setInitializer - Sets the initializer for this global variable to 
+  /// InitVal, which must be non-null.  If this GV has type T*, the
   /// initializer must have type T.
   void setInitializer(Constant *InitVal);
 

>From 02543fffc54a95147aab899938601d287e66a6d6 Mon Sep 17 00:00:00 2001
From: Dave Abrahams <dabrahams at adobe.com>
Date: Fri, 23 Feb 2024 09:40:28 -0800
Subject: [PATCH 2/2] Whitespace

---
 llvm/include/llvm/IR/GlobalVariable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/IR/GlobalVariable.h b/llvm/include/llvm/IR/GlobalVariable.h
index d76db8463c9dfa..5108d5eec292e9 100644
--- a/llvm/include/llvm/IR/GlobalVariable.h
+++ b/llvm/include/llvm/IR/GlobalVariable.h
@@ -146,7 +146,7 @@ class GlobalVariable : public GlobalObject, public ilist_node<GlobalVariable> {
     assert(hasInitializer() && "GV doesn't have initializer!");
     return static_cast<Constant*>(Op<0>().get());
   }
-  /// setInitializer - Sets the initializer for this global variable to 
+  /// setInitializer - Sets the initializer for this global variable to
   /// InitVal, which must be non-null.  If this GV has type T*, the
   /// initializer must have type T.
   void setInitializer(Constant *InitVal);



More information about the llvm-commits mailing list