Function.h revision 52f792329be5db8e38961350589e97e8f2823acd
1dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//===-- Function.h ----------------------------------------------*- C++ -*-===//
2dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//
3dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//                     The LLVM Compiler Infrastructure
4dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//
5dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com// This file is distributed under the University of Illinois Open Source
6dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com// License. See LICENSE.TXT for details.
7dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//
8dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//===----------------------------------------------------------------------===//
9dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
10dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com#ifndef liblldb_Function_h_
11dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com#define liblldb_Function_h_
12dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
13dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com#include "lldb/Core/ClangForward.h"
14dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com#include "lldb/Core/AddressRange.h"
15dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com#include "lldb/Symbol/Block.h"
16dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com#include "lldb/Symbol/Declaration.h"
17dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com#include "lldb/Expression/DWARFExpression.h"
18dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com#include "lldb/Core/Mangled.h"
19dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com#include "lldb/Core/UserID.h"
20dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
21dff7e11c2000d6745261de046d76b1500a05ece9reed@google.comnamespace lldb_private {
22dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
23dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//----------------------------------------------------------------------
24dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com/// @class FunctionInfo Function.h "lldb/Symbol/Function.h"
25dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com/// @brief A class that contains generic function information.
26dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com///
27dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com/// This provides generic function information that gets resused between
28dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com/// inline functions and function types.
29dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//----------------------------------------------------------------------
30dff7e11c2000d6745261de046d76b1500a05ece9reed@google.comclass FunctionInfo
31dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com{
32dff7e11c2000d6745261de046d76b1500a05ece9reed@google.compublic:
33dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
34dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Construct with the function method name and optional declaration
35dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// information.
36dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
37dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] name
38dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     A C string name for the method name for this function. This
39dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     value should not be the mangled named, but the simple method
40dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     name.
41dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
42dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] decl_ptr
43dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     Optional declaration information that describes where the
44dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     function was declared. This can be NULL.
45dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
46dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    FunctionInfo (const char *name, const Declaration *decl_ptr);
47dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
48dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
49dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Construct with the function method name and optional declaration
50dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// information.
51dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
52dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] name
53dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     A name for the method name for this function. This value
54dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     should not be the mangled named, but the simple method name.
55dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
56dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] decl_ptr
57dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     Optional declaration information that describes where the
58dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     function was declared. This can be NULL.
59dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
60dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    FunctionInfo (const ConstString& name, const Declaration *decl_ptr);
61dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
62dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
63dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Destructor.
64dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
65dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// The destructor is virtual since classes inherit from this class.
66dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
67dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    virtual
68dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ~FunctionInfo ();
69dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
70dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
71dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Compare two function information objects.
72dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
73dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// First compares the method names, and if equal, then compares
74dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// the declaration information.
75dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
76dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] lhs
77dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     The Left Hand Side const FunctionInfo object reference.
78dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
79dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] rhs
80dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     The Right Hand Side const FunctionInfo object reference.
81dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
82dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @return
83dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     @li -1 if lhs < rhs
84dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     @li 0 if lhs == rhs
85dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     @li 1 if lhs > rhs
86dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
87dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    static int
88dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    Compare (const FunctionInfo& lhs, const FunctionInfo& rhs);
89dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
90dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
91dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Dump a description of this object to a Stream.
92dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
93dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Dump a description of the contents of this object to the
94dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// supplied stream \a s.
95dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
96dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] s
97dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     The stream to which to dump the object descripton.
98dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
99dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    void
100dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    Dump (Stream *s, bool show_fullpaths) const;
101dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
102dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
103dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Get accessor for the declaration information.
104dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
105dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @return
106dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     A reference to the declaration object.
107dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
108dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    Declaration&
109dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    GetDeclaration ();
110dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
111dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
112dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Get const accessor for the declaration information.
113dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
114dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @return
115dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     A const reference to the declaration object.
116dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
117dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    const Declaration&
118dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    GetDeclaration () const;
119dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
120dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
121dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Get accessor for the method name.
122dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
123dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @return
124dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     A const reference to the method name object.
125dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
126dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    const ConstString&
127dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    GetName () const;
128dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
129dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
130dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Get the memory cost of this object.
131dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
132dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @return
133dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     The number of bytes that this object occupies in memory.
134dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     The returned value does not include the bytes for any
135dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     shared string values.
136dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
137dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @see ConstString::StaticMemorySize ()
138dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
139dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    virtual size_t
140dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    MemorySize () const;
141dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
142dff7e11c2000d6745261de046d76b1500a05ece9reed@google.comprotected:
143dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
144dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    // Member variables.
145dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
146dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ConstString m_name; ///< Function method name (not a mangled name).
147dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    Declaration m_declaration; ///< Information describing where this function information was defined.
148dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com};
149dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
150dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
151dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//----------------------------------------------------------------------
152dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com/// @class InlineFunctionInfo Function.h "lldb/Symbol/Function.h"
153dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com/// @brief A class that describes information for an inlined function.
154dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com//----------------------------------------------------------------------
155dff7e11c2000d6745261de046d76b1500a05ece9reed@google.comclass InlineFunctionInfo : public FunctionInfo
156dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com{
157dff7e11c2000d6745261de046d76b1500a05ece9reed@google.compublic:
158dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
159dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Construct with the function method name, mangled name, and
160dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// optional declaration information.
161dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
162dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] name
163dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     A C string name for the method name for this function. This
164dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     value should not be the mangled named, but the simple method
165dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     name.
166dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
167dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] mangled
168dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     A C string name for the mangled name for this function. This
169dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     value can be NULL if there is no mangled information.
170dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
171dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] decl_ptr
172dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     Optional declaration information that describes where the
173dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     function was declared. This can be NULL.
174dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
175dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] call_decl_ptr
176dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     Optional calling location declaration information that
177dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     describes from where this inlined function was called.
178dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
179dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    InlineFunctionInfo(const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr);
180dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
181dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
182dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Construct with the function method name, mangled name, and
183dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// optional declaration information.
184dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
185dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] name
186dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     A name for the method name for this function. This value
187dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     should not be the mangled named, but the simple method name.
188dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
189dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] mangled
190dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     A name for the mangled name for this function. This value
191dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     can be empty if there is no mangled information.
192dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
193dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] decl_ptr
194dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     Optional declaration information that describes where the
195dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     function was declared. This can be NULL.
196dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
197dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] call_decl_ptr
198dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     Optional calling location declaration information that
199dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     describes from where this inlined function was called.
200dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
201dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    InlineFunctionInfo(const ConstString& name, const Mangled &mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr);
202dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
203dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
204dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Destructor.
205dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
206dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ~InlineFunctionInfo();
207dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com
208dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
209dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// Compare two inlined function information objects.
210dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
211dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// First compares the FunctionInfo objects, and if equal,
212dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// compares the mangled names.
213dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
214dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] lhs
215dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     The Left Hand Side const InlineFunctionInfo object
216dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     reference.
217dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
218dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @param[in] rhs
219dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     The Right Hand Side const InlineFunctionInfo object
220dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     reference.
221dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///
222dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    /// @return
223dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     @li -1 if lhs < rhs
224dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     @li 0 if lhs == rhs
225dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    ///     @li 1 if lhs > rhs
226dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    //------------------------------------------------------------------
227dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    int
228dff7e11c2000d6745261de046d76b1500a05ece9reed@google.com    Compare(const InlineFunctionInfo& lhs, const InlineFunctionInfo& rhs);
229
230    //------------------------------------------------------------------
231    /// Dump a description of this object to a Stream.
232    ///
233    /// Dump a description of the contents of this object to the
234    /// supplied stream \a s.
235    ///
236    /// @param[in] s
237    ///     The stream to which to dump the object descripton.
238    //------------------------------------------------------------------
239    void
240    Dump(Stream *s, bool show_fullpaths) const;
241
242    void
243    DumpStopContext (Stream *s) const;
244
245    const ConstString &
246    GetName () const;
247
248    //------------------------------------------------------------------
249    /// Get accessor for the call site declaration information.
250    ///
251    /// @return
252    ///     A reference to the declaration object.
253    //------------------------------------------------------------------
254    Declaration&
255    GetCallSite ();
256
257    //------------------------------------------------------------------
258    /// Get const accessor for the call site declaration information.
259    ///
260    /// @return
261    ///     A const reference to the declaration object.
262    //------------------------------------------------------------------
263    const Declaration&
264    GetCallSite () const;
265
266    //------------------------------------------------------------------
267    /// Get accessor for the mangled name object.
268    ///
269    /// @return
270    ///     A reference to the mangled name object.
271    //------------------------------------------------------------------
272    Mangled&
273    GetMangled();
274
275    //------------------------------------------------------------------
276    /// Get const accessor for the mangled name object.
277    ///
278    /// @return
279    ///     A const reference to the mangled name object.
280    //------------------------------------------------------------------
281    const Mangled&
282    GetMangled() const;
283
284    //------------------------------------------------------------------
285    /// Get the memory cost of this object.
286    ///
287    /// @return
288    ///     The number of bytes that this object occupies in memory.
289    ///     The returned value does not include the bytes for any
290    ///     shared string values.
291    ///
292    /// @see ConstString::StaticMemorySize ()
293    //------------------------------------------------------------------
294    virtual size_t
295    MemorySize() const;
296
297private:
298    //------------------------------------------------------------------
299    // Member variables.
300    //------------------------------------------------------------------
301    Mangled m_mangled; ///< Mangled inlined function name (can be empty if there is no mangled information).
302    Declaration m_call_decl;
303};
304
305//----------------------------------------------------------------------
306/// @class Function Function.h "lldb/Symbol/Function.h"
307/// @brief A class that describes a function.
308///
309/// Functions belong to CompileUnit objects (Function::m_comp_unit),
310/// have unique user IDs (Function::UserID), know how to reconstruct
311/// their symbol context (Function::SymbolContextScope), have a
312/// specific function type (Function::m_type_uid), have a simple
313/// method name (FunctionInfo::m_name), be declared at a specific
314/// location (FunctionInfo::m_declaration), possibly have mangled
315/// names (Function::m_mangled), an optional return type
316/// (Function::m_type), and contains lexical blocks
317/// (Function::m_blocks).
318///
319/// The function inforation is split into a few pieces:
320///     @li The concrete instance information
321///     @li The abstract information
322///
323/// The abstract information is found in the function type (Type) that
324/// describes a function information, return type and parameter types.
325///
326/// The concreate information is the address range information and
327/// specific locations for an instance of this function.
328//----------------------------------------------------------------------
329class Function :
330    public UserID,
331    public SymbolContextScope
332{
333public:
334    //------------------------------------------------------------------
335    /// Construct with a compile unit, function UID, function type UID,
336    /// optional mangled name, function type, and a section offset
337    /// based address range.
338    ///
339    /// @param[in] comp_unit
340    ///     The compile unit to which this function belongs.
341    ///
342    /// @param[in] func_uid
343    ///     The UID for this function. This value is provided by the
344    ///     SymbolFile plug-in and can be any value that allows
345    ///     the plug-in to quickly find and parse more detailed
346    ///     information when and if more information is needed.
347    ///
348    /// @param[in] func_type_uid
349    ///     The type UID for the function Type to allow for lazy type
350    ///     parsing from the debug information.
351    ///
352    /// @param[in] mangled
353    ///     The optional mangled name for this function. If empty, there
354    ///     is no mangled information.
355    ///
356    /// @param[in] func_type
357    ///     The optional function type. If NULL, the function type will
358    ///     be parsed on demand when accessed using the
359    ///     Function::GetType() function by asking the SymbolFile
360    ///     plug-in to get the type for \a func_type_uid.
361    ///
362    /// @param[in] range
363    ///     The section offset based address for this function.
364    //------------------------------------------------------------------
365    Function (
366        CompileUnit *comp_unit,
367        lldb::user_id_t func_uid,
368        lldb::user_id_t func_type_uid,
369        const Mangled &mangled,
370        Type * func_type,
371        const AddressRange& range);
372
373    //------------------------------------------------------------------
374    /// Construct with a compile unit, function UID, function type UID,
375    /// optional mangled name, function type, and a section offset
376    /// based address range.
377    ///
378    /// @param[in] comp_unit
379    ///     The compile unit to which this function belongs.
380    ///
381    /// @param[in] func_uid
382    ///     The UID for this function. This value is provided by the
383    ///     SymbolFile plug-in and can be any value that allows
384    ///     the plug-in to quickly find and parse more detailed
385    ///     information when and if more information is needed.
386    ///
387    /// @param[in] func_type_uid
388    ///     The type UID for the function Type to allow for lazy type
389    ///     parsing from the debug information.
390    ///
391    /// @param[in] mangled
392    ///     The optional mangled name for this function. If empty, there
393    ///     is no mangled information.
394    ///
395    /// @param[in] func_type
396    ///     The optional function type. If NULL, the function type will
397    ///     be parsed on demand when accessed using the
398    ///     Function::GetType() function by asking the SymbolFile
399    ///     plug-in to get the type for \a func_type_uid.
400    ///
401    /// @param[in] range
402    ///     The section offset based address for this function.
403    //------------------------------------------------------------------
404    Function (
405        CompileUnit *comp_unit,
406        lldb::user_id_t func_uid,
407        lldb::user_id_t func_type_uid,
408        const char *mangled,
409        Type * func_type,
410        const AddressRange& range);
411
412    //------------------------------------------------------------------
413    /// Destructor.
414    //------------------------------------------------------------------
415    ~Function ();
416
417    //------------------------------------------------------------------
418    /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
419    ///
420    /// @see SymbolContextScope
421    //------------------------------------------------------------------
422    virtual void
423    CalculateSymbolContext(SymbolContext* sc);
424
425    virtual lldb::ModuleSP
426    CalculateSymbolContextModule ();
427
428    virtual CompileUnit *
429    CalculateSymbolContextCompileUnit ();
430
431    virtual Function *
432    CalculateSymbolContextFunction ();
433
434    const AddressRange &
435    GetAddressRange()
436    {
437        return m_range;
438    }
439
440    //------------------------------------------------------------------
441    /// Find the file and line number of the source location of the start
442    /// of the function.  This will use the declaration if present and fall
443    /// back on the line table if that fails.  So there may NOT be a line
444    /// table entry for this source file/line combo.
445    ///
446    /// @param[out] source_file
447    ///     The source file.
448    ///
449    /// @param[out] line_no
450    ///     The line number.
451    //------------------------------------------------------------------
452    void
453    GetStartLineSourceInfo (FileSpec &source_file, uint32_t &line_no);
454
455     //------------------------------------------------------------------
456    /// Find the file and line number of the source location of the end
457    /// of the function.
458    ///
459    ///
460    /// @param[out] source_file
461    ///     The source file.
462    ///
463    /// @param[out] line_no
464    ///     The line number.
465    //------------------------------------------------------------------
466    void
467    GetEndLineSourceInfo (FileSpec &source_file, uint32_t &line_no);
468
469    //------------------------------------------------------------------
470    /// Get accessor for the block list.
471    ///
472    /// @return
473    ///     The block list object that describes all lexical blocks
474    ///     in the function.
475    ///
476    /// @see BlockList
477    //------------------------------------------------------------------
478    Block&
479    GetBlock (bool can_create);
480
481    //------------------------------------------------------------------
482    /// Get accessor for the compile unit that owns this function.
483    ///
484    /// @return
485    ///     A compile unit object pointer.
486    //------------------------------------------------------------------
487    CompileUnit*
488    GetCompileUnit();
489
490    //------------------------------------------------------------------
491    /// Get const accessor for the compile unit that owns this function.
492    ///
493    /// @return
494    ///     A const compile unit object pointer.
495    //------------------------------------------------------------------
496    const CompileUnit*
497    GetCompileUnit() const;
498
499    void
500    GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target);
501
502    //------------------------------------------------------------------
503    /// Get accessor for the frame base location.
504    ///
505    /// @return
506    ///     A location expression that describes the function frame
507    ///     base.
508    //------------------------------------------------------------------
509    DWARFExpression &
510    GetFrameBaseExpression()
511    {
512        return m_frame_base;
513    }
514
515    //------------------------------------------------------------------
516    /// Get const accessor for the frame base location.
517    ///
518    /// @return
519    ///     A const compile unit object pointer.
520    //------------------------------------------------------------------
521    const DWARFExpression &
522    GetFrameBaseExpression() const
523    {
524        return m_frame_base;
525    }
526
527    const ConstString &
528    GetName() const
529    {
530        return m_mangled.GetName();
531    }
532
533    const Mangled &
534    GetMangled() const
535    {
536        return m_mangled;
537    }
538
539    //------------------------------------------------------------------
540    /// Get the DeclContext for this function, if available.
541    ///
542    /// @return
543    ///     The DeclContext, or NULL if none exists.
544    //------------------------------------------------------------------
545    clang::DeclContext *
546    GetClangDeclContext();
547
548    //------------------------------------------------------------------
549    /// Get accessor for the type that describes the function
550    /// return value type, and paramter types.
551    ///
552    /// @return
553    ///     A type object pointer.
554    //------------------------------------------------------------------
555    Type*
556    GetType();
557
558    //------------------------------------------------------------------
559    /// Get const accessor for the type that describes the function
560    /// return value type, and paramter types.
561    ///
562    /// @return
563    ///     A const type object pointer.
564    //------------------------------------------------------------------
565    const Type*
566    GetType() const;
567
568    ClangASTType
569    GetClangType ();
570
571    uint32_t
572    GetPrologueByteSize ();
573
574    //------------------------------------------------------------------
575    /// Dump a description of this object to a Stream.
576    ///
577    /// Dump a description of the contents of this object to the
578    /// supplied stream \a s.
579    ///
580    /// @param[in] s
581    ///     The stream to which to dump the object descripton.
582    ///
583    /// @param[in] show_context
584    ///     If \b true, variables will dump their symbol context
585    ///     information.
586    //------------------------------------------------------------------
587    void
588    Dump(Stream *s, bool show_context) const;
589
590    //------------------------------------------------------------------
591    /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
592    ///
593    /// @see SymbolContextScope
594    //------------------------------------------------------------------
595    virtual void
596    DumpSymbolContext(Stream *s);
597
598    //------------------------------------------------------------------
599    /// Get the memory cost of this object.
600    ///
601    /// @return
602    ///     The number of bytes that this object occupies in memory.
603    ///     The returned value does not include the bytes for any
604    ///     shared string values.
605    ///
606    /// @see ConstString::StaticMemorySize ()
607    //------------------------------------------------------------------
608    size_t
609    MemorySize () const;
610
611protected:
612
613    enum
614    {
615        flagsCalculatedPrologueSize = (1 << 0)  ///< Have we already tried to calculate the prologue size?
616    };
617
618
619
620    //------------------------------------------------------------------
621    // Member variables.
622    //------------------------------------------------------------------
623    CompileUnit *m_comp_unit;       ///< The compile unit that owns this function.
624    lldb::user_id_t m_type_uid;     ///< The user ID of for the prototype Type for this function.
625    Type * m_type;                  ///< The function prototype type for this function that include the function info (FunctionInfo), return type and parameters.
626    Mangled m_mangled;              ///< The mangled function name if any, if empty, there is no mangled information.
627    Block m_block;                  ///< All lexical blocks contained in this function.
628    AddressRange m_range;           ///< The function address range that covers the widest range needed to contain all blocks
629    DWARFExpression m_frame_base;   ///< The frame base expression for variables that are relative to the frame pointer.
630    Flags m_flags;
631    uint32_t m_prologue_byte_size;  ///< Compute the prologue size once and cache it
632private:
633    DISALLOW_COPY_AND_ASSIGN(Function);
634};
635
636} // namespace lldb_private
637
638#endif  // liblldb_Function_h_
639