[llvm-commits] [llvm] r108162 - in /llvm/trunk: lib/Analysis/Lint.cpp test/Other/lint.ll
Dan Gohman
gohman at apple.com
Mon Jul 12 11:02:04 PDT 2010
Author: djg
Date: Mon Jul 12 13:02:04 2010
New Revision: 108162
URL: http://llvm.org/viewvc/llvm-project?rev=108162&view=rev
Log:
Add a lint check for mismatched return types, inspired by PR6944.
Modified:
llvm/trunk/lib/Analysis/Lint.cpp
llvm/trunk/test/Other/lint.ll
Modified: llvm/trunk/lib/Analysis/Lint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Lint.cpp?rev=108162&r1=108161&r2=108162&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Lint.cpp (original)
+++ llvm/trunk/lib/Analysis/Lint.cpp Mon Jul 12 13:02:04 2010
@@ -225,6 +225,10 @@
"Undefined behavior: Call argument count mismatches callee "
"argument count", &I);
+ Assert1(FT->getReturnType() == I.getType(),
+ "Undefined behavior: Call return type mismatches "
+ "callee return type", &I);
+
// Check argument types (in case the callee was casted) and attributes.
// TODO: Verify that caller and callee attributes are compatible.
Function::arg_iterator PI = F->arg_begin(), PE = F->arg_end();
Modified: llvm/trunk/test/Other/lint.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/lint.ll?rev=108162&r1=108161&r2=108162&view=diff
==============================================================================
--- llvm/trunk/test/Other/lint.ll (original)
+++ llvm/trunk/test/Other/lint.ll Mon Jul 12 13:02:04 2010
@@ -154,3 +154,12 @@
%x = volatile load i32* %t3
br label %exit
}
+
+; CHECK: Call return type mismatches callee return type
+%struct = type { double, double }
+declare i32 @nonstruct_callee() nounwind
+define void @struct_caller() nounwind {
+entry:
+ call %struct bitcast (i32 ()* @foo to %struct ()*)()
+ ret void
+}
More information about the llvm-commits
mailing list