diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 6bd90e53ba90..1a34f5a638f4 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -3538,6 +3538,26 @@ static SourceLocation getLocationFromExpr(const Expr *E) { return E->getLocStart(); } +static std::string getMangledStructor(std::unique_ptr &M, + std::unique_ptr &DL, + const NamedDecl *ND, + unsigned StructorType) { + std::string FrontendBuf; + llvm::raw_string_ostream FOS(FrontendBuf); + + if (const auto *CD = dyn_cast_or_null(ND)) + M->mangleCXXCtor(CD, static_cast(StructorType), FOS); + else if (const auto *DD = dyn_cast_or_null(ND)) + M->mangleCXXDtor(DD, static_cast(StructorType), FOS); + + std::string BackendBuf; + llvm::raw_string_ostream BOS(BackendBuf); + + llvm::Mangler::getNameWithPrefix(BOS, llvm::Twine(FOS.str()), *DL); + + return BOS.str(); +} + extern "C" { unsigned clang_visitChildren(CXCursor parent, @@ -3911,26 +3931,6 @@ CXString clang_Cursor_getMangling(CXCursor C) { return cxstring::createDup(FinalBufOS.str()); } -static std::string getMangledStructor(std::unique_ptr &M, - std::unique_ptr &DL, - const NamedDecl *ND, - unsigned StructorType) { - std::string FrontendBuf; - llvm::raw_string_ostream FOS(FrontendBuf); - - if (const auto *CD = dyn_cast_or_null(ND)) - M->mangleCXXCtor(CD, static_cast(StructorType), FOS); - else if (const auto *DD = dyn_cast_or_null(ND)) - M->mangleCXXDtor(DD, static_cast(StructorType), FOS); - - std::string BackendBuf; - llvm::raw_string_ostream BOS(BackendBuf); - - llvm::Mangler::getNameWithPrefix(BOS, llvm::Twine(FOS.str()), *DL); - - return BOS.str(); -} - CXStringSet *clang_Cursor_getCXXManglings(CXCursor C) { if (clang_isInvalid(C.kind) || !clang_isDeclaration(C.kind)) return nullptr;