Browse Source

Updated to a recent LLVM and Clang revision.

pull/206/head
triton 11 years ago
parent
commit
fb70229e26
  1. 4
      docs/GettingStarted.md
  2. 30
      src/CppParser/Parser.cpp
  3. 22
      src/Parser/Parser.cpp

4
docs/GettingStarted.md

@ -25,12 +25,10 @@ Git repository urls found here: [http://llvm.org/docs/GettingStarted.html#git-mi
Building in *Release* is recommended because else the Clang parser will be Building in *Release* is recommended because else the Clang parser will be
excruciatingly slow. excruciatingly slow.
Last updated to LLVM/Clang revision: `r198449` Last updated to LLVM/Clang revision: `r202563`
## Compiling on Mac OS X (experimental) ## Compiling on Mac OS X (experimental)
Requirements: Clang revision >= 198625
1. Clone CppSharp to `<CppSharp>` 1. Clone CppSharp to `<CppSharp>`
2. Clone LLVM to `<CppSharp>\deps\llvm` 2. Clone LLVM to `<CppSharp>\deps\llvm`
3. Clone Clang to `<CppSharp>\deps\llvm\tools\clang` 3. Clone Clang to `<CppSharp>\deps\llvm\tools\clang`

30
src/CppParser/Parser.cpp

@ -8,6 +8,7 @@
#include "Parser.h" #include "Parser.h"
#include <llvm/Support/Path.h> #include <llvm/Support/Path.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Object/Archive.h> #include <llvm/Object/Archive.h>
#include <llvm/Object/ObjectFile.h> #include <llvm/Object/ObjectFile.h>
#include <llvm/IR/LLVMContext.h> #include <llvm/IR/LLVMContext.h>
@ -507,11 +508,10 @@ void Parser::WalkVTable(clang::CXXRecordDecl* RD, Class* C)
auto& VFPtrInfo = *I; auto& VFPtrInfo = *I;
VFTableInfo Info; VFTableInfo Info;
Info.VBTableIndex = VFPtrInfo.VBTableIndex; Info.VFPtrOffset = VFPtrInfo->NonVirtualOffset.getQuantity();
Info.VFPtrOffset = VFPtrInfo.VFPtrOffset.getQuantity(); Info.VFPtrFullOffset = VFPtrInfo->FullOffsetInMDC.getQuantity();
Info.VFPtrFullOffset = VFPtrInfo.VFPtrFullOffset.getQuantity();
auto& VTLayout = VTContext.getVFTableLayout(RD, VFPtrInfo.VFPtrFullOffset); auto& VTLayout = VTContext.getVFTableLayout(RD, VFPtrInfo->FullOffsetInMDC);
Info.Layout = WalkVTableLayout(VTLayout); Info.Layout = WalkVTableLayout(VTLayout);
C->Layout.VFTables.push_back(Info); C->Layout.VFTables.push_back(Info);
@ -2632,23 +2632,25 @@ ParserResultKind Parser::ParseSharedLib(llvm::StringRef File,
for(auto it = Object.get()->symbol_begin(); it != Object.get()->symbol_end(); for(auto it = Object.get()->symbol_begin(); it != Object.get()->symbol_end();
++it) ++it)
{ {
llvm::StringRef SymRef; std::string Sym;
llvm::raw_string_ostream SymStream(Sym);
if (it->getName(SymRef))
continue; if (it->printName(SymStream))
continue;
NativeLib->Symbols.push_back(SymRef); NativeLib->Symbols.push_back(Sym);
} }
for (auto it = Object.get()->symbol_begin(); it != Object.get()->symbol_end(); for (auto it = Object.get()->symbol_begin(); it != Object.get()->symbol_end();
++it) ++it)
{ {
llvm::StringRef SymRef; std::string Sym;
llvm::raw_string_ostream SymStream(Sym);
if (it->getName(SymRef))
continue; if (it->printName(SymStream))
continue;
NativeLib->Symbols.push_back(SymRef); NativeLib->Symbols.push_back(Sym);
} }
return ParserResultKind::Success; return ParserResultKind::Success;

22
src/Parser/Parser.cpp

@ -9,6 +9,7 @@
#include "Interop.h" #include "Interop.h"
#include <llvm/Support/Path.h> #include <llvm/Support/Path.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Object/Archive.h> #include <llvm/Object/Archive.h>
#include <llvm/Object/ObjectFile.h> #include <llvm/Object/ObjectFile.h>
#include <llvm/IR/LLVMContext.h> #include <llvm/IR/LLVMContext.h>
@ -508,11 +509,10 @@ void Parser::WalkVTable(clang::CXXRecordDecl* RD, CppSharp::AST::Class^ C)
auto& VFPtrInfo = *I; auto& VFPtrInfo = *I;
CppSharp::AST::VFTableInfo Info; CppSharp::AST::VFTableInfo Info;
Info.VBTableIndex = VFPtrInfo.VBTableIndex; Info.VFPtrOffset = VFPtrInfo->NonVirtualOffset.getQuantity();
Info.VFPtrOffset = VFPtrInfo.VFPtrOffset.getQuantity(); Info.VFPtrFullOffset = VFPtrInfo->FullOffsetInMDC.getQuantity();
Info.VFPtrFullOffset = VFPtrInfo.VFPtrFullOffset.getQuantity();
auto& VTLayout = VTContext.getVFTableLayout(RD, VFPtrInfo.VFPtrFullOffset); auto& VTLayout = VTContext.getVFTableLayout(RD, VFPtrInfo->FullOffsetInMDC);
Info.Layout = WalkVTableLayout(VTLayout); Info.Layout = WalkVTableLayout(VTLayout);
C->Layout->VFTables->Add(Info); C->Layout->VFTables->Add(Info);
@ -2644,24 +2644,26 @@ ParserResultKind Parser::ParseSharedLib(llvm::StringRef File,
for(auto it = Object.get()->symbol_begin(); it != Object.get()->symbol_end(); for(auto it = Object.get()->symbol_begin(); it != Object.get()->symbol_end();
++it) ++it)
{ {
llvm::StringRef SymRef; std::string Sym;
llvm::raw_string_ostream SymStream(Sym);
if (it->getName(SymRef)) if (it->printName(SymStream))
continue; continue;
System::String^ SymName = clix::marshalString<clix::E_UTF8>(SymRef); System::String^ SymName = clix::marshalString<clix::E_UTF8>(Sym);
NativeLib->Symbols->Add(SymName); NativeLib->Symbols->Add(SymName);
} }
for(auto it = Object.get()->symbol_begin(); it != Object.get()->symbol_end(); for(auto it = Object.get()->symbol_begin(); it != Object.get()->symbol_end();
++it) ++it)
{ {
llvm::StringRef SymRef; std::string Sym;
llvm::raw_string_ostream SymStream(Sym);
if (it->getName(SymRef)) if (it->printName(SymStream))
continue; continue;
System::String^ SymName = clix::marshalString<clix::E_UTF8>(SymRef); System::String^ SymName = clix::marshalString<clix::E_UTF8>(Sym);
NativeLib->Symbols->Add(SymName); NativeLib->Symbols->Add(SymName);
} }

Loading…
Cancel
Save