]> granicus.if.org Git - clang/commitdiff
add support for conditional expressions in Expr::HasSideEffects()
authorNuno Lopes <nunoplopes@sapo.pt>
Fri, 13 Jul 2012 20:48:52 +0000 (20:48 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Fri, 13 Jul 2012 20:48:52 +0000 (20:48 +0000)
This fixes a bug in __builtin_object_size() codegen

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

lib/AST/ExprConstant.cpp
test/CodeGen/object-size.c

index ad5aa54e4830f8d0843f9146c090ee6c23a2e317..eb34fc5fcad5df84729434fb9f1dd8b581fae810 100644 (file)
@@ -2323,6 +2323,9 @@ public:
     { 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; }
index df6189ef10d3641c6f8f54bc2f9eb657996dc00f..f6c7db835bf3b681f79e6680661c4350219197e1 100644 (file)
@@ -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 @@ void test16() {
   strcpy(gp += 1, "Hi there");
 }
 
+// CHECK: @test17
 void test17() {
   // CHECK: store i32 -1
   gi = __builtin_object_size(gp++, 0);
@@ -137,3 +138,11 @@ void test17() {
   // 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);
+}