[cfe-commits] r58306 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/ExprCXX.h include/clang/AST/StmtNodes.def include/clang/Analysis/PathSensitive/GRExprEngine.h lib/AST/Expr.cpp lib/Analysis/GRExprEngine.cpp lib/Sema/SemaDecl.cpp li
Doug Gregor
doug.gregor at gmail.com
Tue Oct 28 10:13:42 PDT 2008
On Tue, Oct 28, 2008 at 11:42 AM, Chris Lattner <clattner at apple.com> wrote:
> On Oct 28, 2008, at 8:25 AM, Doug Gregor wrote:
>>>>
>>>> +++ cfe/trunk/lib/AST/Expr.cpp Mon Oct 27 19:22:11 2008
>>>> @@ -393,6 +393,20 @@
>>>> break;
>>>> case ParenExprClass: // C99 6.5.1p5
>>>> return cast<ParenExpr>(this)->getSubExpr()->isLvalue(Ctx);
>>>> + case CallExprClass: {
>>>> + // C++ [expr.call]p10:
>>>> + // A function call is an lvalue if and only if the result type
>>>> + // is a reference.
>>>> + QualType CalleeType
>>>> + =
>>>> dyn_cast<CallExpr>(this)->getCallee()->IgnoreParens()->getType();
>>>> + if (const PointerType *FnTypePtr = CalleeType->getAsPointerType())
>>>
>>> Won't this crash if dyn_cast returns null?
>>
>> Oops, it should just be cast<CallExpr>, since we know the type statically.
>
> Oh right.
>
>>> It would also be more idiomatic
>>> and claean to make 'CalleeType' be a Type* instead of a QualType, as
>>> there
>>> are no qualifiers in the result of the dyn_cast.
>>
>> ?? The thing we're getting back is a QualType.
>
> cast<T> returns a "T*" or "const T*". It is just being implicitly converted
> to QualType here with no qualifiers. The cast argument is converted from
> QualType to Type by simplify_type<const ::clang::QualType> at around
> Type.h:212.
This is the code we're looking at:
>> + QualType CalleeType
>> + = dyn_cast<CallExpr>(this)->getCallee()->IgnoreParens()->getType();
The dyn_cast<> (now a cast<>) gives us a CallExpr*, on which we
immediately call getCallee() to get an Expr*, then IgnoreParens() and
getType(), which returns a QualType.
- Doug
More information about the cfe-commits
mailing list