@@ -2433,24 +2433,6 @@ namespace BinaryNinja {
24332433 */
24342434 Ref<BinaryView> Load(Ref<BinaryView> rawData, bool updateAnalysis, ProgressFunction progress, Ref<Metadata> options = new Metadata(MetadataType::KeyValueDataType), bool isDatabase = false);
24352435
2436- /*! Determines if a symbol name is a mangled Microsoft Visual Studio C++ name
2437-
2438- \param[in] mangledName a potentially mangled name
2439-
2440- \ingroup demangle
2441- */
2442- bool IsMSVCMangledString(const std::string& mangledName);
2443-
2444- /*! Determines if a symbol name is a mangled GNU3 name
2445-
2446- \param[in] mangledName a potentially mangled name
2447-
2448- \ingroup demangle
2449- */
2450- bool IsGNU3MangledString(const std::string& mangledName);
2451-
2452- QualifiedName SimplifyDemangledTemplateName(const QualifiedName& name);
2453-
24542436 /*!
24552437 \ingroup mainthread
24562438 */
@@ -4723,8 +4705,7 @@ namespace BinaryNinja {
47234705 struct DemanglerConfig
47244706 {
47254707 Ref<Platform> platform;
4726- // Borrowed reference; the caller must keep the view alive while this config is in use.
4727- BinaryView* view = nullptr;
4708+ Ref<BinaryView> view;
47284709 bool simplifyTemplates = false;
47294710
47304711 DemanglerConfig(
@@ -4736,9 +4717,6 @@ namespace BinaryNinja {
47364717
47374718 Platform& GetPlatform() const;
47384719 BNDemanglerConfig ToAPIObject() const;
4739-
4740- private:
4741- Ref<BinaryView> m_viewOwner;
47424720 };
47434721
47444722 struct DemanglerResult
@@ -4747,10 +4725,12 @@ namespace BinaryNinja {
47474725 Ref<Type> type;
47484726
47494727 static DemanglerResult FromAPIObject(const BNDemanglerResult* result);
4750- static DemanglerResult FromAPIObjectAndFree(BNDemanglerResult* result);
47514728 BNDemanglerResult ToAPIObject() const;
4729+ static void FreeAPIObject(BNDemanglerResult* result);
47524730 };
47534731
4732+ QualifiedName SimplifyDemangledTemplateName(const QualifiedName& name);
4733+
47544734 /*! Demangles using LLVM's demangler.
47554735
47564736 \param[in] mangledName A mangled MSVC/GNU3/Rust/D name.
@@ -4786,6 +4766,64 @@ namespace BinaryNinja {
47864766 std::optional<DemanglerResult> DemangleGNU3(
47874767 const Platform* platform, const std::string& mangledName, bool simplify = true);
47884768
4769+ /*! Determines if a symbol name is a mangled Microsoft Visual Studio C++ name.
4770+
4771+ \param[in] mangledName A potentially mangled name.
4772+ \return True if the name is recognized by the built-in MSVC demangler.
4773+
4774+ \ingroup demangle
4775+ */
4776+ bool IsMSVCMangledString(const std::string& mangledName);
4777+
4778+ /*! Determines if a symbol name is a mangled GNU3 name.
4779+
4780+ \param[in] mangledName A potentially mangled name.
4781+ \return True if the name is recognized by the built-in GNU3 demangler.
4782+
4783+ \ingroup demangle
4784+ */
4785+ bool IsGNU3MangledString(const std::string& mangledName);
4786+
4787+ BN_DEPRECATED("Use Demangler::DemangleAny with DemanglerConfig")
4788+ bool DemangleGeneric(Ref<Architecture> arch, const std::string& mangledName, Ref<Type>& outType,
4789+ QualifiedName& outVarName, Ref<BinaryView> view = nullptr, bool simplify = false);
4790+
4791+ BN_DEPRECATED("Use the DemangleLLVM overload returning std::optional<DemanglerResult>")
4792+ bool DemangleLLVM(
4793+ const std::string& mangledName, QualifiedName& outVarName, bool simplify = false);
4794+
4795+ BN_DEPRECATED("Use Demangler::DemangleAny with DemanglerConfig::ForBinaryView")
4796+ bool DemangleLLVM(
4797+ const std::string& mangledName, QualifiedName& outVarName, BinaryView* view);
4798+
4799+ BN_DEPRECATED("Use the DemangleMS overload returning std::optional<DemanglerResult>")
4800+ bool DemangleMS(Architecture* arch, const std::string& mangledName, Ref<Type>& outType,
4801+ QualifiedName& outVarName, bool simplify = false);
4802+
4803+ BN_DEPRECATED("Use Demangler::DemangleAny with DemanglerConfig::ForBinaryView")
4804+ bool DemangleMS(Architecture* arch, const std::string& mangledName, Ref<Type>& outType,
4805+ QualifiedName& outVarName, BinaryView* view);
4806+
4807+ BN_DEPRECATED("Use the DemangleGNU3 overload returning std::optional<DemanglerResult>")
4808+ bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Ref<Type>& outType,
4809+ QualifiedName& outVarName, bool simplify = false);
4810+
4811+ BN_DEPRECATED("Use Demangler::DemangleAny with DemanglerConfig::ForBinaryView")
4812+ bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Ref<Type>& outType,
4813+ QualifiedName& outVarName, BinaryView* view);
4814+
4815+ BN_DEPRECATED("Use SimplifyDemangledTemplateName")
4816+ std::string SimplifyToString(const std::string& input);
4817+
4818+ BN_DEPRECATED("Use SimplifyDemangledTemplateName")
4819+ std::string SimplifyToString(const QualifiedName& input);
4820+
4821+ BN_DEPRECATED("Use SimplifyDemangledTemplateName")
4822+ QualifiedName SimplifyToQualifiedName(const std::string& input, bool simplify);
4823+
4824+ BN_DEPRECATED("Use SimplifyDemangledTemplateName")
4825+ QualifiedName SimplifyToQualifiedName(const QualifiedName& input);
4826+
47894827 /*!
47904828
47914829 \ingroup namelist
@@ -22506,16 +22544,6 @@ namespace BinaryNinja {
2250622544 */
2250722545 static bool Promote(const Ref<Demangler>& demangler);
2250822546
22509- /*!
22510- Attempt to demangle a mangled name, trying all relevant demanglers and using whichever one accepts it.
22511-
22512- \param[in] mangledName Raw mangled name
22513- \param[in] config Platform/view/options used while demangling
22514- \return Demangled type/name if successful
22515- */
22516- static std::optional<Result> DemangleAny(
22517- const std::string& mangledName, const Config& config = DemanglerConfig::Default());
22518-
2251922547 std::string GetName() const;
2252022548
2252122549 /*! Determine if a given name is mangled and this demangler can process it
@@ -22531,6 +22559,16 @@ namespace BinaryNinja {
2253122559 */
2253222560 virtual bool IsMangledString(const std::string& mangledName) = 0;
2253322561
22562+ /*!
22563+ Attempt to demangle a mangled name, trying all relevant demanglers and using whichever one accepts it.
22564+
22565+ \param[in] mangledName Raw mangled name
22566+ \param[in] config Platform/view/options used while demangling
22567+ \return Demangled type/name if successful
22568+ */
22569+ static std::optional<Result> DemangleAny(
22570+ const std::string& mangledName, const Config& config = DemanglerConfig::Default());
22571+
2253422572 /*! Demangle a raw name into a Type and QualifiedName.
2253522573
2253622574 The most recently registered demangler that claims a name is a mangled string
0 commit comments