Instantiator
Generate c++ template instantiations
Loading...
Searching...
No Matches
Injection Struct Reference

Struct for the collection of all relevant data for a template instantiation which needs to be inserted somewhere. More...

#include <Injection.hpp>

Collaboration diagram for Injection:
[legend]

Public Types

typedef std::string StringType
 

Public Member Functions

std::string getInstantiation () const
 
bool match (const Injection &other) const
 

Static Public Member Functions

static Injection createFromMFS (const clang::CXXMethodDecl *MFS, clang::PrintingPolicy pp)
 
static Injection createFromFS (const clang::FunctionDecl *FS, clang::PrintingPolicy pp)
 

Public Attributes

StringType func_name = ""
 
StringType nested_namespace = ""
 
StringType class_name = ""
 
std::string return_type = ""
 
std::vector< std::string > func_Ttypes
 
std::vector< Instantiator::TemplateArgumentclass_Targs
 
std::vector< Paramparams
 
std::vector< Paramnonresolved_params
 
bool is_const = false
 
bool is_member = false
 
bool is_constructor = false
 
StringType guess_injection_place
 

Detailed Description

Struct for the collection of all relevant data for a template instantiation which needs to be inserted somewhere.

Definition at line 20 of file Injection.hpp.

Member Typedef Documentation

◆ StringType

typedef std::string Injection::StringType

Definition at line 22 of file Injection.hpp.

Member Function Documentation

◆ createFromFS()

Injection Injection::createFromFS ( const clang::FunctionDecl * FS,
clang::PrintingPolicy pp )
static

Function to load all needed data from a clang::FunctionDecl.

Returns
Data bundled into an Injection instance.
Parameters
FSPointer to a clang::FunctionDecl.
ppclang::PrintingPolicy which controls how strings are created.

The following data is parsed:

  • Function name -> func_name
  • Nested namespace in which the function is defined -> nested_namespace
  • Function return type -> return_type
  • Function template arguments -> func_Ttypes
  • Function parameters with fully resolved types -> params
  • Function parameters with nonresolved types -> nonresolved_params

Definition at line 30 of file Injection.cpp.

◆ createFromMFS()

Injection Injection::createFromMFS ( const clang::CXXMethodDecl * MFS,
clang::PrintingPolicy pp )
static

Function to load all needed data from a clang::CXXMethodDecl.

Returns
Data bundled into an Injection instance.
Parameters
MFSPointer to a clang::CXXMethodDecl.
ppclang::PrintingPolicy which controls how strings are created.

Calls createFromFS() and loads the following member function information:

  • Sets is_member to true.
  • Determine whether it is a contructor -> is_constructor
  • Determines whether this is a const qualified member function -> is_const
  • Resets the nested namespace qualifier to the nested namespace of the parent class -> nested_namespace
  • Class name of parent class -> class_name
  • Template arguments of the class -> class_Ttypes
  • nonresolved function parameters in the case that this function is not a function template -> nonresolved_params

Definition at line 52 of file Injection.cpp.

◆ getInstantiation()

std::string Injection::getInstantiation ( ) const
Returns
The string which needs to inserted to explicitly instantiate this function template or class template member function.

Definition at line 95 of file Injection.cpp.

◆ match()

bool Injection::match ( const Injection & other) const

Checks whether other does exactly match this entry. I.e.:

  • function name
  • resolved funtion parameters
  • namespace
  • function template arguments
  • class template arguments
  • const qualifier
  • constructor bit

Definition at line 15 of file Injection.cpp.

Member Data Documentation

◆ class_name

StringType Injection::class_name = ""

For member functions, this is the name of the parent class. For free functions it is empty. E.g.

void Bar::Foo<T1,T2>(const T1& t1, const T2& t2)

the class name would be "Bar".

Definition at line 40 of file Injection.hpp.

◆ class_Targs

std::vector<Instantiator::TemplateArgument> Injection::class_Targs

The concrete types of the class template parameters (for class template member functions only). E.g.

void Bar<double, int>::Foo()

it would be {"double", "int"}

Definition at line 57 of file Injection.hpp.

◆ func_name

StringType Injection::func_name = ""

Name of the function without namespace and template parameters. For

void Bar::Foo<T1,T2>(const T1& t1, const T2& t2)

the name would be "Foo".

Definition at line 27 of file Injection.hpp.

◆ func_Ttypes

std::vector<std::string> Injection::func_Ttypes

The concrete types of the function template parameters. E.g.

void Bar::Foo<double,int>(const double& t1, const int& t2)

it would be {"double", "int"}

Definition at line 51 of file Injection.hpp.

◆ guess_injection_place

StringType Injection::guess_injection_place

Unused so far. Intended for more efficiency in the lookup step.

Definition at line 85 of file Injection.hpp.

◆ is_const

bool Injection::is_const = false

Whether this member function is const qualified.

Definition at line 73 of file Injection.hpp.

◆ is_constructor

bool Injection::is_constructor = false

Whether this a class constructor.

Note
Names of class constructors are special in c++. We therefore don't need to compare it when we search for matches of constructors.

Definition at line 82 of file Injection.hpp.

◆ is_member

bool Injection::is_member = false

Whether this is a member function of some class.

Definition at line 76 of file Injection.hpp.

◆ nested_namespace

StringType Injection::nested_namespace = ""

Nested namespace of the function. For For

void My::Nested::Namespace::Foo<T1,T2>(const T1& t1, const T2& t2)

the nested namespace would be "My::Nested::Namespace".

Definition at line 34 of file Injection.hpp.

◆ nonresolved_params

std::vector<Param> Injection::nonresolved_params

A vector of the function parameters where the parameters are not resolved with concrete types. If all of the parameter are nondependent on template parameters its the same as params. This information is needed to compare this Injection with possible candidates which provide the appropriate definition.

Definition at line 70 of file Injection.hpp.

◆ params

std::vector<Param> Injection::params

A vector of the function parameters where each parameter is fully resolved with the concrete types. This information is needed to create the explicit instantiation.

Definition at line 63 of file Injection.hpp.

◆ return_type

std::string Injection::return_type = ""

The return type of the function.

Definition at line 45 of file Injection.hpp.


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