Index: clang/include/clang/Index/CodegenNameGenerator.h =================================================================== --- clang/include/clang/Index/CodegenNameGenerator.h +++ clang/include/clang/Index/CodegenNameGenerator.h @@ -13,7 +13,10 @@ #ifndef LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H #define LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H +#include "clang/AST/DeclCXX.h" +#include "clang/AST/Mangle.h" #include "clang/Basic/LLVM.h" +#include "llvm/Support/raw_ostream.h" #include #include #include @@ -24,6 +27,8 @@ namespace index { +bool writeFuncOrVarName(MangleContext *MC, const NamedDecl *D, raw_ostream &OS); + class CodegenNameGenerator { public: explicit CodegenNameGenerator(ASTContext &Ctx); Index: clang/lib/Index/CodegenNameGenerator.cpp =================================================================== --- clang/lib/Index/CodegenNameGenerator.cpp +++ clang/lib/Index/CodegenNameGenerator.cpp @@ -24,6 +24,29 @@ using namespace clang; using namespace clang::index; +namespace clang { +namespace index { +bool writeFuncOrVarName(MangleContext *MC, const NamedDecl *D, + raw_ostream &OS) { + if (MC->shouldMangleDeclName(D)) { + if (const auto *CtorD = dyn_cast(D)) + MC->mangleCXXCtor(CtorD, Ctor_Complete, OS); + else if (const auto *DtorD = dyn_cast(D)) + MC->mangleCXXDtor(DtorD, Dtor_Complete, OS); + else + MC->mangleName(D, OS); + return false; + } else { + IdentifierInfo *II = D->getIdentifier(); + if (!II) + return true; + OS << II->getName(); + return false; + } +} +} // namespace index +} // namespace clang + struct CodegenNameGenerator::Implementation { std::unique_ptr MC; llvm::DataLayout DL; @@ -147,21 +170,7 @@ private: bool writeFuncOrVarName(const NamedDecl *D, raw_ostream &OS) { - if (MC->shouldMangleDeclName(D)) { - if (const auto *CtorD = dyn_cast(D)) - MC->mangleCXXCtor(CtorD, Ctor_Complete, OS); - else if (const auto *DtorD = dyn_cast(D)) - MC->mangleCXXDtor(DtorD, Dtor_Complete, OS); - else - MC->mangleName(D, OS); - return false; - } else { - IdentifierInfo *II = D->getIdentifier(); - if (!II) - return true; - OS << II->getName(); - return false; - } + return clang::index::writeFuncOrVarName(MC.get(), D, OS); } void writeObjCClassName(const ObjCInterfaceDecl *D, raw_ostream &OS) {