From: James Y Knight <jyknight@google.com>
Date: Mon, 14 Jan 2019 17:16:55 +0000 (+0000)
Subject: Remove NameLen argument from newly-introduced IR C APIs.
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f613a607d8d19203372de0bd495ade3d9cd59af;p=llvm

Remove NameLen argument from newly-introduced IR C APIs.

Normally, changing the function signatures of C APIs is disallowed,
but as these two are brand new last week, and haven't been released
yet, it is okay in this instance.

As per discussion in D56556, we will not add NameLen arguments to IR
building APIs, for the following reasons:

1. We do not want to deprecate all of the IR building APIs, just to add a
NameLen argument to each one.

2. Consistency is important, so adding it just to new ones is unfortunate.

3. The IR names are completely optional, useful for readability of IR
only. There is no value in ever supporting nul bytes.

Differential Revision: https://reviews.llvm.org/D56669

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351076 91177308-0d34-0410-b5e6-96231b3b80d8
---

diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h
index e22e4b78eec..8a67e3bba3d 100644
--- a/include/llvm-c/Core.h
+++ b/include/llvm-c/Core.h
@@ -2812,8 +2812,7 @@ LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
  * @see llvm::BasicBlock::Create()
  */
 LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
-                                                const char *Name,
-                                                size_t NameLen);
+                                                const char *Name);
 
 /**
  * Append a basic block to the end of a function.
@@ -3644,7 +3643,7 @@ LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
                                   LLVMTypeRef DestTy, const char *Name);
 LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,
                                LLVMTypeRef DestTy, LLVMBool IsSigned,
-                               const char *Name, size_t NameLen);
+                               const char *Name);
 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
                              LLVMTypeRef DestTy, const char *Name);
 
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp
index 6f7c7afc59d..357b8cd43ab 100644
--- a/lib/IR/Core.cpp
+++ b/lib/IR/Core.cpp
@@ -2533,9 +2533,8 @@ LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB) {
 }
 
 LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
-                                                const char *Name,
-                                                size_t NameLen) {
-  return wrap(llvm::BasicBlock::Create(*unwrap(C), StringRef(Name, NameLen)));
+                                                const char *Name) {
+  return wrap(llvm::BasicBlock::Create(*unwrap(C), Name));
 }
 
 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
@@ -3542,9 +3541,9 @@ LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef B, LLVMValueRef Val,
 
 LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef B, LLVMValueRef Val,
                                LLVMTypeRef DestTy, LLVMBool IsSigned,
-                               const char *Name, size_t NameLen) {
-  return wrap(unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy),
-                                       IsSigned, StringRef(Name, NameLen)));
+                               const char *Name) {
+  return wrap(
+      unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy), IsSigned, Name));
 }
 
 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef B, LLVMValueRef Val,