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

Zhongxing Xu xuzhongxing at gmail.com
Fri Dec 18 19:17:59 PST 2009


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();
 }





More information about the cfe-commits mailing list