summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2009-11-16 15:28:17 +0000
committerDuncan Sands <baldrick@free.fr>2009-11-16 15:28:17 +0000
commit551861e7d9d4b9f2bd7806e3b8b6875580c2b3c9 (patch)
treeab768b2e17a955ca58146b506c57fd90ab6a0c5b
parent25905c833629c3ea90710f0fdb5c3fb35e4eabd0 (diff)
downloadbcm5719-llvm-551861e7d9d4b9f2bd7806e3b8b6875580c2b3c9.tar.gz
bcm5719-llvm-551861e7d9d4b9f2bd7806e3b8b6875580c2b3c9.zip
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*. llvm-svn: 88913
-rw-r--r--llvm/include/llvm/Support/Compiler.h6
-rw-r--r--llvm/include/llvm/Support/IRBuilder.h3
2 files changed, 9 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index da31f986288..cce652f9261 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -78,4 +78,10 @@
#define NORETURN
#endif
+#ifdef __GNUC__
+#define ERROR_IF_USED __attribute__((error("wrong usage")))
+#else
+#define ERROR_IF_USED
+#endif
+
#endif
diff --git a/llvm/include/llvm/Support/IRBuilder.h b/llvm/include/llvm/Support/IRBuilder.h
index 05c3c569aa1..1d3c08c6375 100644
--- a/llvm/include/llvm/Support/IRBuilder.h
+++ b/llvm/include/llvm/Support/IRBuilder.h
@@ -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;
OpenPOWER on IntegriCloud