Instantiator
Generate c++ template instantiations
Loading...
Searching...
No Matches
GetNeededInstantiations.cpp
Go to the documentation of this file.
2
3#include "spdlog/spdlog.h"
4
5#include "clang/AST/Decl.h"
6#include "clang/AST/DeclCXX.h"
7#include "clang/AST/DeclTemplate.h"
8
9#include "Injection.hpp"
10
11void GetNeededInstantiations::run(const clang::ast_matchers::MatchFinder::MatchResult& Result)
12{
13 clang::PrintingPolicy pp(Result.Context->getLangOpts());
14 pp.PrintInjectedClassNameWithArguments = true;
15 pp.PrintCanonicalTypes = true;
16 pp.SuppressDefaultTemplateArgs = true;
17 pp.FullyQualifiedName = true;
18 pp.SuppressScope = false;
19 // pp.UsePreferredNames = true;
20
21 Injection toDo;
22 if(const clang::CXXMethodDecl* MFS = Result.Nodes.getNodeAs<clang::CXXMethodDecl>("templ_func_instantation")) {
23 if(const clang::MemberSpecializationInfo* MSI = MFS->getMemberSpecializationInfo()) {
24 if(MSI->getPointOfInstantiation().isValid()) {
25 toDo = Injection::createFromMFS(MFS, pp);
26 toDoList->push_back(toDo);
27 }
28 } else if(const clang::FunctionTemplateSpecializationInfo* TSI = MFS->getTemplateSpecializationInfo()) {
29 if(TSI->getPointOfInstantiation().isValid()) {
30 toDo = Injection::createFromMFS(MFS, pp);
31 toDoList->push_back(toDo);
32 }
33 }
34 } else if(const clang::FunctionDecl* FS = Result.Nodes.getNodeAs<clang::FunctionDecl>("templ_func_instantation")) {
35 if(const clang::FunctionTemplateSpecializationInfo* TSI = FS->getTemplateSpecializationInfo()) {
36 if(TSI->getPointOfInstantiation().isValid()) {
37 spdlog::debug("Created with success.");
38 toDo = Injection::createFromFS(FS, pp);
39 toDoList->push_back(toDo);
40 }
41 }
42 }
43}
std::vector< Injection > * toDoList
virtual void run(const clang::ast_matchers::MatchFinder::MatchResult &Result) override
Struct for the collection of all relevant data for a template instantiation which needs to be inserte...
Definition Injection.hpp:21
static Injection createFromFS(const clang::FunctionDecl *FS, clang::PrintingPolicy pp)
Definition Injection.cpp:30
static Injection createFromMFS(const clang::CXXMethodDecl *MFS, clang::PrintingPolicy pp)
Definition Injection.cpp:52