retdec
Static Public Member Functions | List of all members
retdec::llvmir2hll::StructTypesSorter Class Reference

Sorts structured types according to their names and dependencies. More...

#include <struct_types_sorter.h>

Inheritance diagram for retdec::llvmir2hll::StructTypesSorter:
Inheritance graph
[legend]
Collaboration diagram for retdec::llvmir2hll::StructTypesSorter:
Collaboration graph
[legend]

Static Public Member Functions

static StructTypeVector sort (const StructTypeSet &types)
 Sorts the given set of structured types according to their names and dependencies. More...
 

Additional Inherited Members

- Private Member Functions inherited from retdec::utils::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 

Detailed Description

Sorts structured types according to their names and dependencies.

This class implements the "static helper" (or "library") design pattern (it has just static functions and no instances can be created).

Member Function Documentation

◆ sort()

StructTypeVector retdec::llvmir2hll::StructTypesSorter::sort ( const StructTypeSet types)
static

Sorts the given set of structured types according to their names and dependencies.

For example, if types contains the following three structures

struct A { struct B b; };
struct B { struct C c; };
struct C {};

then they are ordered in the following way

struct C {};
struct B { struct C c; };
struct A { struct B b; };

This is the order in which they have to be defined.

Before the structures are compared based on dependencies, they are sorted by their names. This results into a more deterministic output.

Preconditions
  • the structures can be sorted, i.e. there are no dependency loops that would prevent the structures from being sorted (standard C behavior)

The documentation for this class was generated from the following files: