[cfe-commits] r97562 - in /cfe/trunk: lib/Analysis/LiveVariables.cpp test/Analysis/inline2.c

Zhongxing Xu xuzhongxing at gmail.com
Tue Mar 2 02:08:30 PST 2010


Author: zhongxingxu
Date: Tue Mar  2 04:08:30 2010
New Revision: 97562

URL: http://llvm.org/viewvc/llvm-project?rev=97562&view=rev
Log:
Register all parameters even if they didn't occur in the function body.
We may query their liveness because they are added to store when passing
argument values.

Added:
    cfe/trunk/test/Analysis/inline2.c
Modified:
    cfe/trunk/lib/Analysis/LiveVariables.cpp

Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=97562&r1=97561&r2=97562&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Tue Mar  2 04:08:30 2010
@@ -86,6 +86,12 @@
 
   RegisterDecls R(getAnalysisData());
   cfg.VisitBlockStmts(R);
+
+  // Register all parameters even if they didn't occur in the function body.
+  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(AC.getDecl()))
+    for (FunctionDecl::param_const_iterator PI = FD->param_begin(), 
+           PE = FD->param_end(); PI != PE; ++PI)
+      getAnalysisData().Register(*PI);
 }
 
 //===----------------------------------------------------------------------===//

Added: cfe/trunk/test/Analysis/inline2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inline2.c?rev=97562&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/inline2.c (added)
+++ cfe/trunk/test/Analysis/inline2.c Tue Mar  2 04:08:30 2010
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -analyze -inline-call -analyzer-store region -analyze-function f2 -verify %s
+
+// Test parameter 'a' is registered to LiveVariables analysis data although it
+// is not referenced in the function body. 
+int f1(int a) {
+  return 1;
+}
+
+void f2() {
+  int x;
+  x = f1(1);
+}





More information about the cfe-commits mailing list