]> granicus.if.org Git - clang/commitdiff
Register all parameters even if they didn't occur in the function body.
authorZhongxing Xu <xuzhongxing@gmail.com>
Tue, 2 Mar 2010 10:08:30 +0000 (10:08 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Tue, 2 Mar 2010 10:08:30 +0000 (10:08 +0000)
We may query their liveness because they are added to store when passing
argument values.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97562 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/LiveVariables.cpp
test/Analysis/inline2.c [new file with mode: 0644]

index 94ed75286dee2888a726ae199018e2d6e8ab6690..c636a43bc50fa8fe839e6bf7e4fba3a134d50638 100644 (file)
@@ -86,6 +86,12 @@ LiveVariables::LiveVariables(AnalysisContext &AC) {
 
   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);
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/test/Analysis/inline2.c b/test/Analysis/inline2.c
new file mode 100644 (file)
index 0000000..9029fb9
--- /dev/null
@@ -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);
+}