[cfe-commits] r108266 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiate.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp lib/Sema/TreeTransform.h test/CodeGenCXX/instantiate-blocks.cpp

Douglas Gregor dgregor at apple.com
Tue Jul 13 13:27:22 PDT 2010


On Jul 13, 2010, at 1:05 PM, Fariborz Jahanian wrote:

> Author: fjahanian
> Date: Tue Jul 13 15:05:58 2010
> New Revision: 108266
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=108266&view=rev
> Log:
> More block instantiation stuff. Set variable/param DeclContext
> to block context when first instantiating them.

I'm confused... the CurContext isn't the BlockDecl already?

	- Doug

> Modified:
>    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
>    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>    cfe/trunk/lib/Sema/TreeTransform.h
>    cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp
> 
> Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=108266&r1=108265&r2=108266&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Tue Jul 13 15:05:58 2010
> @@ -1067,6 +1067,10 @@
>   NewParm->setHasInheritedDefaultArg(OldParm->hasInheritedDefaultArg());
> 
>   CurrentInstantiationScope->InstantiatedLocal(OldParm, NewParm);
> +  // Set DeclContext if inside a Block.
> +  if (BlockScopeInfo *CurBlock = getCurBlock())
> +    NewParm->setDeclContext(CurBlock->TheDecl);
> +  
>   return NewParm;  
> }
> 
> 
> Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=108266&r1=108265&r2=108266&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Jul 13 15:05:58 2010
> @@ -400,6 +400,9 @@
>       SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Var);
>   }
>   InstantiateAttrs(D, Var);
> +  // Set DeclContext if inside a Block.
> +  if (BlockScopeInfo *CurBlock = SemaRef.getCurBlock())
> +    D->setDeclContext(CurBlock->TheDecl);
> 
>   // Link instantiations of static data members back to the template from
>   // which they were instantiated.
> 
> Modified: cfe/trunk/lib/Sema/TreeTransform.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=108266&r1=108265&r2=108266&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
> +++ cfe/trunk/lib/Sema/TreeTransform.h Tue Jul 13 15:05:58 2010
> @@ -4198,10 +4198,6 @@
>   if (!ND)
>     return SemaRef.ExprError();
> 
> -  // Set DeclContext if inside a Block.
> -  if (BlockScopeInfo *CurBlock = SemaRef.getCurBlock())
> -    ND->setDeclContext(CurBlock->TheDecl);
> -  
>   if (!getDerived().AlwaysRebuild() && 
>       Qualifier == E->getQualifier() &&
>       ND == E->getDecl() &&
> 
> Modified: cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp?rev=108266&r1=108265&r2=108266&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp Tue Jul 13 15:05:58 2010
> @@ -31,3 +31,29 @@
> {
>     foo(100, 'a');
> }
> +
> +namespace rdar6182276 {
> +extern "C" {
> +int printf(const char *, ...);
> +}
> +
> +template <typename T> T foo(T t)
> +{
> +    void (^testing)(int) = ^(int bar) { printf("bar is %d\n", bar); };
> +    printf("bar is\n");
> +    return 1;
> +}
> +
> +template <typename T> void gorf(T t)
> +{
> +    foo(t);
> +}
> +
> +
> +void test(void)
> +{
> +    gorf(2);
> +}
> +}
> +
> +
> 
> 
> _______________________________________________
> 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