17 const std::vector<llvm::StringRef> &names) {
21 if (
auto mce = dyn_cast<CXXMemberCallExpr>(ce)) {
22 const Type* obj_ptr{ mce->getObjectType().getTypePtr()};
25 if (
auto oce = dyn_cast<CXXOperatorCallExpr>(ce)) {
26 const Decl* decl{ oce->getCalleeDecl()};
27 if (
auto cxxdecl = dyn_cast<CXXRecordDecl>(decl)) {
106 const clang::CXXRecordDecl *decl) {
110 std::queue<const clang::CXXRecordDecl *> decl_queue;
111 std::vector<const clang::CXXRecordDecl *> bases;
112 llvm::StringSet<> bases_set;
115 const clang::CXXRecordDecl *top_decl{decl};
118 auto name{top_decl->getNameAsString()};
122 bases.push_back(top_decl);
123 bases_set.insert(top_decl->getName());
125 for (
auto &base : top_decl->bases()) {
126 const clang::CXXRecordDecl *base_decl{
127 base.getType().getTypePtr()->getAsCXXRecordDecl()};
129 decl_queue.push(base_decl);
132 if (!decl_queue.empty()) {
133 top_decl = decl_queue.front();
141 LLVM_DEBUG(llvm::dbgs() <<
"Bases collected: ";);
142 for (
auto const &base : bases) {
143 LLVM_DEBUG(llvm::dbgs() << base->getNameAsString() <<
" ";);
145 LLVM_DEBUG(llvm::dbgs() <<
"\n";);
151 const clang::CXXRecordDecl *decl) {
155 std::queue<const clang::CXXRecordDecl *> decl_queue;
156 std::vector<const clang::CXXRecordDecl *> bases;
159 const clang::CXXRecordDecl *top_decl{decl};
162 auto name{top_decl->getNameAsString()};
164 LLVM_DEBUG(llvm::dbgs() <<
"Processing base named: " << name <<
"\n";);
167 if ((top_decl != decl) && (name !=
"sc_object") &&
168 (name !=
"sc_process_host") && (name !=
"sc_module")) {
169 LLVM_DEBUG(llvm::dbgs() <<
"+ Insert into bases\n";);
170 bases.push_back(top_decl);
174 for (
auto &base : top_decl->bases()) {
175 const clang::CXXRecordDecl *base_decl{
176 base.getType().getTypePtr()->getAsCXXRecordDecl()};
178 decl_queue.push(base_decl);
181 if (!decl_queue.empty()) {
182 top_decl = decl_queue.front();
190 LLVM_DEBUG(llvm::dbgs() <<
"Bases collected: ";);
191 for (
auto const &base : bases) {
192 LLVM_DEBUG(llvm::dbgs() << base->getNameAsString() <<
" ";);
194 LLVM_DEBUG(llvm::dbgs() <<
"\n";);
200 const clang::CXXCtorInitializer *init) {
203 std::vector<ModuleInitializerTupleType> module_info;
209 clang::Expr *str_expr{init->getInit()->IgnoreUnlessSpelledInSource()};
212 clang::StringLiteral *str_lit{llvm::dyn_cast<clang::StringLiteral>(str_expr)};
214 LLVM_DEBUG(llvm::dbgs()
215 <<
"Get first arg: " << str_lit->getString() <<
"\n";);
219 clang::FieldDecl *fd{init->getMember()};
221 auto name{fd->getType().getAsString()};
222 LLVM_DEBUG(llvm::dbgs()
223 <<
"\n *************** Initializer names ****** : " << name
227 auto decl{fd->getType()
229 ->getUnqualifiedDesugaredType()
230 ->getAsCXXRecordDecl()};
233 LLVM_DEBUG(llvm::dbgs() <<
"decl: " << decl->getNameAsString() <<
"\n";);
234 for (
const auto &base : decl->bases()) {
235 clang::CXXRecordDecl *base_decl{base.getType()
237 ->getUnqualifiedDesugaredType()
238 ->getAsCXXRecordDecl()};
240 LLVM_DEBUG(llvm::dbgs() <<
"base decl: "
241 << base_decl->getNameAsString() <<
"\n";);
243 if (base_decl->getNameAsString() ==
"sc_module") {
244 LLVM_DEBUG(llvm::dbgs() <<
"Module class\n";);
245 module_info.push_back(
246 std::make_tuple(fd, str_lit->getString().str(), init));