@@ -840,12 +840,25 @@ static std::string GetParamSignature(const clang::Decl *decl) {
840840 return args;
841841}
842842
843+ static clang::ASTNameGenerator *name_generator = nullptr ;
844+
845+ void SetNameGenerator (clang::ASTNameGenerator *generator) {
846+ name_generator = generator;
847+ }
848+
849+ clang::ASTNameGenerator *GetNameGenerator () { return name_generator; }
850+
851+ static std::string GetMangledName (const clang::Decl *decl) {
852+ assert (name_generator);
853+ return name_generator->getName (decl);
854+ }
855+
843856static std::string GetLexicalSpecializationID (const clang::Decl *decl) {
844857 auto &ctx = decl->getASTContext ();
845858 std::string id;
846859 if (const auto *var =
847860 clang::dyn_cast<clang::VarTemplateSpecializationDecl>(decl)) {
848- id += clang::ASTNameGenerator (var-> getASTContext ()). getName (var);
861+ id += GetMangledName (var);
849862 }
850863 if (const auto *self =
851864 clang::dyn_cast<clang::ClassTemplateSpecializationDecl>(decl)) {
@@ -864,7 +877,7 @@ static std::string GetLexicalSpecializationID(const clang::Decl *decl) {
864877 }
865878 if (const auto *fn = clang::dyn_cast<clang::FunctionDecl>(dc);
866879 fn && fn->getTemplateSpecializationArgs ()) {
867- id += clang::ASTNameGenerator (fn-> getASTContext ()). getName (fn);
880+ id += GetMangledName (fn);
868881 }
869882 }
870883 return id;
@@ -937,9 +950,7 @@ std::string DisambiguateAnonymousTag(const clang::TagDecl *tag) {
937950static std::unordered_map<std::string, size_t > type_mapping;
938951
939952static size_t GetDeclId (const clang::NamedDecl *decl, bool internal) {
940- std::string key =
941- clang::ASTNameGenerator (decl->getASTContext ()).getName (decl) +
942- GetParamSignature (decl);
953+ std::string key = GetMangledName (decl) + GetParamSignature (decl);
943954 if (internal) {
944955 key += GetLocationID (decl);
945956 }
0 commit comments