Hi
Attached you can find an updates patch.



On Tue, Jun 10, 2014 at 11:50 PM, David Majnemer <[email protected]>
wrote:

> +
>> +  case Expr::CXXThrowExprClass: {
>> +    const auto* throwExpr = cast<CXXThrowExpr>(E);
>>
>
> Please stick the star on the RHS. Also, it is customary in LLVM and clang
> to spell it like "ThrowExpr"
>
>
>> +    EmitCXXThrowExpr(throwExpr);
>> +    const QualType subExprType = throwExpr->getSubExpr()->getType();
>>
>
> Likewise for "subExprType"
>
> +    llvm::Type *Ty =
>> llvm::PointerType::getUnqual(ConvertType(subExprType));
>> +    return MakeAddrLValue(llvm::UndefValue::get(Ty), subExprType);
>>    }
>
>
>
> On Tue, Jun 10, 2014 at 5:19 PM, Marius Wachtler <[email protected]>
> wrote:
>
>> Hello
>>
>> Attached you can find my first clang patch which should implement
>> "cond ? throw 1 : val".
>>
>> Without this patch I get: "cannot compile this l-value expression yet"
>>
>> As this is my first time looking under the hood of clang I'm not sure if
>> this is the right approach. I'm Looking forward to your feedback.
>>
>> - Marius Wachtler
>>
>> _______________________________________________
>> cfe-commits mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
>
Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp	(revision 210556)
+++ lib/CodeGen/CGExpr.cpp	(working copy)
@@ -874,7 +874,16 @@
 
   case Expr::MaterializeTemporaryExprClass:
     return EmitMaterializeTemporaryExpr(cast<MaterializeTemporaryExpr>(E));
+
+  case Expr::CXXThrowExprClass: {
+    const auto *ThrowExpr = cast<CXXThrowExpr>(E);
+    EmitCXXThrowExpr(ThrowExpr);
+    const QualType SubExprType = ThrowExpr->getSubExpr()->getType();
+    llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(SubExprType));
+    return MakeAddrLValue(llvm::UndefValue::get(Ty), SubExprType);
   }
+
+  }
 }
 
 /// Given an object of the given canonical type, can we safely copy a
Index: test/CodeGenCXX/throw-expressions.cpp
===================================================================
--- test/CodeGenCXX/throw-expressions.cpp	(revision 210556)
+++ test/CodeGenCXX/throw-expressions.cpp	(working copy)
@@ -80,3 +80,19 @@
   // CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN6DR15601AD1Ev {{.*}} @_ZGRN6DR15601rE
   // CHECK-NOT: call {{.*}}@_ZN6DR15601AD1Ev
 }
+
+void test7(bool cond) {
+  cond ? throw 1 : val;
+}
+// CHECK-LABEL: define void @_Z5test7b(
+// CHECK: br i1
+//
+// x.true:
+// CHECK: call void @__cxa_throw(
+// CHECK-NEXT: unreachable
+//
+// x.false:
+// CHECK: br label
+//
+// end:
+// CHECK: ret void
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to