Skip to content

Commit 1b95a6f

Browse files
author
Greg Clayton
committed
Added some logging back and cleaned up the code to match LLDB's coding
conventions. llvm-svn: 119771
1 parent 461e704 commit 1b95a6f

File tree

2 files changed

+200
-182
lines changed

2 files changed

+200
-182
lines changed

lldb/include/lldb/Expression/IRForTarget.h

Lines changed: 90 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,38 @@ class IRForTarget : public llvm::ModulePass
7272
//------------------------------------------------------------------
7373
/// Run this IR transformer on a single module
7474
///
75-
/// @param[in] M
75+
/// Implementation of the llvm::ModulePass::runOnModule() function.
76+
///
77+
/// @param[in] llvm_module
7678
/// The module to run on. This module is searched for the function
7779
/// $__lldb_expr, and that function is passed to the passes one by
7880
/// one.
7981
///
8082
/// @return
8183
/// True on success; false otherwise
8284
//------------------------------------------------------------------
83-
bool runOnModule(llvm::Module &M);
85+
virtual bool
86+
runOnModule (llvm::Module &llvm_module);
8487

8588
//------------------------------------------------------------------
8689
/// Interface stub
90+
///
91+
/// Implementation of the llvm::ModulePass::assignPassManager()
92+
/// function.
8793
//------------------------------------------------------------------
88-
void assignPassManager(llvm::PMStack &PMS,
89-
llvm::PassManagerType T = llvm::PMT_ModulePassManager);
94+
virtual void
95+
assignPassManager (llvm::PMStack &pass_mgr_stack,
96+
llvm::PassManagerType pass_mgr_type = llvm::PMT_ModulePassManager);
9097

9198
//------------------------------------------------------------------
9299
/// Returns PMT_ModulePassManager
100+
///
101+
/// Implementation of the llvm::ModulePass::getPotentialPassManagerType()
102+
/// function.
93103
//------------------------------------------------------------------
94-
llvm::PassManagerType getPotentialPassManagerType() const;
104+
virtual llvm::PassManagerType
105+
getPotentialPassManagerType() const;
106+
95107
private:
96108
//------------------------------------------------------------------
97109
/// A function-level pass to take the generated global value
@@ -102,17 +114,18 @@ class IRForTarget : public llvm::ModulePass
102114
//------------------------------------------------------------------
103115
/// The top-level pass implementation
104116
///
105-
/// @param[in] M
117+
/// @param[in] llvm_module
106118
/// The module currently being processed.
107119
///
108-
/// @param[in] F
120+
/// @param[in] llvm_function
109121
/// The function currently being processed.
110122
///
111123
/// @return
112124
/// True on success; false otherwise
113125
//------------------------------------------------------------------
114-
bool createResultVariable(llvm::Module &M,
115-
llvm::Function &F);
126+
bool
127+
CreateResultVariable (llvm::Module &llvm_module,
128+
llvm::Function &llvm_function);
116129

117130
//------------------------------------------------------------------
118131
/// A function-level pass to find Objective-C constant strings and
@@ -122,7 +135,7 @@ class IRForTarget : public llvm::ModulePass
122135
//------------------------------------------------------------------
123136
/// Rewrite a single Objective-C constant string.
124137
///
125-
/// @param[in] M
138+
/// @param[in] llvm_module
126139
/// The module currently being processed.
127140
///
128141
/// @param[in] NSStr
@@ -142,25 +155,27 @@ class IRForTarget : public llvm::ModulePass
142155
/// @return
143156
/// True on success; false otherwise
144157
//------------------------------------------------------------------
145-
bool rewriteObjCConstString(llvm::Module &M,
146-
llvm::GlobalVariable *NSStr,
147-
llvm::GlobalVariable *CStr,
148-
llvm::Instruction *FirstEntryInstruction);
158+
bool
159+
RewriteObjCConstString (llvm::Module &llvm_module,
160+
llvm::GlobalVariable *NSStr,
161+
llvm::GlobalVariable *CStr,
162+
llvm::Instruction *FirstEntryInstruction);
149163

150164
//------------------------------------------------------------------
151165
/// The top-level pass implementation
152166
///
153-
/// @param[in] M
167+
/// @param[in] llvm_module
154168
/// The module currently being processed.
155169
///
156-
/// @param[in] F
170+
/// @param[in] llvm_function
157171
/// The function currently being processed.
158172
///
159173
/// @return
160174
/// True on success; false otherwise
161175
//------------------------------------------------------------------
162-
bool rewriteObjCConstStrings(llvm::Module &M,
163-
llvm::Function &F);
176+
bool
177+
RewriteObjCConstStrings (llvm::Module &llvm_module,
178+
llvm::Function &llvm_function);
164179

165180
//------------------------------------------------------------------
166181
/// A basic block-level pass to find all Objective-C method calls and
@@ -179,29 +194,31 @@ class IRForTarget : public llvm::ModulePass
179194
/// @param[in] selector_load
180195
/// The load of the statically-allocated selector.
181196
///
182-
/// @param[in] M
197+
/// @param[in] llvm_module
183198
/// The module containing the load.
184199
///
185200
/// @return
186201
/// True on success; false otherwise
187202
//------------------------------------------------------------------
188-
bool RewriteObjCSelector(llvm::Instruction* selector_load,
189-
llvm::Module &M);
203+
bool
204+
RewriteObjCSelector (llvm::Instruction* selector_load,
205+
llvm::Module &llvm_module);
190206

191207
//------------------------------------------------------------------
192208
/// The top-level pass implementation
193209
///
194-
/// @param[in] M
210+
/// @param[in] llvm_module
195211
/// The module currently being processed.
196212
///
197-
/// @param[in] BB
213+
/// @param[in] basic_block
198214
/// The basic block currently being processed.
199215
///
200216
/// @return
201217
/// True on success; false otherwise
202218
//------------------------------------------------------------------
203-
bool rewriteObjCSelectors(llvm::Module &M,
204-
llvm::BasicBlock &BB);
219+
bool
220+
RewriteObjCSelectors (llvm::Module &llvm_module,
221+
llvm::BasicBlock &basic_block);
205222

206223
//------------------------------------------------------------------
207224
/// A basic block-level pass to find all newly-declared persistent
@@ -211,7 +228,7 @@ class IRForTarget : public llvm::ModulePass
211228
/// variables look like normal locals, so they have an allocation.
212229
/// This pass excises these allocations and makes references look
213230
/// like external references where they will be resolved -- like all
214-
/// other external references -- by resolveExternals().
231+
/// other external references -- by ResolveExternals().
215232
//------------------------------------------------------------------
216233

217234
//------------------------------------------------------------------
@@ -220,26 +237,28 @@ class IRForTarget : public llvm::ModulePass
220237
/// @param[in] persistent_alloc
221238
/// The allocation of the persistent variable.
222239
///
223-
/// @param[in] M
240+
/// @param[in] llvm_module
224241
/// The module currently being processed.
225242
///
226243
/// @return
227244
/// True on success; false otherwise
228245
//------------------------------------------------------------------
229-
bool RewritePersistentAlloc(llvm::Instruction *persistent_alloc,
230-
llvm::Module &M);
246+
bool
247+
RewritePersistentAlloc (llvm::Instruction *persistent_alloc,
248+
llvm::Module &llvm_module);
231249

232250
//------------------------------------------------------------------
233251
/// The top-level pass implementation
234252
///
235-
/// @param[in] M
253+
/// @param[in] llvm_module
236254
/// The module currently being processed.
237255
///
238-
/// @param[in] BB
256+
/// @param[in] basic_block
239257
/// The basic block currently being processed.
240258
//------------------------------------------------------------------
241-
bool rewritePersistentAllocs(llvm::Module &M,
242-
llvm::BasicBlock &BB);
259+
bool
260+
RewritePersistentAllocs (llvm::Module &llvm_module,
261+
llvm::BasicBlock &basic_block);
243262

244263
//------------------------------------------------------------------
245264
/// A function-level pass to find all external variables and functions
@@ -252,7 +271,7 @@ class IRForTarget : public llvm::ModulePass
252271
//------------------------------------------------------------------
253272
/// Handle a single externally-defined variable
254273
///
255-
/// @param[in] M
274+
/// @param[in] llvm_module
256275
/// The module currently being processed.
257276
///
258277
/// @param[in] V
@@ -264,13 +283,14 @@ class IRForTarget : public llvm::ModulePass
264283
/// @return
265284
/// True on success; false otherwise
266285
//------------------------------------------------------------------
267-
bool MaybeHandleVariable(llvm::Module &M,
268-
llvm::Value *V);
286+
bool
287+
MaybeHandleVariable (llvm::Module &llvm_module,
288+
llvm::Value *value);
269289

270290
//------------------------------------------------------------------
271291
/// Handle all the arguments to a function call
272292
///
273-
/// @param[in] M
293+
/// @param[in] llvm_module
274294
/// The module currently being processed.
275295
///
276296
/// @param[in] C
@@ -279,13 +299,14 @@ class IRForTarget : public llvm::ModulePass
279299
/// @return
280300
/// True on success; false otherwise
281301
//------------------------------------------------------------------
282-
bool MaybeHandleCallArguments(llvm::Module &M,
283-
llvm::CallInst *C);
302+
bool
303+
MaybeHandleCallArguments (llvm::Module &llvm_module,
304+
llvm::CallInst *call_inst);
284305

285306
//------------------------------------------------------------------
286307
/// Handle a single external function call
287308
///
288-
/// @param[in] M
309+
/// @param[in] llvm_module
289310
/// The module currently being processed.
290311
///
291312
/// @param[in] C
@@ -294,38 +315,41 @@ class IRForTarget : public llvm::ModulePass
294315
/// @return
295316
/// True on success; false otherwise
296317
//------------------------------------------------------------------
297-
bool MaybeHandleCall(llvm::Module &M,
298-
llvm::CallInst *C);
318+
bool
319+
MaybeHandleCall (llvm::Module &llvm_module,
320+
llvm::CallInst *C);
299321

300322
//------------------------------------------------------------------
301323
/// Resolve calls to external functions
302324
///
303-
/// @param[in] M
325+
/// @param[in] llvm_module
304326
/// The module currently being processed.
305327
///
306-
/// @param[in] BB
328+
/// @param[in] basic_block
307329
/// The basic block currently being processed.
308330
///
309331
/// @return
310332
/// True on success; false otherwise
311333
//------------------------------------------------------------------
312-
bool resolveCalls(llvm::Module &M,
313-
llvm::BasicBlock &BB);
334+
bool
335+
ResolveCalls (llvm::Module &llvm_module,
336+
llvm::BasicBlock &basic_block);
314337

315338
//------------------------------------------------------------------
316339
/// The top-level pass implementation
317340
///
318-
/// @param[in] M
341+
/// @param[in] llvm_module
319342
/// The module currently being processed.
320343
///
321-
/// @param[in] BB
344+
/// @param[in] basic_block
322345
/// The function currently being processed.
323346
///
324347
/// @return
325348
/// True on success; false otherwise
326349
//------------------------------------------------------------------
327-
bool resolveExternals(llvm::Module &M,
328-
llvm::Function &F);
350+
bool
351+
ResolveExternals (llvm::Module &llvm_module,
352+
llvm::Function &llvm_function);
329353

330354
//------------------------------------------------------------------
331355
/// A basic block-level pass to excise guard variables from the code.
@@ -337,17 +361,18 @@ class IRForTarget : public llvm::ModulePass
337361
//------------------------------------------------------------------
338362
/// The top-level pass implementation
339363
///
340-
/// @param[in] M
364+
/// @param[in] llvm_module
341365
/// The module currently being processed.
342366
///
343-
/// @param[in] BB
367+
/// @param[in] basic_block
344368
/// The basic block currently being processed.
345369
///
346370
/// @return
347371
/// True on success; false otherwise
348372
//------------------------------------------------------------------
349-
bool removeGuards(llvm::Module &M,
350-
llvm::BasicBlock &BB);
373+
bool
374+
RemoveGuards (llvm::Module &llvm_module,
375+
llvm::BasicBlock &basic_block);
351376

352377
//------------------------------------------------------------------
353378
/// A function-level pass to make all external variable references
@@ -359,21 +384,21 @@ class IRForTarget : public llvm::ModulePass
359384
//------------------------------------------------------------------
360385
/// The top-level pass implementation
361386
///
362-
/// @param[in] M
387+
/// @param[in] llvm_module
363388
/// The module currently being processed.
364389
///
365-
/// @param[in] F
390+
/// @param[in] llvm_function
366391
/// The function currently being processed.
367392
///
368393
/// @return
369394
/// True on success; false otherwise
370395
//------------------------------------------------------------------
371-
bool replaceVariables(llvm::Module &M,
372-
llvm::Function &F);
396+
bool
397+
ReplaceVariables (llvm::Module &llvm_module,
398+
llvm::Function &llvm_function);
373399

374400
/// Flags
375401
bool m_resolve_vars; ///< True if external variable references and persistent variable references should be resolved
376-
377402
std::string m_func_name; ///< The name of the function to translate
378403
lldb_private::ClangExpressionDeclMap *m_decl_map; ///< The DeclMap containing the Decls
379404
llvm::Constant *m_CFStringCreateWithBytes; ///< The address of the function CFStringCreateWithBytes, cast to the appropriate function pointer type
@@ -394,18 +419,19 @@ class IRForTarget : public llvm::ModulePass
394419
/// FirstEntryInstruction. These instructions replace the constant
395420
/// uses, so UnfoldConstant calls itself recursively for those.
396421
///
397-
/// @param[in] M
422+
/// @param[in] llvm_module
398423
/// The module currently being processed.
399424
///
400-
/// @param[in] F
425+
/// @param[in] llvm_function
401426
/// The function currently being processed.
402427
///
403428
/// @return
404429
/// True on success; false otherwise
405430
//------------------------------------------------------------------
406-
static bool UnfoldConstant(llvm::Constant *Old,
407-
llvm::Value *New,
408-
llvm::Instruction *FirstEntryInstruction);
431+
static bool
432+
UnfoldConstant (llvm::Constant *old_constant,
433+
llvm::Value *new_constant,
434+
llvm::Instruction *first_entry_inst);
409435
};
410436

411437
#endif

0 commit comments

Comments
 (0)