[cfe-commits] r108026 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CodeGenCXX/instantiate-blocks.cpp

Fariborz Jahanian fjahanian at apple.com
Sat Jul 10 10:50:44 PDT 2010


On Jul 9, 2010, at 7:12 PM, Douglas Gregor wrote:

>
>
> Sent from my iPhone
>
> On Jul 9, 2010, at 3:21 PM, Fariborz Jahanian <fjahanian at apple.com>  
> wrote:
>
>> Author: fjahanian
>> Date: Fri Jul  9 17:21:32 2010
>> New Revision: 108026
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=108026&view=rev
>> Log:
>> BlockDeclRefExpr of a dependent type must
>> be a dependent expression when its is built.
>>
>>
>> Modified:
>>   cfe/trunk/lib/Sema/SemaExpr.cpp
>>   cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=108026&r1=108025&r2=108026&view=diff
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jul  9 17:21:32 2010
>> @@ -1748,22 +1748,25 @@
>>                                                            ExprTy,  
>> Loc, false,
>>                                                             
>> constAdded);
>>    QualType T = VD->getType();
>> -    if (getLangOptions().CPlusPlus && !T->isDependentType() &&
>> -        !T->isReferenceType()) {
>> -      Expr *E = new (Context)
>> -                  DeclRefExpr(const_cast<ValueDecl*>(BDRE->getDecl 
>> ()), T,
>> -                                         SourceLocation());
>> +    if (getLangOptions().CPlusPlus) {
>> +      if (!T->isDependentType() && !T->isReferenceType()) {
>> +        Expr *E = new (Context)
>> +                    DeclRefExpr(const_cast<ValueDecl*>(BDRE- 
>> >getDecl()), T,
>> +                                          SourceLocation());
>>
>> -      OwningExprResult Res = PerformCopyInitialization(
>> -                      InitializedEntity::InitializeBlock(VD- 
>> >getLocation(),
>> +        OwningExprResult Res = PerformCopyInitialization(
>> +                          InitializedEntity::InitializeBlock(VD- 
>> >getLocation(),
>>                                                         T, false),
>> -                      SourceLocation(),
>> -                      Owned(E));
>> -      if (!Res.isInvalid()) {
>> -        Res = MaybeCreateCXXExprWithTemporaries(move(Res));
>> -        Expr *Init = Res.takeAs<Expr>();
>> -        BDRE->setCopyConstructorExpr(Init);
>> +                                                          
>> SourceLocation(),
>> +                                                         Owned(E));
>> +        if (!Res.isInvalid()) {
>> +          Res = MaybeCreateCXXExprWithTemporaries(move(Res));
>> +          Expr *Init = Res.takeAs<Expr>();
>> +          BDRE->setCopyConstructorExpr(Init);
>> +        }
>>      }
>> +      else if (T->isDependentType())
>> +        BDRE->setTypeDependent(true);
>
> Since we only need to look at the declaration's type to determine  
> whether the BlockDeclRefExpr is type-dependent, why not move this  
> part of the computation into its constructor?

Sounds good.

- Fariborz

>
>  - Doug
>
>>    }
>>    return Owned(BDRE);
>>  }
>>
>> Modified: cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp?rev=108026&r1=108025&r2=108026&view=diff
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp (original)
>> +++ cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp Fri Jul  9  
>> 17:21:32 2010
>> @@ -22,7 +22,7 @@
>>
>>    T1 (^block)(char, T, T1, double) =
>>   ^ T1 (char ch, T arg, T1 arg2, double d1) { byref_block_arg = arg2;
>> -                                   return byref_block_arg + arg; };
>> +                                   return byref_block_arg +  
>> block_arg + arg; };
>>
>>    void (^block2)() = ^{};
>> }
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list