Make sure that if anyone passes a name by accident for the isSigned
authorDuncan Sands <baldrick@free.fr>
Mon, 16 Nov 2009 15:28:17 +0000 (15:28 +0000)
committerDuncan Sands <baldrick@free.fr>
Mon, 16 Nov 2009 15:28:17 +0000 (15:28 +0000)
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*.

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

include/llvm/Support/Compiler.h
include/llvm/Support/IRBuilder.h

index da31f9862885fea54420e484bd4e0350ecd05d64..cce652f9261947ece3799db13ebcc349f8ecc04a 100644 (file)
 #define NORETURN
 #endif
 
+#ifdef __GNUC__
+#define ERROR_IF_USED __attribute__((error("wrong usage")))
+#else
+#define ERROR_IF_USED
+#endif
+
 #endif
index 05c3c569aa1a7a4fbde2da64d343c4fe313ec819..1d3c08c63754fe55e0b5ad2d6affb258389f29f7 100644 (file)
@@ -709,6 +709,9 @@ public:
       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;