diff options
Diffstat (limited to 'src/common/module.h')
-rw-r--r-- | src/common/module.h | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/src/common/module.h b/src/common/module.h index 7309cedd..60bf709b 100644 --- a/src/common/module.h +++ b/src/common/module.h @@ -74,7 +74,7 @@ class Module { // A source file. struct File { - explicit File(const string &name_input) : name(name_input), source_id(0) {} + explicit File(const string& name_input) : name(name_input), source_id(0) {} // The name of the source file. const string name; @@ -96,12 +96,12 @@ class Module { // A function. struct Function { - Function(const string &name_input, const Address &address_input) : + Function(const string& name_input, const Address& address_input) : name(name_input), address(address_input), parameter_size(0) {} // For sorting by address. (Not style-guide compliant, but it's // stupid not to put this in the struct.) - static bool CompareByAddress(const Function *x, const Function *y) { + static bool CompareByAddress(const Function* x, const Function* y) { return x->address < y->address; } @@ -124,18 +124,18 @@ class Module { struct Line { // For sorting by address. (Not style-guide compliant, but it's // stupid not to put this in the struct.) - static bool CompareByAddress(const Module::Line &x, const Module::Line &y) { + static bool CompareByAddress(const Module::Line& x, const Module::Line& y) { return x.address < y.address; } Address address, size; // The address and size of the line's code. - File *file; // The source file. + File* file; // The source file. int number; // The source line number. }; // An exported symbol. struct Extern { - explicit Extern(const Address &address_input) : address(address_input) {} + explicit Extern(const Address& address_input) : address(address_input) {} const Address address; string name; }; @@ -170,8 +170,7 @@ class Module { }; struct FunctionCompare { - bool operator() (const Function *lhs, - const Function *rhs) const { + bool operator() (const Function* lhs, const Function* rhs) const { if (lhs->address == rhs->address) return lhs->name < rhs->name; return lhs->address < rhs->address; @@ -179,16 +178,15 @@ class Module { }; struct ExternCompare { - bool operator() (const Extern *lhs, - const Extern *rhs) const { + bool operator() (const Extern* lhs, const Extern* rhs) const { return lhs->address < rhs->address; } }; // Create a new module with the given name, operating system, // architecture, and ID string. - Module(const string &name, const string &os, const string &architecture, - const string &id, const string &code_id = ""); + Module(const string& name, const string& os, const string& architecture, + const string& id, const string& code_id = ""); ~Module(); // Set the module's load address to LOAD_ADDRESS; addresses given @@ -216,62 +214,62 @@ class Module { // Add FUNCTION to the module. FUNCTION's name must not be empty. // This module owns all Function objects added with this function: // destroying the module destroys them as well. - void AddFunction(Function *function); + void AddFunction(Function* function); // Add all the functions in [BEGIN,END) to the module. // This module owns all Function objects added with this function: // destroying the module destroys them as well. - void AddFunctions(vector<Function *>::iterator begin, - vector<Function *>::iterator end); + void AddFunctions(vector<Function*>::iterator begin, + vector<Function*>::iterator end); // Add STACK_FRAME_ENTRY to the module. // This module owns all StackFrameEntry objects added with this // function: destroying the module destroys them as well. - void AddStackFrameEntry(StackFrameEntry *stack_frame_entry); + void AddStackFrameEntry(StackFrameEntry* stack_frame_entry); // Add PUBLIC to the module. // This module owns all Extern objects added with this function: // destroying the module destroys them as well. - void AddExtern(Extern *ext); + void AddExtern(Extern* ext); // If this module has a file named NAME, return a pointer to it. If // it has none, then create one and return a pointer to the new // file. This module owns all File objects created using these // functions; destroying the module destroys them as well. - File *FindFile(const string &name); - File *FindFile(const char *name); + File* FindFile(const string& name); + File* FindFile(const char* name); // If this module has a file named NAME, return a pointer to it. // Otherwise, return NULL. - File *FindExistingFile(const string &name); + File* FindExistingFile(const string& name); // Insert pointers to the functions added to this module at I in // VEC. The pointed-to Functions are still owned by this module. // (Since this is effectively a copy of the function list, this is // mostly useful for testing; other uses should probably get a more // appropriate interface.) - void GetFunctions(vector<Function *> *vec, vector<Function *>::iterator i); + void GetFunctions(vector<Function*>* vec, vector<Function*>::iterator i); // Insert pointers to the externs added to this module at I in // VEC. The pointed-to Externs are still owned by this module. // (Since this is effectively a copy of the extern list, this is // mostly useful for testing; other uses should probably get a more // appropriate interface.) - void GetExterns(vector<Extern *> *vec, vector<Extern *>::iterator i); + void GetExterns(vector<Extern*>* vec, vector<Extern*>::iterator i); // Clear VEC and fill it with pointers to the Files added to this // module, sorted by name. The pointed-to Files are still owned by // this module. (Since this is effectively a copy of the file list, // this is mostly useful for testing; other uses should probably get // a more appropriate interface.) - void GetFiles(vector<File *> *vec); + void GetFiles(vector<File*>* vec); // Clear VEC and fill it with pointers to the StackFrameEntry // objects that have been added to this module. (Since this is // effectively a copy of the stack frame entry list, this is mostly // useful for testing; other uses should probably get // a more appropriate interface.) - void GetStackFrameEntries(vector<StackFrameEntry *> *vec) const; + void GetStackFrameEntries(vector<StackFrameEntry*>* vec) const; // Find those files in this module that are actually referred to by // functions' line number data, and assign them source id numbers. @@ -292,7 +290,7 @@ class Module { // - all CFI records. // Addresses in the output are all relative to the load address // established by SetLoadAddress. - bool Write(std::ostream &stream, SymbolData symbol_data); + bool Write(std::ostream& stream, SymbolData symbol_data); string name() const { return name_; } string os() const { return os_; } @@ -308,7 +306,7 @@ class Module { // Write RULE_MAP to STREAM, in the form appropriate for 'STACK CFI' // records, without a final newline. Return true if all goes well; // if an error occurs, return false, and leave errno set. - static bool WriteRuleMap(const RuleMap &rule_map, std::ostream &stream); + static bool WriteRuleMap(const RuleMap& rule_map, std::ostream& stream); // Returns true of the specified address resides with an specified address // range, or if no ranges have been specified. @@ -329,18 +327,18 @@ class Module { // Relation for maps whose keys are strings shared with some other // structure. struct CompareStringPtrs { - bool operator()(const string *x, const string *y) const { return *x < *y; } + bool operator()(const string* x, const string* y) const { return *x < *y; } }; // A map from filenames to File structures. The map's keys are // pointers to the Files' names. - typedef map<const string *, File *, CompareStringPtrs> FileByNameMap; + typedef map<const string*, File*, CompareStringPtrs> FileByNameMap; // A set containing Function structures, sorted by address. - typedef set<Function *, FunctionCompare> FunctionSet; + typedef set<Function*, FunctionCompare> FunctionSet; // A set containing Extern structures, sorted by address. - typedef set<Extern *, ExternCompare> ExternSet; + typedef set<Extern*, ExternCompare> ExternSet; // The module owns all the files and functions that have been added // to it; destroying the module frees the Files and Functions these @@ -350,7 +348,7 @@ class Module { // The module owns all the call frame info entries that have been // added to it. - vector<StackFrameEntry *> stack_frame_entries_; + vector<StackFrameEntry*> stack_frame_entries_; // The module owns all the externs that have been added to it; // destroying the module frees the Externs these point to. |