[cfe-commits] r89717 - in /cfe/trunk: include/clang/AST/Stmt.h lib/CodeGen/CGStmt.cpp lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriterStmt.cpp lib/Sema/Sema.h lib/Sema/SemaExprCXX.cpp lib/Sema/SemaStmt.cpp lib/Sema/TreeTransform.h
Douglas Gregor
dgregor at apple.com
Tue Nov 24 08:31:54 PST 2009
On Nov 23, 2009, at 11:27 PM, Anders Carlsson wrote:
> 23 nov 2009 kl. 15.44 skrev Douglas Gregor:
>
>> Author: dgregor
>> Date: Mon Nov 23 17:44:04 2009
>> New Revision: 89717
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=89717&view=rev
>> Log:
>> Explicitly track the condition variable within an "if" statement,
>> rather than burying it in a CXXConditionDeclExpr (that occassionally
>> hides behind implicit conversions). Similar changes for
>> switch, while, and do-while will follow, then the removal of
>> CXXConditionDeclExpr. This commit is the canary.
>
> This broke the following test:
>
> void *f();
>
> template <typename T> T* g() {
> if (T* t = f())
> return t;
>
> return 0;
> }
>
> void h() {
> void *a = g<void>();
> }
>
> which is very common in clang (getAs<FooType>() :)
Yikes! Sorry, this is fixed in r89769. Test-case coming soon.
> Also, if you're getting rid of CXXConditionDeclExpr, then how are you going to disambiguate between
>
> if (void * f = foo()) { }
>
> and
>
> void *f = foo();
>
> if (f) { }
>
> Since both cond exprs in this case are going to be DeclRefExprs.
The IfStmt stores its conditional variable (as a VarDecl). so we can look there. It's actually much cleaner, since today the declaration is buried within a CXXConditionDeclExpr that may have implicit conversions and temporary-destruction nodes wrapped around it.
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20091124/4bd6b890/attachment.html>
More information about the cfe-commits
mailing list