]> granicus.if.org Git - clang/commitdiff
Quick fix for crash in IRgen when we can tryEvaluate a condition to
authorDaniel Dunbar <daniel@zuster.org>
Wed, 12 Nov 2008 22:37:10 +0000 (22:37 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 12 Nov 2008 22:37:10 +0000 (22:37 +0000)
something that is not an int.

 - Ignore these cases for now, added FIXME that we should also boolize
   them.

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

lib/CodeGen/CodeGenFunction.cpp

index ab9633418ac22963117091728f0aa0ceb92ee0e1..c445864bb31dd696b84df61caf5f7eecf2b9b91e 100644 (file)
@@ -194,8 +194,11 @@ bool CodeGenFunction::ContainsLabel(const Stmt *S, bool IgnoreCaseStmts) {
 /// to 'false' and does not contain a label, return -1.
 int CodeGenFunction::ConstantFoldsToSimpleInteger(const Expr *Cond) {
   APValue V;
-  if (!Cond->tryEvaluate(V, getContext()))
-    return 0;  // Not foldable.
+  
+  // FIXME: Rename and handle conversion of other evaluatable things
+  // to bool.
+  if (!Cond->tryEvaluate(V, getContext()) || !V.isInt())
+    return 0;  // Not foldable or not integer.
   
   if (CodeGenFunction::ContainsLabel(Cond))
     return 0;  // Contains a label.