systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
FindGlobalEvents.cpp
Go to the documentation of this file.
1#include "FindGlobalEvents.h"
2#include "clang/AST/Decl.h"
3
4using namespace systemc_clang;
5
6FindGlobalEvents::FindGlobalEvents(clang::TranslationUnitDecl *declaration,
7 llvm::raw_ostream &os)
8 : _os(os) {
9 TraverseDecl(declaration);
10}
11
13
14bool 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
28
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
39std::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(clang::TranslationUnitDecl *, llvm::raw_ostream &)
virtual bool VisitVarDecl(clang::VarDecl *)
std::map< std::string, clang::VarDecl * > globalEventMapType
std::pair< std::string, clang::VarDecl * > kvType