systemc-clang
2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
src
matchers
FindGlobalEvents.cpp
Go to the documentation of this file.
1
#include "
FindGlobalEvents.h
"
2
#include "clang/AST/Decl.h"
3
4
using namespace
systemc_clang
;
5
6
FindGlobalEvents::FindGlobalEvents
(clang::TranslationUnitDecl *declaration,
7
llvm::raw_ostream &os)
8
: _os(os) {
9
TraverseDecl(declaration);
10
}
11
12
FindGlobalEvents::~FindGlobalEvents
() {}
13
14
bool
FindGlobalEvents::VisitVarDecl
(clang::VarDecl *variable_declaration) {
15
clang::QualType variable_type{variable_declaration->getType()};
16
17
if
(variable_type.getAsString() ==
"class sc_core::sc_event"
) {
18
if
(clang::IdentifierInfo *info = variable_declaration->getIdentifier()) {
19
_globalEvents
.insert(
kvType
(info->getNameStart(), variable_declaration));
20
}
21
}
22
return
true
;
23
}
24
25
FindGlobalEvents::globalEventMapType
FindGlobalEvents::getEventMap
() {
26
return
_globalEvents
;
27
}
28
29
void
FindGlobalEvents::dump
() {
30
_os
<<
"\n ============== FindGlobalEvents ==============="
;
31
_os
<<
"\n:> Print global sc_event variables"
;
32
for
(globalEventMapType::iterator vit =
_globalEvents
.begin();
33
vit !=
_globalEvents
.end(); vit++) {
34
_os
<<
"\n Name: "
<< vit->first <<
", VarDecl*: "
<< vit->second;
35
}
36
_os
<<
"\n ============== END FindGlobalEvents ==============="
;
37
}
38
39
std::string
FindGlobalEvents::asString
()
const
{
40
std::string str{};
41
42
if
(
_globalEvents
.size() > 0) {
43
str +=
"global_declarations: "
;
44
}
45
46
for
(
auto
const
&event :
_globalEvents
) {
47
str +=
" "
+
event
.first;
48
}
49
50
str +=
"\n"
;
51
llvm::outs() << str;
52
return
str;
53
}
FindGlobalEvents.h
systemc_clang::FindGlobalEvents::getEventMap
globalEventMapType getEventMap()
Definition
FindGlobalEvents.cpp:25
systemc_clang::FindGlobalEvents::FindGlobalEvents
FindGlobalEvents(clang::TranslationUnitDecl *, llvm::raw_ostream &)
Definition
FindGlobalEvents.cpp:6
systemc_clang::FindGlobalEvents::VisitVarDecl
virtual bool VisitVarDecl(clang::VarDecl *)
Definition
FindGlobalEvents.cpp:14
systemc_clang::FindGlobalEvents::_os
llvm::raw_ostream & _os
Definition
FindGlobalEvents.h:37
systemc_clang::FindGlobalEvents::globalEventMapType
std::map< std::string, clang::VarDecl * > globalEventMapType
Definition
FindGlobalEvents.h:22
systemc_clang::FindGlobalEvents::~FindGlobalEvents
virtual ~FindGlobalEvents()
Definition
FindGlobalEvents.cpp:12
systemc_clang::FindGlobalEvents::asString
std::string asString() const
Definition
FindGlobalEvents.cpp:39
systemc_clang::FindGlobalEvents::kvType
std::pair< std::string, clang::VarDecl * > kvType
Definition
FindGlobalEvents.h:23
systemc_clang::FindGlobalEvents::dump
void dump()
Definition
FindGlobalEvents.cpp:29
systemc_clang::FindGlobalEvents::_globalEvents
globalEventMapType _globalEvents
Definition
FindGlobalEvents.h:38
systemc_clang
Definition
SplitCFG.h:10
Generated by
1.12.0