From 15f6b42b68d296cabf117752094693afe813dffb Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Tue, 2 Mar 2010 10:08:30 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97562 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/LiveVariables.cpp | 6 ++++++ test/Analysis/inline2.c | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/Analysis/inline2.c diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 94ed75286d..c636a43bc5 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -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(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 index 0000000000..9029fb9c67 --- /dev/null +++ b/test/Analysis/inline2.c @@ -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); +} -- 2.40.0