[llvm-commits] [llvm] r162090 - /llvm/trunk/include/llvm/Support/NoFolder.h

Jin Gu Kang jaykang10 at imrc.kist.re.kr
Fri Aug 17 02:21:09 PDT 2012


Thanks for your comment,

This comment means that this function's goal is to avoid ambigious overload error as following when we use NoFolder.

/llvm-3.1.src/include/llvm/Support/IRBuilder.h:841: error: call of overloaded ‘CreateGetElementPtr(llvm::Constant*&, llvm::Constant*&)’ is ambiguous
/llvm-3.1.src/include/llvm/Support/NoFolder.h:180: note: candidates are: llvm::Constant* llvm::NoFolder::CreateGetElementPtr(llvm::Constant*, llvm::ArrayRef<llvm::Constant*>) const
/llvm-3.1.src/include/llvm/Support/NoFolder.h:194: note:                 llvm::Instruction* llvm::NoFolder::CreateGetElementPtr(llvm::Constant*, llvm::ArrayRef<llvm::Value*>) const

What do you think about this comment?

"Insertion of NoFolder functions to avoid ambiguous overload warnings or errors like ConstantFolder and TargetFolder."

Thanks,
Jin-Gu Kang
________________________________
From: Chandler Carruth [chandlerc at google.com]
Sent: Friday, August 17, 2012 6:01 PM
To: Jin Gu Kang
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] [llvm] r162090 - /llvm/trunk/include/llvm/Support/NoFolder.h

On Fri, Aug 17, 2012 at 1:54 AM, Jin-Gu Kang <jaykang10 at imrc.kist.re.kr<mailto:jaykang10 at imrc.kist.re.kr>> wrote:
Author: jaykang10
Date: Fri Aug 17 03:54:57 2012
New Revision: 162090

URL: http://llvm.org/viewvc/llvm-project?rev=162090&view=rev
Log:
Insertion of NoFolder functions to avoid ambiguous overload warnings or errors about whether to convert Idx to ArrayRef<Constant *> or ArrayRef<Value *> like ConstantFolder and TargetFolder.

Modified:
    llvm/trunk/include/llvm/Support/NoFolder.h

Modified: llvm/trunk/include/llvm/Support/NoFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/NoFolder.h?rev=162090&r1=162089&r2=162090&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/NoFolder.h (original)
+++ llvm/trunk/include/llvm/Support/NoFolder.h Fri Aug 17 03:54:57 2012
@@ -181,6 +181,12 @@
                                 ArrayRef<Constant *> IdxList) const {
     return ConstantExpr::getGetElementPtr(C, IdxList);
   }
+  Constant *CreateGetElementPtr(Constant *C, Constant *Idx) const {
+    // This form of the function only exists to avoid ambiguous overload
+    // warnings about whether to convert Idx to ArrayRef<Constant *> or
+    // ArrayRef<Value *>.

This comment doesn't seem right at all -- this function doesn't accept anything to do with ArrayRef. The comment seems copy/pasted from the edit below where it is correct, but it needs updating for this signature.

+    return ConstantExpr::getGetElementPtr(C, Idx);
+  }
   Instruction *CreateGetElementPtr(Constant *C,
                                    ArrayRef<Value *> IdxList) const {
     return GetElementPtrInst::Create(C, IdxList);
@@ -190,6 +196,12 @@
                                         ArrayRef<Constant *> IdxList) const {
     return ConstantExpr::getInBoundsGetElementPtr(C, IdxList);
   }
+  Constant *CreateInBoundsGetElementPtr(Constant *C, Constant *Idx) const {
+    // This form of the function only exists to avoid ambiguous overload
+    // warnings about whether to convert Idx to ArrayRef<Constant *> or
+    // ArrayRef<Value *>.
+    return ConstantExpr::getInBoundsGetElementPtr(C, Idx);
+  }
   Instruction *CreateInBoundsGetElementPtr(Constant *C,
                                            ArrayRef<Value *> IdxList) const {
     return GetElementPtrInst::CreateInBounds(C, IdxList);


_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu<mailto:llvm-commits at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120817/ba2d35aa/attachment.html>


More information about the llvm-commits mailing list