[cfe-commits] r93917 - in /cfe/trunk: lib/Frontend/RewriteObjC.cpp test/Rewriter/rewrite-typeof.mm

Daniel Dunbar daniel at zuster.org
Sat Jan 23 14:32:44 PST 2010


Hi Fariborz,

On Tue, Jan 19, 2010 at 1:48 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
> Author: fjahanian
> Date: Tue Jan 19 15:48:35 2010
> New Revision: 93917
>
> URL: http://llvm.org/viewvc/llvm-project?rev=93917&view=rev
> Log:
> Rewriteing of gnu extension __typeof in objective-c rewriter.
> Fixes radar 6358225.
>
> Added:
>    cfe/trunk/test/Rewriter/rewrite-typeof.mm
> Modified:
>    cfe/trunk/lib/Frontend/RewriteObjC.cpp
>
> Modified: cfe/trunk/lib/Frontend/RewriteObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/RewriteObjC.cpp?rev=93917&r1=93916&r2=93917&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Frontend/RewriteObjC.cpp (original)
> +++ cfe/trunk/lib/Frontend/RewriteObjC.cpp Tue Jan 19 15:48:35 2010
> @@ -4293,7 +4293,19 @@
>
>   const char *startBuf = SM->getCharacterData(LocStart);
>   const char *endBuf = SM->getCharacterData(LocEnd);
> -
> +  QualType QT = CE->getType();
> +  const Type* TypePtr = QT->getAs<Type>();
> +  if (isa<TypeOfExprType>(TypePtr)) {
> +    const TypeOfExprType *TypeOfExprTypePtr = cast<TypeOfExprType>(TypePtr);
> +    QT = TypeOfExprTypePtr->getUnderlyingExpr()->getType();
> +    std::string TypeAsString = "(";
> +    TypeAsString += QT.getAsString();
> +    TypeAsString += ")";
> +    ReplaceText(LocStart, endBuf-startBuf+1,
> +                TypeAsString.c_str(), TypeAsString.size());
> +    return;
> +  }
> +
>   // advance the location to startArgList.
>   const char *argPtr = startBuf;
>
>
> Added: cfe/trunk/test/Rewriter/rewrite-typeof.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-typeof.mm?rev=93917&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Rewriter/rewrite-typeof.mm (added)
> +++ cfe/trunk/test/Rewriter/rewrite-typeof.mm Tue Jan 19 15:48:35 2010
> @@ -0,0 +1,20 @@
> +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -o - %s

Please include at least one check that the output matches what is expected.

 - Daniel

> +extern "C" {
> +extern "C" void *_Block_copy(const void *aBlock);
> +extern "C" void _Block_release(const void *aBlock);
> +}
> +
> +int main() {
> +    __attribute__((__blocks__(byref))) int a = 42;
> +    int save_a = a;
> +
> +    void (^b)(void) = ^{
> +        ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; })));
> +    };
> +
> +    ((__typeof(b))_Block_copy((const void *)(b)));
> +
> +    return 0;
> +}
> +
>
>
> _______________________________________________
> 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