| 62 | } |
| 63 | |
| 64 | static inline std::vector<std::string> |
| 65 | getMangledNames(const clang::NamedDecl &D) { |
| 66 | // NOTE: getAllManglings method causes segmentation fault when a specific |
| 67 | // instance of CXXMethodDecl is given. To bypass this bug, below logic |
| 68 | // is used instead and its reasonable because getAllManglings is used |
| 69 | // to get more precise result for constructors and destructors only. |
| 70 | // However, from the version where the bug is fixed, it would be desriable to |
| 71 | // use getAllMangling for any cases to erase unnecessary conditions. |
| 72 | if (llvm::isa<clang::CXXConstructorDecl>(&D) || |
| 73 | llvm::isa<clang::CXXDestructorDecl>(&D)) { |
| 74 | auto MangledNames = |
| 75 | clang::ASTNameGenerator(D.getASTContext()).getAllManglings(&D); |
| 76 | if (MangledNames.size() == 0) |
| 77 | MangledNames.emplace_back(D.getNameAsString()); |
| 78 | return MangledNames; |
| 79 | } |
| 80 | |
| 81 | auto MangleCtx = std::unique_ptr<clang::MangleContext>( |
| 82 | D.getASTContext().createMangleContext()); |
| 83 | if (!MangleCtx) |
| 84 | return {D.getNameAsString()}; |
| 85 | |
| 86 | if (!MangleCtx->shouldMangleDeclName(&D)) { |
| 87 | return {D.getNameAsString()}; |
| 88 | } |
| 89 | |
| 90 | std::string MangledName; |
| 91 | llvm::raw_string_ostream OS(MangledName); |
| 92 | MangleCtx->mangleName(&D, OS); |
| 93 | OS.flush(); |
| 94 | return {MangledName}; |
| 95 | } |
| 96 | |
| 97 | static inline std::string getFullPath(const llvm::DIFile &F) { |
| 98 | std::string Name = F.getFilename().str(); |