Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
caesr-pub
systemc-clang
Commits
006fb5e1
Commit
006fb5e1
authored
Jun 15, 2019
by
rmrf
Browse files
Add FindTemplateParameters
parent
b0fcd790
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
+78
-0
src/FindTemplateParameters.cpp
src/FindTemplateParameters.cpp
+49
-0
src/FindTemplateParameters.h
src/FindTemplateParameters.h
+29
-0
No files found.
src/FindTemplateParameters.cpp
0 → 100644
View file @
006fb5e1
#include "FindTemplateParameters.h"
#include "FindTemplateTypes.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Type.h"
#include "clang/Basic/SourceManager.h"
using
namespace
scpar
;
FindTemplateParameters
::
FindTemplateParameters
(
CXXRecordDecl
*
declaration
,
llvm
::
raw_ostream
&
os
)
:
declaration_
{
declaration
},
os_
{
os
},
template_parameters_
{
nullptr
}
{
if
(
declaration
->
hasDefinition
()
==
true
)
{
TraverseDecl
(
declaration
);
}
}
bool
FindTemplateParameters
::
VisitCXXRecordDecl
(
CXXRecordDecl
*
declaration
)
{
if
(
IdentifierInfo
*
info
=
declaration_
->
getIdentifier
())
{
auto
module_name
=
info
->
getNameStart
();
// Check if the class is a templated module class.
auto
template_args
{
declaration
->
getDescribedClassTemplate
()
};
if
(
template_args
!=
nullptr
)
{
template_parameters_
=
template_args
->
getTemplateParameters
();
}
}
return
false
;
}
vector
<
string
>
FindTemplateParameters
::
getTemplateParameters
()
const
{
vector
<
string
>
parm_list
;
if
(
(
template_parameters_
==
nullptr
)
||
(
template_parameters_
->
size
()
<=
0
)
)
{
return
parm_list
;
}
for
(
auto
parm
:
template_parameters_
->
asArray
()
)
{
parm_list
.
push_back
(
parm
->
getName
()
);
// os_ << "Parm: " << parm->getName() << "\n";
}
return
parm_list
;
}
FindTemplateParameters
::~
FindTemplateParameters
()
{
declaration_
=
nullptr
;
}
void
FindTemplateParameters
::
dump
()
{
}
src/FindTemplateParameters.h
0 → 100644
View file @
006fb5e1
#ifndef _FIND_TEMPLATE_PARAMETERS_H_
#define _FIND_TEMPLATE_PARAMETERS_H_
#include "clang/AST/DeclCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "llvm/Support/raw_ostream.h"
namespace
scpar
{
using
namespace
clang
;
using
namespace
std
;
class
FindTemplateParameters
:
public
RecursiveASTVisitor
<
FindTemplateParameters
>
{
public:
FindTemplateParameters
(
CXXRecordDecl
*
,
llvm
::
raw_ostream
&
);
virtual
bool
VisitCXXRecordDecl
(
CXXRecordDecl
*
decl
);
virtual
~
FindTemplateParameters
();
void
dump
();
vector
<
string
>
getTemplateParameters
()
const
;
private:
CXXRecordDecl
*
declaration_
;
llvm
::
raw_ostream
&
os_
;
TemplateParameterList
*
template_parameters_
;
};
}
// namespace scpar
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment