Skip to content

Commit

Permalink
Merge branch 'master' into borland_ast_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
xvenge00 committed Mar 10, 2019
2 parents f2d00a6 + 6edcaae commit 0208422
Show file tree
Hide file tree
Showing 70 changed files with 262 additions and 26,126 deletions.
16 changes: 0 additions & 16 deletions include/llvm/Demangle/demangler.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/retdec/bin2llvmir/providers/debugformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DebugFormatProvider
retdec::loader::Image* objf,
const std::string& pdbFile,
const retdec::utils::Address& imageBase,
retdec::demangler::CDemangler* demangler);
retdec::demangler::Demangler* demangler);

static DebugFormat* getDebugFormat(llvm::Module* m);
static bool getDebugFormat(llvm::Module* m, DebugFormat*& df);
Expand Down
8 changes: 4 additions & 4 deletions include/retdec/bin2llvmir/providers/demangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ namespace bin2llvmir {
class DemanglerProvider
{
public:
static retdec::demangler::CDemangler* addDemangler(
static retdec::demangler::Demangler* addDemangler(
llvm::Module* m,
const retdec::config::ToolInfoContainer& t);

static retdec::demangler::CDemangler* getDemangler(llvm::Module* m);
static retdec::demangler::Demangler* getDemangler(llvm::Module* m);
static bool getDemangler(
llvm::Module* m,
retdec::demangler::CDemangler*& d);
retdec::demangler::Demangler*& d);

static void clear();

private:
using Demangler = std::unique_ptr<retdec::demangler::CDemangler>;
using Demangler = std::unique_ptr<retdec::demangler::Demangler>;
/// Mapping of modules to demanglers associated with them.
static std::map<llvm::Module*, Demangler> _module2demangler;
};
Expand Down
4 changes: 2 additions & 2 deletions include/retdec/bin2llvmir/providers/names.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class NameContainer
Config* c,
DebugFormat* d,
FileImage* i,
demangler::CDemangler* dm,
demangler::Demangler* dm,
Lti* lti = nullptr);

bool addNameForAddress(
Expand Down Expand Up @@ -199,7 +199,7 @@ class NamesProvider
Config* c,
DebugFormat* d,
FileImage* i,
demangler::CDemangler* dm,
demangler::Demangler* dm,
Lti* lti);
static NameContainer* getNames(llvm::Module* m);
static bool getNames(llvm::Module* m, NameContainer*& names);
Expand Down
18 changes: 9 additions & 9 deletions include/retdec/ctypesparser/borland_ast_ctypes_parser.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef RETDEC_BORLAND_AST_CTYPES_PARSER_H
#define RETDEC_BORLAND_AST_CTYPES_PARSER_H

#include "llvm/Demangle/borland_ast.h"
#include "llvm/Demangle/borland_ast_types.h"
#include "retdec/demangler/borland_ast.h"
#include "retdec/demangler/borland_ast_types.h"
#include "retdec/ctypes/module.h"
#include "retdec/ctypes/context.h"
#include "retdec/ctypes/function.h"
Expand Down Expand Up @@ -37,13 +37,13 @@ class BorlandToCtypesParser
private:
std::shared_ptr<ctypes::Function> parseFunction(std::shared_ptr<demangler::borland::FunctionNode> function);
std::shared_ptr<ctypes::Type> parseType(std::shared_ptr<demangler::borland::TypeNode> typeNode);
std::shared_ptr<ctypes::IntegralType> parseIntegralType(std::shared_ptr<demangler::borland::IntegralTypeNode> integralNode);
std::shared_ptr<ctypes::FloatingPointType> parseFloatingPointType(std::shared_ptr<demangler::borland::FloatTypeNode> floatNode);
std::shared_ptr<ctypes::IntegralType> parseCharType(std::shared_ptr<demangler::borland::CharTypeNode> charNode);
std::shared_ptr<ctypes::Type> parseBuiltInType(std::shared_ptr<demangler::borland::BuiltInTypeNode> typeNode);
std::shared_ptr<ctypes::PointerType> parsePointerType(std::shared_ptr<demangler::borland::PointerTypeNode> pointerNode);
std::shared_ptr<ctypes::Type> parseReferenceType(std::shared_ptr<demangler::borland::ReferenceTypeNode> referenceNode);
std::shared_ptr<ctypes::Type> parseRReferenceType(std::shared_ptr<demangler::borland::RReferenceTypeNode> referenceNode);
// std::shared_ptr<ctypes::IntegralType> parseIntegralType(std::shared_ptr<demangler::borland::IntegralTypeNode> integralNode);
// std::shared_ptr<ctypes::FloatingPointType> parseFloatingPointType(std::shared_ptr<demangler::borland::FloatTypeNode> floatNode);
// std::shared_ptr<ctypes::IntegralType> parseCharType(std::shared_ptr<demangler::borland::CharTypeNode> charNode);
// std::shared_ptr<ctypes::Type> parseBuiltInType(std::shared_ptr<demangler::borland::BuiltInTypeNode> typeNode);
// std::shared_ptr<ctypes::PointerType> parsePointerType(std::shared_ptr<demangler::borland::PointerTypeNode> pointerNode);
// std::shared_ptr<ctypes::Type> parseReferenceType(std::shared_ptr<demangler::borland::ReferenceTypeNode> referenceNode);
// std::shared_ptr<ctypes::Type> parseRReferenceType(std::shared_ptr<demangler::borland::RReferenceTypeNode> referenceNode);
ctypes::Function::Parameters parseFuncParameters(std::shared_ptr<demangler::borland::NodeArray> paramsNode);
ctypes::CallConvention parseCallConvention(demangler::borland::CallConv callConv);
ctypes::FunctionType::VarArgness parseVarArgness(bool isVarArg);
Expand Down
4 changes: 2 additions & 2 deletions include/retdec/debugformat/debugformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DebugFormat
retdec::loader::Image* inFile,
const std::string& pdbFile,
SymbolTable* symtab,
retdec::demangler::CDemangler* demangler,
retdec::demangler::Demangler* demangler,
unsigned long long imageBase = 0);

retdec::config::Function* getFunction(retdec::utils::Address a);
Expand Down Expand Up @@ -69,7 +69,7 @@ class DebugFormat
/// Underlying DWARF representation.
retdec::dwarfparser::DwarfFile* _dwarfFile = nullptr;
/// Demangler.
retdec::demangler::CDemangler* _demangler = nullptr;
retdec::demangler::Demangler* _demangler = nullptr;

public:
retdec::config::GlobalVarContainer globals;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file include/llvm/Demangle/borland_ast.h
* @file include/retdec/demangler/borland_ast.h
* @brief Representation of syntactic tree for borland demangler.
* @copyright (c) 2018 Avast Software, licensed under the MIT license
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* @file include/llvm/Demangle/borland_ast_parser.h
* @file include/retdec/demangler/borland_ast_parser.h
* @brief Parser of mangled names into tree for borland demangler.
* @copyright (c) 2018 Avast Software, licensed under the MIT license
*/

#ifndef RETDEC_BORLAND_AST_PARSER_H
#define RETDEC_BORLAND_AST_PARSER_H

#include "llvm/Demangle/borland_ast.h"
#include "llvm/Demangle/borland_ast_types.h"
#include "llvm/Demangle/context.h"

#include "llvm/Demangle/StringView.h"

#include "retdec/demangler/borland_ast.h"
#include "retdec/demangler/borland_ast_types.h"
#include "retdec/demangler/context.h"

namespace retdec {
namespace demangler {
namespace borland {
Expand Down Expand Up @@ -54,7 +54,6 @@ class BorlandASTParser
bool consumeIfPossible(const StringView &s);
bool consume(char c);
bool consume(const StringView &s);
static std::string getString(const StringView &s);

std::shared_ptr<Node> parseFunction();
std::shared_ptr<FunctionTypeNode> parseFuncType(Qualifiers &quals);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file include/llvm/Demangle/borland_ast_types.h
* @file include/retdec/demangler/borland_ast_types.h
* @brief Representation of types in demangler ast.
* @copyright (c) 2019 Avast Software, licensed under the MIT license
*/
Expand All @@ -11,7 +11,7 @@
#include <string>
#include <vector>

#include "llvm/Demangle/borland_ast.h"
#include "retdec/demangler/borland_ast.h"

namespace retdec {
namespace demangler {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/**
* @file include/llvm/Demangle/borland_demangler.h
* @file include/retdec/demangler/borland_demangler.h
* @brief Borland demangler adapter.
* @copyright (c) 2018 Avast Software, licensed under the MIT license
*/

#ifndef RETDEC_LLVM_BORLAND_DEMANGLER_H
#define RETDEC_LLVM_BORLAND_DEMANGLER_H

#include "llvm/Demangle/demangler_base.h"
#include "llvm/Demangle/context.h"
#include "llvm/Demangle/borland_ast_parser.h"
#include "retdec/demangler/demangler_base.h"
#include "retdec/demangler/borland_ast_parser.h"
#include "retdec/ctypes/context.h"

namespace retdec {
Expand All @@ -27,11 +26,6 @@ class BorlandDemangler : public Demangler

void demangleToModule(const std::string &mangled, retdec::ctypes::Module &module) override;

private:
static Status astStatusToDemStatus(const borland::BorlandASTParser::Status &parserStatus);

std::string astToString(const std::shared_ptr<borland::Node> &ast) const;

private:
borland::Context _demangleContext;
};
Expand Down
File renamed without changes.
53 changes: 11 additions & 42 deletions include/retdec/demangler/demangler.h
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
/**
* @file include/retdec/demangler/demangler.h
* @brief Demangler library.
* @copyright (c) 2017 Avast Software, licensed under the MIT license
* @file include/retdec/demangler/demangler_retdec.h
* @brief File to include for demangling work.
* @copyright (c) 2018 Avast Software, licensed under the MIT license
*/

#ifndef RETDEC_DEMANGLER_DEMANGLERL_H
#define RETDEC_DEMANGLER_DEMANGLERL_H
#ifndef RETDEC_DEMANGLER_H
#define RETDEC_DEMANGLER_H

#include <memory>
#include <string>
#include "retdec/demangler/demangler_base.h"
#include "retdec/demangler/itanium_demangler.h"
#include "retdec/demangler/microsoft_demangler.h"
#include "retdec/demangler/borland_demangler.h"
#include "retdec/demangler/demangler_factory.h"

#include "retdec/demangler/gparser.h"

namespace retdec {
namespace demangler {

/**
* The grammar parser class - the core of the demangler.
*/
class CDemangler {
cGram *pGram;
cName *pName;
std::string compiler = "gcc";
cGram::errcode errState; /// error state; 0 = everyting is ok

public:
CDemangler(std::string gname, bool i = true);
static std::unique_ptr<CDemangler> createGcc(bool i = true);
static std::unique_ptr<CDemangler> createMs(bool i = true);
static std::unique_ptr<CDemangler> createBorland(bool i = true);
virtual ~CDemangler();

bool isOk();
std::string printError();
void resetError();

void createGrammar(std::string inputfilename, std::string outputname);
cName *demangleToClass(std::string inputName);
std::string demangleToString(std::string inputName);
void setSubAnalyze(bool x);
};

} // namespace demangler
} // namespace retdec

#endif
#endif //RETDEC_DEMANGLER_H
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file include/llvm/Demangle/demangler_base.h
* @file include/retdec/demangler/demangler_base.h
* @brief Demangler library.
* @copyright (c) 2018 Avast Software, licensed under the MIT license
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file include/llvm/Demangle/demangler_retdec.h
* @file include/retdec/demangler/demangler_retdec.h
* @brief Demangler factory class. Should be included for demangling work.
* @copyright (c) 2018 Avast Software, licensed under the MIT license
*/
Expand All @@ -9,10 +9,10 @@

#include <memory>

#include "llvm/Demangle/demangler_base.h"
#include "llvm/Demangle/itanium_demangler.h"
#include "llvm/Demangle/microsoft_demangler.h"
#include "llvm/Demangle/borland_demangler.h"
#include "retdec/demangler/demangler_base.h"
#include "retdec/demangler/itanium_demangler.h"
#include "retdec/demangler/microsoft_demangler.h"
#include "retdec/demangler/borland_demangler.h"

namespace retdec {
namespace demangler {
Expand Down
22 changes: 0 additions & 22 deletions include/retdec/demangler/demglobal.h

This file was deleted.

36 changes: 0 additions & 36 deletions include/retdec/demangler/demtools.h

This file was deleted.

Loading

0 comments on commit 0208422

Please sign in to comment.