[llvm] dcc4b94 - [llvm-c] Document that LLVMGetElementType on pointers is deprecated (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 00:28:33 PST 2022


Author: Nikita Popov
Date: 2022-03-11T09:28:18+01:00
New Revision: dcc4b94d9438af96fb00c015b4f4715e45ec347a

URL: https://github.com/llvm/llvm-project/commit/dcc4b94d9438af96fb00c015b4f4715e45ec347a
DIFF: https://github.com/llvm/llvm-project/commit/dcc4b94d9438af96fb00c015b4f4715e45ec347a.diff

LOG: [llvm-c] Document that LLVMGetElementType on pointers is deprecated (NFC)

We can't actually deprecate the function, because it is also used
for arrays and vectors, so we can only document this.

Added: 
    

Modified: 
    llvm/include/llvm-c/Core.h
    llvm/lib/IR/Core.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 09d80841fa5d3..dfec99e1bb078 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -1391,9 +1391,9 @@ LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
  */
 
 /**
- * Obtain the type of elements within a sequential type.
+ * Obtain the element type of an array or vector type.
  *
- * This works on array, vector, and pointer types.
+ * This currently also works for pointer types, but this usage is deprecated.
  *
  * @see llvm::SequentialType::getElementType()
  */

diff  --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 7ed156d552b1f..182be54c844bd 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -798,7 +798,7 @@ LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,
 LLVMTypeRef LLVMGetElementType(LLVMTypeRef WrappedTy) {
   auto *Ty = unwrap<Type>(WrappedTy);
   if (auto *PTy = dyn_cast<PointerType>(Ty))
-    return wrap(PTy->getPointerElementType());
+    return wrap(PTy->getNonOpaquePointerElementType());
   if (auto *ATy = dyn_cast<ArrayType>(Ty))
     return wrap(ATy->getElementType());
   return wrap(cast<VectorType>(Ty)->getElementType());


        


More information about the llvm-commits mailing list