[cfe-commits] r91751 - in /cfe/trunk: lib/Analysis/CFRefCount.cpp test/Analysis/misc-ps-region-store.cpp

Ted Kremenek kremenek at apple.com
Mon Dec 21 10:58:08 PST 2009


Awesome!

On Dec 18, 2009, at 7:17 PM, Zhongxing Xu <xuzhongxing at gmail.com> wrote:

> Author: zhongxingxu
> Date: Fri Dec 18 21:17:55 2009
> New Revision: 91751
>
> URL: http://llvm.org/viewvc/llvm-project?rev=91751&view=rev
> Log:
> Use the FunctionDecl's result type to know exactly if it returns a  
> reference.
>
> Modified:
>    cfe/trunk/lib/Analysis/CFRefCount.cpp
>    cfe/trunk/test/Analysis/misc-ps-region-store.cpp
>
> Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=91751&r1=91750&r2=91751&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
> +++ cfe/trunk/lib/Analysis/CFRefCount.cpp Fri Dec 18 21:17:55 2009
> @@ -2942,6 +2942,16 @@
>
>       QualType T = Ex->getType();
>
> +      // For CallExpr, use the result type to know if it returns a  
> reference.
> +      if (const CallExpr *CE = dyn_cast<CallExpr>(Ex)) {
> +        const Expr *Callee = CE->getCallee();
> +        SVal L = state->getSVal(Callee);
> +
> +        const FunctionDecl *FD = L.getAsFunctionDecl();
> +        if (FD)
> +          T = FD->getResultType();
> +      }
> +
>       if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType 
> ())) {
>         unsigned Count = Builder.getCurrentBlockCount();
>         ValueManager &ValMgr = Eng.getValueManager();
>
> Modified: cfe/trunk/test/Analysis/misc-ps-region-store.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.cpp?rev=91751&r1=91750&r2=91751&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/test/Analysis/misc-ps-region-store.cpp (original)
> +++ cfe/trunk/test/Analysis/misc-ps-region-store.cpp Fri Dec 18  
> 21:17:55 2009
> @@ -1,6 +1,5 @@
> // RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer- 
> experimental-internal-checks -checker-cfref -analyzer-store=region - 
> verify -fblocks -analyzer-opt-analyze-nested-blocks %s
> // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer- 
> experimental-internal-checks -checker-cfref -analyzer-store=region - 
> verify -fblocks   -analyzer-opt-analyze-nested-blocks %s
> -// XFAIL: *
>
> // Test basic handling of references.
> char &test1_aux();
> @@ -8,7 +7,7 @@
>   return &test1_aux();
> }
>
> -// This test currently crasehs because test1_aux() evaluates to a  
> 'char' instead of a char& in CFRefCount.cpp.
> +// Test test1_aux() evaluates to char &.
> char test1_as_rvalue() {
>   return test1_aux();
> }
>
>
> _______________________________________________
> 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