[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 lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp
Chris Lattner
clattner at apple.com
Mon Oct 27 22:09:08 PDT 2008
On Oct 27, 2008, at 5:22 PM, Douglas Gregor wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=58306&view=rev
> Log:
> Improve our handling of (C++) references within Clang. Specifically:
> - Do not allow expressions to ever have reference type
> - Extend Expr::isLvalue to handle more cases where having written a
> reference into the source implies that the expression is an lvalue
> (e.g., function calls, C++ casts).
Nice assert,
> +++ 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? 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.
-Chris
More information about the cfe-commits
mailing list