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. 3
      .gitignore
  2. 6
      build/LLVM.lua
  3. 7
      src/CppParser/Parser.cpp
  4. 11
      tests/Native/AST.h

3
.gitignore vendored

@ -46,4 +46,5 @@ src/generator/generator @@ -46,4 +46,5 @@ src/generator/generator
/deps/NUnit*
/extra
/site
/wip
/wip
/.vs

6
build/LLVM.lua

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

7
src/CppParser/Parser.cpp

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
#include <llvm/Support/Host.h>
#include <llvm/Support/Path.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/Object/Archive.h>
#include <llvm/Object/COFF.h>
#include <llvm/Object/ObjectFile.h>
@ -63,7 +64,7 @@ @@ -63,7 +64,7 @@
using namespace CppSharp::CppParser;
// 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) @@ -232,6 +233,10 @@ ConvertToClangTargetCXXABI(CppSharp::CppParser::AST::CppAbi abi)
void Parser::SetupHeader()
{
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmParsers();
using namespace clang;
std::vector<const char*> args;

11
tests/Native/AST.h

@ -208,3 +208,14 @@ template<> @@ -208,3 +208,14 @@ template<>
bool functionWithSpecInfo(const float& t11, const float& t12, const float& t2);
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