[PATCH] Implement throw in conditional operator
Richard Smith
richard at metafoo.co.uk
Tue Jun 10 16:05:49 PDT 2014
Please also include a test that the produced lvalue actually has the right
value. Something like:
int &test7(bool cond) {
return cond ? throw 1 : val;
}
... and check that the value returned is @_Z3val
On Tue, Jun 10, 2014 at 3:01 PM, Marius Wachtler <undingen at gmail.com> wrote:
> Hi
> Attached you can find an updates patch.
>
>
>
>
> On Tue, Jun 10, 2014 at 11:50 PM, David Majnemer <david.majnemer at gmail.com
> > 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 <undingen at gmail.com>
>> 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
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>>
>>>
>>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140610/880c10c8/attachment.html>
More information about the cfe-commits
mailing list