[llvm-commits] [llvm] r88913 - in /llvm/trunk/include/llvm/Support: Compiler.h IRBuilder.h

Duncan Sands baldrick at free.fr
Mon Nov 16 07:28:18 PST 2009


Author: baldrick
Date: Mon Nov 16 09:28:17 2009
New Revision: 88913

URL: http://llvm.org/viewvc/llvm-project?rev=88913&view=rev
Log:
Make sure that if anyone passes a name by accident for the isSigned
parameter of CreateIntCast then they get an error from the compiler
(or from the linker with a non-gcc compiler).  Another possibility
is to flip the order of the DestTy and isSigned parameters, since you
should then get a compiler warning if you try to use a char* for a
Type*.

Modified:
    llvm/trunk/include/llvm/Support/Compiler.h
    llvm/trunk/include/llvm/Support/IRBuilder.h

Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=88913&r1=88912&r2=88913&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Mon Nov 16 09:28:17 2009
@@ -78,4 +78,10 @@
 #define NORETURN
 #endif
 
+#ifdef __GNUC__
+#define ERROR_IF_USED __attribute__((error("wrong usage")))
+#else
+#define ERROR_IF_USED
+#endif
+
 #endif

Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=88913&r1=88912&r2=88913&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Mon Nov 16 09:28:17 2009
@@ -709,6 +709,9 @@
       return Folder.CreateIntCast(VC, DestTy, isSigned);
     return Insert(CastInst::CreateIntegerCast(V, DestTy, isSigned), Name);
   }
+  // Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', instead of converting
+  // the string to 'bool' for the isSigned parameter.
+  ERROR_IF_USED Value *CreateIntCast(Value *, const Type *, const char *);
   Value *CreateFPCast(Value *V, const Type *DestTy, const Twine &Name = "") {
     if (V->getType() == DestTy)
       return V;





More information about the llvm-commits mailing list