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

Struct for the collection of all relevant data for a template function which can provide a definition for an explicit instantiation from a different translation unit. More...

#include <Template.hpp>

Collaboration diagram for Template:
[legend]

Public Types

typedef std::string StringType
 

Public Member Functions

bool isTemplateFor (const Injection &candidate) const
 

Static Public Member Functions

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

Public Attributes

StringType func_name = ""
 
StringType nested_namespace = ""
 
StringType class_name = ""
 
std::vector< Paramparams
 
std::vector< Instantiator::TemplateArgumentclass_Targs
 
bool is_const = false
 
bool is_member = false
 
bool is_constructor = false
 

Detailed Description

Struct for the collection of all relevant data for a template function which can provide a definition for an explicit instantiation from a different translation unit.

Definition at line 17 of file Template.hpp.

Member Typedef Documentation

◆ StringType

typedef std::string Template::StringType

Definition at line 19 of file Template.hpp.

Member Function Documentation

◆ createFromFS()

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

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

Returns
Data bundled into a Template 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 parameters of the template -> params

Definition at line 18 of file Template.cpp.

◆ createFromMFS()

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

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

Returns
Data bundled into a Template 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

Definition at line 33 of file Template.cpp.

◆ isTemplateFor()

bool Template::isTemplateFor ( const Injection & candidate) const

Checks whether this is a matching template for the Injection candidate. I.e. the following is checked:

  • function name
  • nonresolved function parameters of candidate with function parameters of the template
  • namespace
  • const qualifier
  • constructor bit

Definition at line 82 of file Template.cpp.

Member Data Documentation

◆ class_name

StringType Template::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 37 of file Template.hpp.

◆ class_Targs

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

The class template parameters. These can either unresolved or concrete types/values. In case of unresolved parameters, just the kind is stored (type, nontype, pack, template). In case of a concrete type/value, the type/value is stored. This happens in case of partial specializations. E.g.

template <typename T> Bar<T, int>::Foo()

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

Definition at line 53 of file Template.hpp.

◆ func_name

StringType Template::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 24 of file Template.hpp.

◆ is_const

bool Template::is_const = false

Whether this member function is const qualified.

Definition at line 56 of file Template.hpp.

◆ is_constructor

bool Template::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 65 of file Template.hpp.

◆ is_member

bool Template::is_member = false

Whether this is a member function of some class.

Definition at line 59 of file Template.hpp.

◆ nested_namespace

StringType Template::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 31 of file Template.hpp.

◆ params

std::vector<Param> Template::params

A vector of the function parameters.

Note
The parameters are nonresolved because this is the signature of a function template.

Definition at line 45 of file Template.hpp.


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