Browse Source

[parser] Added LLVM target initialization and supporting libraries for parsing inline assembly.

Fixes #923

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/935/head
DevSidious 8 years ago committed by Dimitar Dobrev
parent
commit
07ea284431
  1. 1
      .gitignore
  2. 6
      build/LLVM.lua
  3. 7
      src/CppParser/Parser.cpp
  4. 11
      tests/Native/AST.h

1
.gitignore vendored

@ -47,3 +47,4 @@ src/generator/generator
/extra /extra
/site /site
/wip /wip
/.vs

6
build/LLVM.lua

@ -151,12 +151,18 @@ function SetupLLVMLibs()
"LLVMX86Info", "LLVMX86Info",
"LLVMX86AsmPrinter", "LLVMX86AsmPrinter",
"LLVMX86Utils", "LLVMX86Utils",
"LLVMX86CodeGen",
"LLVMX86Disassembler",
"LLVMCodeGen", "LLVMCodeGen",
"LLVMSelectionDAG",
"LLVMGlobalISel",
"LLVMDebugInfoCodeView",
"LLVMScalarOpts", "LLVMScalarOpts",
"LLVMInstCombine", "LLVMInstCombine",
"LLVMTransformUtils", "LLVMTransformUtils",
"LLVMAnalysis", "LLVMAnalysis",
"LLVMTarget", "LLVMTarget",
"LLVMMCDisassembler",
"LLVMMC", "LLVMMC",
"LLVMCoverage", "LLVMCoverage",
"LLVMCore", "LLVMCore",

7
src/CppParser/Parser.cpp

@ -15,6 +15,7 @@
#include <llvm/Support/Host.h> #include <llvm/Support/Host.h>
#include <llvm/Support/Path.h> #include <llvm/Support/Path.h>
#include <llvm/Support/raw_ostream.h> #include <llvm/Support/raw_ostream.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/Object/Archive.h> #include <llvm/Object/Archive.h>
#include <llvm/Object/COFF.h> #include <llvm/Object/COFF.h>
#include <llvm/Object/ObjectFile.h> #include <llvm/Object/ObjectFile.h>
@ -63,7 +64,7 @@
using namespace CppSharp::CppParser; using namespace CppSharp::CppParser;
// We use this as a placeholder for pointer values that should be ignored. // We use this as a placeholder for pointer values that should be ignored.
void* IgnorePtr = (void*) 0x1; void* IgnorePtr = reinterpret_cast<void*>(0x1);
//-----------------------------------// //-----------------------------------//
@ -232,6 +233,10 @@ ConvertToClangTargetCXXABI(CppSharp::CppParser::AST::CppAbi abi)
void Parser::SetupHeader() void Parser::SetupHeader()
{ {
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmParsers();
using namespace clang; using namespace clang;
std::vector<const char*> args; std::vector<const char*> args;

11
tests/Native/AST.h

@ -208,3 +208,14 @@ template<>
bool functionWithSpecInfo(const float& t11, const float& t12, const float& t2); bool functionWithSpecInfo(const float& t11, const float& t12, const float& t2);
void functionWithSpecializationArg(const TestTemplateClass<int>); void functionWithSpecializationArg(const TestTemplateClass<int>);
void testInlineAssembly()
{
#ifdef _WIN32
#ifndef _WIN64
__asm mov eax, 1
#endif
#elif __linux__
asm("mov eax, 1");
#endif
}

Loading…
Cancel
Save