[cfe-commits] r160191 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/CodeGen/object-size.c
Nuno Lopes
nunoplopes at sapo.pt
Fri Jul 13 13:48:52 PDT 2012
Author: nlopes
Date: Fri Jul 13 15:48:52 2012
New Revision: 160191
URL: http://llvm.org/viewvc/llvm-project?rev=160191&view=rev
Log:
add support for conditional expressions in Expr::HasSideEffects()
This fixes a bug in __builtin_object_size() codegen
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/CodeGen/object-size.c
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=160191&r1=160190&r2=160191&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jul 13 15:48:52 2012
@@ -2323,6 +2323,9 @@
{ return Visit(E->getLHS()) || Visit(E->getRHS()); }
bool VisitChooseExpr(const ChooseExpr *E)
{ return Visit(E->getChosenSubExpr(Ctx)); }
+ bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E)
+ { return Visit(E->getCond()) || Visit(E->getTrueExpr())
+ || Visit(E->getFalseExpr()); }
bool VisitCastExpr(const CastExpr *E) { return Visit(E->getSubExpr()); }
bool VisitBinAssign(const BinaryOperator *E) { return true; }
bool VisitCompoundAssignOperator(const BinaryOperator *E) { return true; }
Modified: cfe/trunk/test/CodeGen/object-size.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/object-size.c?rev=160191&r1=160190&r2=160191&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/object-size.c (original)
+++ cfe/trunk/test/CodeGen/object-size.c Fri Jul 13 15:48:52 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - 2>&1 | FileCheck %s
#define strcpy(dest, src) \
((__builtin_object_size(dest, 0) != -1ULL) \
@@ -127,6 +127,7 @@
strcpy(gp += 1, "Hi there");
}
+// CHECK: @test17
void test17() {
// CHECK: store i32 -1
gi = __builtin_object_size(gp++, 0);
@@ -137,3 +138,11 @@
// CHECK: store i32 0
gi = __builtin_object_size(gp++, 3);
}
+
+// CHECK: @test18
+unsigned test18(int cond) {
+ int a[4], b[4];
+ // CHECK: phi i32*
+ // CHECK: call i64 @llvm.objectsize.i64
+ return __builtin_object_size(cond ? a : b, 0);
+}
More information about the cfe-commits
mailing list