Skip to content

Commit 14cede3

Browse files
author
drswinghead
committed
start clang 3.7 support
Fix llvm::Module::getDataLayout() return value changed to reference. Fix clang::CodeGen lots change. Fix clang::ASTUnit load change. Fix llvm::Object::SymbolRef getName and getCommonSize change. Fix Seme.h contains emit method conflict with Qt emit keyword. compiled clang 3.7 support.
1 parent 1162aa8 commit 14cede3

9 files changed

+115
-60
lines changed

Diff for: CMakeLists.txt

+7-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ string(REPLACE "-std=gnu++11" "-std=c++17 -std=c++1z" NEW_FLAGS ${CMAKE_CXX_FLAG
4444
string(REPLACE "-std=c++11" "-std=c++17 -std=c++1z" NEW_FLAGS ${CMAKE_CXX_FLAGS})
4545
set(CMAKE_CXX_FLAGS "${NEW_FLAGS}")
4646

47-
set(LLVM_SRC_DIR2 "./llvm-3.6.0.src") # maybe a symlink
47+
# set(LLVM_SRC_DIR2 "./llvm-3.5.0.src") # maybe a symlink
48+
# set(LLVM_SRC_DIR2 "./llvm-3.6.0.src") # maybe a symlink
49+
# set(LLVM_SRC_DIR2 "./llvm-3.6.2.src") # maybe a symlink
50+
set(LLVM_SRC_DIR2 "./llvm-3.7.0.src") # maybe a symlink
4851
set(CLANG_SRC_DIR2 ${LLVM_SRC_DIR2}/tools/clang)
4952
include_directories(${CLANG_SRC_DIR2}/lib/CodeGen ${CLANG_SRC_DIR2}/lib/ ${LLVM_SRC_DIR2}/lib/)
5053

@@ -98,7 +101,8 @@ set(handby_exe_SRCS
98101
block.cpp
99102
)
100103

101-
set(CLANGLIBS -lclang -lLLVM-3.6
104+
# set(CLANGLIBS -lclang -lLLVM-3.6
105+
set(CLANGLIBS -lclang
102106
-lclangTooling
103107
-lclangFrontendTool
104108
-lclangFrontend
@@ -141,4 +145,4 @@ qt5_use_modules(handby Core Gui Widgets Network WebSockets)
141145
# add_subdirectory(demos)
142146
#add_subdirectory(uitools/rcc)
143147
add_subdirectory(uitools/rbuic)
144-
add_subdirectory(uitools/rbrcc)
148+
add_subdirectory(uitools/rbrcc)

Diff for: ChangeLog

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,43 @@
1+
2015-10
2+
llvm-3.6 => llvm-3.7, qt5.5。注意编译器与内嵌入的llvm-src版本要相同。
3+
1。llvm::Module->getDataLayout() 从返回指针,改为返回引用了,不能再qDebug()直接输出
4+
2。变化最大的看来是clang::CodeGen这部分,大面积编译不过。
5+
CodeGenModule构造方法,添加了两个参数,clang::HeaderSearchOptions&和clang::PreprocessorOptions&。
6+
看能不能采用默认构造方法构造这两个参数。
7+
clang::CreateLLVMCodeGen()添加了两个参数,clang::HeaderSearchOptions&和clang::PreprocessorOptions&,
8+
并去掉了一个参数clang::TargetOptions&。
9+
3。clang::CodeGenerator去掉了一个参数,bool DefinitionRequired。
10+
4。clang::EmitBackendOutput改了一个参数类型,llvm::raw_string_ostream * => llvm::raw_pwrite_stream *。
11+
需要添加一层,llvm::buffer_ostream bufstm(llvm::raw_string_ostream&);
12+
5。clang::FunctionDecl去掉了个方法,getCorrespondingUnsizedGlobalDeallocationFunction
13+
这个在llvm-3.7.0去掉了。
14+
这段代码直接去掉,没见到替代方法。
15+
6。clang::ASTUnit::LoadFromASTFile方法改变,添加了一个参数PCHContainerReader&。
16+
这个参数需要手动构造还是怎么初始化呢?反正默认构造不行,这是个抽像类。
17+
需要从CompilerInstance取出来,CI.getPCHContainerReader()。
18+
正好FrontEngine已经构造了默认的CompilerInstance对象可以使用。
19+
7。clang::ASTUnit::LoadFromCompilerInvocation两个参数全部改了。
20+
8。llvm::object::SymbolRef的getName()方法去掉了参数,直接返回。
21+
getSize方法改为getCommonSize方法,直接返回。
22+
9。<clang/Sema/Sema.h>定义了个emit,与Qt的emit冲突了。
23+
这个可不容易解决了。
24+
临时把/usr/include/clang/Sema/Sema.h中的emit改名emit1,能编译过去,结果啥样不知道。
25+
不过代码中应该并未真正使用到这个Sema中的emit函数。
26+
27+
总的来说,改动不算太大。运行测试再看效果。
28+
29+
2015-5
30+
优化JIT引擎。
31+
llvm::Module拆分优化。
32+
133
2015-3
234
优化IR生成引擎中的ast遍历。
335
升级到依赖llvm-3.6库。
4-
36+
537
2014-11
638
直接存储ruby VALUE类型作为hash的key值,不再使用rb_hash计算一次。
739
实现诸如qApp的Qt全局变量getter/setter。
840

941
2014-10
1042
基本的jit执行。
11-
43+

Diff for: compilerengine.cpp

+39-32
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ void test_raw_codegen()
4949
clang::CodeGenOptions &cgopt = ci.getCodeGenOpts();
5050

5151
llvm::DataLayout dlo("hehhe");
52-
clang::CodeGen::CodeGenModule cgmod(astctx, cgopt, mod, dlo, diag);
52+
// clang::CodeGen::CodeGenModule cgmod(astctx, cgopt, mod, dlo, diag);
5353

54-
cgmod.EmitAnnotationString("hhhh");
54+
// cgmod.EmitAnnotationString("hhhh");
5555

56-
clang::CodeGen::CodeGenFunction cgf(cgmod);
56+
// clang::CodeGen::CodeGenFunction cgf(cgmod);
5757
}
5858

5959

@@ -697,7 +697,9 @@ llvm::Module* CompilerEngine::conv_ctor(clang::ASTContext &ctx, clang::CXXConstr
697697

698698
// llvm::DataLayout dlo("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
699699
llvm::DataLayout dlo(ctx.getTargetInfo().getTargetDescription());
700-
clang::CodeGen::CodeGenModule cgmod(ctx, cgopt, *mod, dlo, diag);
700+
clang::HeaderSearchOptions headersearchopts;
701+
clang::PreprocessorOptions ppopts;
702+
clang::CodeGen::CodeGenModule cgmod(ctx, headersearchopts, ppopts, cgopt, *mod, dlo, diag);
701703
auto &cgtypes = cgmod.getTypes();
702704
auto cgf = new clang::CodeGen::CodeGenFunction(cgmod);
703705

@@ -804,7 +806,9 @@ llvm::Module* CompilerEngine::conv_method(clang::ASTContext &ctx, clang::CXXMeth
804806

805807
// llvm::DataLayout dlo("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
806808
llvm::DataLayout dlo(ctx.getTargetInfo().getTargetDescription());
807-
clang::CodeGen::CodeGenModule cgmod(ctx, cgopt, *mod, dlo, diag);
809+
clang::HeaderSearchOptions headersearchopts;
810+
clang::PreprocessorOptions ppopts;
811+
clang::CodeGen::CodeGenModule cgmod(ctx, headersearchopts, ppopts, cgopt, *mod, dlo, diag);
808812
auto &cgtypes = cgmod.getTypes();
809813
auto cgf = new clang::CodeGen::CodeGenFunction(cgmod);
810814

@@ -926,7 +930,9 @@ QString CompilerEngine::mangle_ctor(clang::ASTContext &ctx, clang::CXXConstructo
926930

927931
// llvm::DataLayout dlo("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
928932
llvm::DataLayout dlo(ctx.getTargetInfo().getTargetDescription());
929-
clang::CodeGen::CodeGenModule cgmod(ctx, cgopt, *mod, dlo, diag);
933+
clang::HeaderSearchOptions headersearchopts;
934+
clang::PreprocessorOptions ppopts;
935+
clang::CodeGen::CodeGenModule cgmod(ctx, headersearchopts, ppopts, cgopt, *mod, dlo, diag);
930936
auto &cgtypes = cgmod.getTypes();
931937
auto cgf = new clang::CodeGen::CodeGenFunction(cgmod);
932938

@@ -952,7 +958,9 @@ QString CompilerEngine::mangle_dtor(clang::ASTContext &ctx, clang::CXXDestructor
952958

953959
// llvm::DataLayout dlo("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
954960
llvm::DataLayout dlo(ctx.getTargetInfo().getTargetDescription());
955-
clang::CodeGen::CodeGenModule cgmod(ctx, cgopt, *mod, dlo, diag);
961+
clang::HeaderSearchOptions headersearchopts;
962+
clang::PreprocessorOptions ppopts;
963+
clang::CodeGen::CodeGenModule cgmod(ctx, headersearchopts, ppopts, cgopt, *mod, dlo, diag);
956964
auto &cgtypes = cgmod.getTypes();
957965
auto cgf = new clang::CodeGen::CodeGenFunction(cgmod);
958966

@@ -978,7 +986,9 @@ QString CompilerEngine::mangle_method(clang::ASTContext &ctx, clang::CXXMethodDe
978986

979987
// llvm::DataLayout dlo("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
980988
llvm::DataLayout dlo(ctx.getTargetInfo().getTargetDescription());
981-
clang::CodeGen::CodeGenModule cgmod(ctx, cgopt, *mod, dlo, diag);
989+
clang::HeaderSearchOptions headersearchopts;
990+
clang::PreprocessorOptions ppopts;
991+
clang::CodeGen::CodeGenModule cgmod(ctx, headersearchopts, ppopts, cgopt, *mod, dlo, diag);
982992
auto &cgtypes = cgmod.getTypes();
983993
auto cgf = new clang::CodeGen::CodeGenFunction(cgmod);
984994

@@ -2059,7 +2069,10 @@ CompilerEngine::createCompilerUnit(clang::ASTUnit *unit, clang::NamedDecl *decl)
20592069
// llvm::DataLayout dlo("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
20602070
llvm::DataLayout *pdlo = new llvm::DataLayout(ctx.getTargetInfo().getTargetDescription());
20612071
auto &dlo = *pdlo;
2062-
cu->mcgm = new clang::CodeGen::CodeGenModule(ctx, cgopt, *cu->mmod, dlo, diag);
2072+
clang::HeaderSearchOptions headersearchopts;
2073+
clang::PreprocessorOptions ppopts;
2074+
cu->mcgm = new clang::CodeGen::CodeGenModule(ctx, headersearchopts, ppopts, cgopt, *cu->mmod, dlo, diag);
2075+
// cu->mcgm = new clang::CodeGen::CodeGenModule(ctx, cgopt, *cu->mmod, dlo, diag);
20632076
cu->mcgf = new clang::CodeGen::CodeGenFunction(*cu->mcgm);
20642077

20652078
//
@@ -2127,13 +2140,16 @@ bool CompilerEngine::tryCompile(clang::CXXRecordDecl *decl, clang::ASTContext &c
21272140

21282141
clang::ExternalASTSource *eas = ctx.getExternalSource();
21292142

2130-
clang::CodeGenerator *cgtor = clang::CreateLLVMCodeGen(diag, "testmm", cgopt, tgopt, vmctx);
2143+
clang::HeaderSearchOptions HeaderSearchOpts;
2144+
clang::PreprocessorOptions PreprocessorOpts;
2145+
clang::CodeGenerator *cgtor =
2146+
clang::CreateLLVMCodeGen(diag, "testmm", HeaderSearchOpts, PreprocessorOpts, cgopt, vmctx);
21312147
qDebug()<<cgtor<<eas;
21322148

21332149

21342150
cgtor->Initialize(ctx);
21352151
cgtor->HandleTranslationUnit(ctx);
2136-
cgtor->HandleVTable(decl, true);
2152+
cgtor->HandleVTable(decl);
21372153
cgtor->HandleTagDeclDefinition(decl);
21382154

21392155
int cnter = 0;
@@ -2159,7 +2175,9 @@ bool CompilerEngine::tryCompile(clang::CXXRecordDecl *decl, clang::ASTContext &c
21592175

21602176
std::string stmc;
21612177
llvm::raw_string_ostream stmo(stmc);
2162-
clang::EmitBackendOutput(diag, cgopt, tgopt, lgopt, "thisok", mod, clang::Backend_EmitLL, &stmo);
2178+
llvm::buffer_ostream bufstm(stmo);
2179+
// clang::EmitBackendOutput(diag, cgopt, tgopt, lgopt, "thisok", mod, clang::Backend_EmitLL, &stmo);
2180+
clang::EmitBackendOutput(diag, cgopt, tgopt, lgopt, "thisok", mod, clang::Backend_EmitLL, &bufstm);
21632181
/*
21642182
void EmitBackendOutput(DiagnosticsEngine &Diags, const CodeGenOptions &CGOpts,
21652183
const TargetOptions &TOpts, const LangOptions &LOpts,
@@ -2322,7 +2340,9 @@ bool CompilerEngine::tryCompile2(clang::CXXRecordDecl *decl, clang::ASTContext &
23222340
// llvm::DataLayout dlo("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
23232341
llvm::DataLayout dlo(ctx.getTargetInfo().getTargetDescription());
23242342
qDebug()<<"heeeeee...";
2325-
clang::CodeGen::CodeGenModule cgmod(ctx, cgopt, mod, dlo, diag);
2343+
clang::HeaderSearchOptions headersearchopts;
2344+
clang::PreprocessorOptions ppopts;
2345+
clang::CodeGen::CodeGenModule cgmod(ctx, headersearchopts, ppopts, cgopt, mod, dlo, diag);
23262346

23272347
// cgmod.EmitAnnotationString("hhhh");
23282348

@@ -2619,13 +2639,6 @@ void testGenerateCode(clang::CodeGen::CodeGenModule &CGM, clang::GlobalDecl GD,
26192639
// Emit the standard function prologue.
26202640
// StartFunction(GD, ResTy, Fn, FnInfo, Args, Loc, BodyRange.getBegin());
26212641

2622-
FunctionDecl *UnsizedDealloc =
2623-
FD->getCorrespondingUnsizedGlobalDeallocationFunction();
2624-
bool ok = (UnsizedDealloc != NULL);
2625-
qDebug()<<UnsizedDealloc<<ok;
2626-
if (UnsizedDealloc) {
2627-
qDebug()<<"error match if";
2628-
}
26292642
// Generate the body of the function.
26302643
// PGO.assignRegionCounters(GD.getDecl(), CurFn);
26312644
if (isa<CXXDestructorDecl>(FD)) {
@@ -2664,13 +2677,6 @@ void testGenerateCode(clang::CodeGen::CodeGenModule &CGM, clang::GlobalDecl GD,
26642677
// EmitFunctionBody(Args, Body);
26652678
qDebug()<<"hhhhhhhhhhh";
26662679
// } else if (UnsizedDealloc != NULL) {
2667-
} else if (FunctionDecl *UnsizedDealloc =
2668-
FD->getCorrespondingUnsizedGlobalDeallocationFunction()) {
2669-
// Global sized deallocation functions get an implicit weak definition if
2670-
// they don't have an explicit definition.
2671-
// EmitSizedDeallocationFunction(*this, UnsizedDealloc);
2672-
// EmitSizedDeallocationFunction(CGM, UnsizedDealloc);
2673-
qDebug()<<"why hereeeeeeeeee"<<UnsizedDealloc<<(UnsizedDealloc != NULL);
26742680
} else {
26752681
qDebug()<<"hhhhhhhhhhh";
26762682
llvm_unreachable("no definition for emitted function");
@@ -2763,13 +2769,14 @@ bool CompilerEngine::tryCompile_tpl(clang::ClassTemplateDecl *decl, clang::ASTCo
27632769

27642770
// llvm::DataLayout dlo("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
27652771
llvm::DataLayout dlo(ctx.getTargetInfo().getTargetDescription());
2766-
2767-
clang::CodeGen::CodeGenModule cgmod(ctx, cgopt, mod, dlo, diag);
2772+
clang::HeaderSearchOptions HeaderSearchOpts;
2773+
clang::PreprocessorOptions PreprocessorOpts;
2774+
clang::CodeGen::CodeGenModule cgmod(ctx, HeaderSearchOpts, PreprocessorOpts, cgopt, mod, dlo, diag);
27682775

27692776
qDebug()<<"heeeeee...";
27702777
clang::CodeGen::CodeGenFunction cgf(cgmod, false);
27712778

2772-
qDebug()<<cgmod.getMangledName(mthdecl).data();
2779+
// qDebug()<<cgmod.getMangledName(mthdecl).data();
27732780
auto mgctx = ctx.createMangleContext();
27742781
std::string stms;
27752782
llvm::raw_string_ostream stmo(stms);
@@ -2823,7 +2830,7 @@ bool CompilerEngine::tryCompile_tpl(clang::ClassTemplateDecl *decl, clang::ASTCo
28232830
qDebug()<<cnter++<<sd;
28242831
int jcnter = 0;
28252832
auto &al = sd->getTemplateArgs();
2826-
for (int j = 0; j < al.size(); j++) {
2833+
for (unsigned int j = 0; j < al.size(); j++) {
28272834
qDebug()<<jcnter++<<al.get(j).getAsType().getAsString().data();
28282835
QString tplat = al.get(j).getAsType().getAsString().data();
28292836
if (tplat == "char") {
@@ -2897,7 +2904,7 @@ bool CompilerEngine::tryCompile_tpl(clang::ClassTemplateDecl *decl, clang::ASTCo
28972904
// Ty = getTypes().ConvertType(cast<ValueDecl>(GD.getDecl())->getType());
28982905
// cgtypes.ConvertType(clang::cast<clang::ValueDecl>(td)->getType());
28992906
qDebug()<<cgm.getMangledName(clang::GlobalDecl(td)).data();
2900-
qDebug()<<td<<td->getCorrespondingUnsizedGlobalDeallocationFunction()
2907+
qDebug()<<td // <<td->getCorrespondingUnsizedGlobalDeallocationFunction()
29012908
<<td->isLambdaStaticInvoker()<<td->isInstance(); // 0x12345, 0x0, false
29022909
cgf.GenerateCode(td, f, FI);
29032910
// testGenerateCode(cgm, clang::GlobalDecl(td), f, FI);

Diff for: ctrlengine.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void *CtrlEngine::vm_new(QString klass, QVector<QVariant> uargs)
7272
} else {
7373
// auto mod = mce->conv_ctor(mfe->getASTContext(), ctor_decl);
7474
auto tmod = mce->conv_ctor2(mfe->getASTUnit(), ctor_decl, dargs);
75-
qDebug()<<tmod<<tmod->getDataLayout();
75+
qDebug()<<tmod<<&tmod->getDataLayout();
7676
TEMP_DEBUG();
7777
qtmod = tmod;
7878

@@ -204,7 +204,7 @@ bool CtrlEngine::vm_delete(void *kthis, QString klass)
204204
qtmod = mman->get(modname);
205205
} else {
206206
auto mod = mce->conv_dtor(mfe->getASTUnit(), dtor_decl);
207-
qDebug()<<mod<<mod->getDataLayout();
207+
qDebug()<<mod<<&mod->getDataLayout();
208208
// mod->dump();
209209
qtmod = mod;
210210

@@ -396,7 +396,7 @@ QVariant CtrlEngine::vm_call(void *kthis, QString klass, QString method, QVector
396396
} else {
397397
// auto mod = mce->conv_method(mfe->getASTContext(), mth_decl);
398398
auto mod = mce->conv_method2(mfe->getASTUnit(), mth_decl);
399-
qDebug()<<mod<<mod->getDataLayout();
399+
qDebug()<<mod<<&mod->getDataLayout();
400400
qtmod = mod;
401401

402402
// mce->conv_ctor(mfe->getASTContext(), ctor_decl);
@@ -478,7 +478,7 @@ QVariant CtrlEngine::vm_static_call(QString klass, QString method, QVector<QVari
478478
} else {
479479
// auto mod = mce->conv_method(mfe->getASTContext(), mth_decl);
480480
auto mod = mce->conv_method2(mfe->getASTUnit(), mth_decl);
481-
qDebug()<<mod<<mod->getDataLayout();
481+
qDebug()<<mod<<&mod->getDataLayout();
482482
// mce->conv_ctor(mfe->getASTContext(), ctor_decl);
483483
qtmod = mod;
484484
}
@@ -566,7 +566,7 @@ QString CtrlEngine::vm_qdebug(void *kthis, QString klass)
566566
qtmod = mman->get(modname);
567567
} else {
568568
auto mod = mce->conv_function2(mfe->getASTUnit(), fun_decl);
569-
qDebug()<<mod<<mod->getDataLayout();
569+
qDebug()<<mod<<&mod->getDataLayout();
570570
qtmod = mod;
571571
// mce->conv_ctor(mfe->getASTContext(), ctor_decl);
572572
// QString symname = mce->mangle_method(mfe->getASTContext(), mth_decl);

Diff for: frontengine.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,20 @@ bool FrontEngine::loadPreparedASTFile()
138138
clang::IntrusiveRefCntPtr<clang::DiagnosticsEngine> mydiag
139139
= clang::CompilerInstance::createDiagnostics(new clang::DiagnosticOptions(), Client, true);
140140
clang::FileSystemOptions fsopts;
141+
const clang::PCHContainerReader &pchreader = this->mcis->getPCHContainerReader();
141142

142143
QDateTime btime = QDateTime::currentDateTime();
143144
std::unique_ptr<clang::ASTUnit> unit
144-
= clang::ASTUnit::LoadFromASTFile(astfile, mydiag, fsopts, false, clang::None, true, true, true);
145+
= clang::ASTUnit::LoadFromASTFile(astfile, pchreader, mydiag, fsopts, false, clang::None, true, true, true);
145146
// false, clang::None,
146147
// true, true, true);
148+
// std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
149+
// const std::string &Filename,
150+
// const PCHContainerReader &PCHContainerRdr,
151+
// IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
152+
// const FileSystemOptions &FileSystemOpts, bool OnlyLocalDecls,
153+
// ArrayRef<RemappedFile> RemappedFiles, bool CaptureDiagnostics,
154+
// bool AllowPCHWithCompilerErrors, bool UserFilesAreVolatile) {
147155
// clang::ASTUnit::LoadFromASTFile(const std::string &Filename,
148156
// IntrusiveRefCntPtr<clang::DiagnosticsEngine> Diags,
149157
// const clang::FileSystemOptions &FileSystemOpts,
@@ -237,9 +245,10 @@ bool FrontEngine::parseHeader()
237245
std::string astfile = "data/qthdrsrc.ast";
238246
clang::IntrusiveRefCntPtr<clang::DiagnosticsEngine> mydiag;
239247
clang::FileSystemOptions fsopts;
248+
const clang::PCHContainerReader &pchreader = this->mcis->getPCHContainerReader();
240249

241250
QDateTime btime = QDateTime::currentDateTime();
242-
std::unique_ptr<clang::ASTUnit> unit = clang::ASTUnit::LoadFromASTFile(astfile, mydiag, fsopts);
251+
std::unique_ptr<clang::ASTUnit> unit = clang::ASTUnit::LoadFromASTFile(astfile, pchreader, mydiag, fsopts);
243252
// clang::ASTUnit::LoadFromASTFile(const std::string &Filename,
244253
// IntrusiveRefCntPtr<clang::DiagnosticsEngine> Diags,
245254
// const clang::FileSystemOptions &FileSystemOpts,
@@ -321,8 +330,12 @@ bool FrontEngine::parseHeader(QString path)
321330
QDateTime btime = QDateTime::currentDateTime();
322331
clang::IntrusiveRefCntPtr<clang::DiagnosticsEngine> mydiag;
323332
// clang::CompilerInstance::createDiagnostics(mcis->
324-
std::unique_ptr<clang::ASTUnit> pastu =
325-
clang::ASTUnit::LoadFromCompilerInvocation(mciv, mydiag);
333+
std::shared_ptr<clang::PCHContainerOperations> PCHContainerOps = this->mcis->getPCHContainerOperations();
334+
335+
std::unique_ptr<clang::ASTUnit> pastu =
336+
clang::ASTUnit::LoadFromCompilerInvocation(mciv, PCHContainerOps, mydiag, false, true,
337+
true, clang::TU_Complete, true, true, true);
338+
// clang::ASTUnit::LoadFromCompilerInvocation(mciv, mydiag);
326339
clang::ASTContext &tctx = pastu->getASTContext();
327340
QDateTime etime = QDateTime::currentDateTime();
328341

@@ -1047,7 +1060,7 @@ FrontEngine::find_ctor_decl(clang::CXXRecordDecl *decl,
10471060
// else ctors.count() == 1
10481061

10491062
clang::CXXConstructorDecl *ctor = ctors.at(0);
1050-
Q_ASSERT(md);
1063+
Q_ASSERT(ctor);
10511064
return ctor;
10521065
}
10531066

Diff for: ivm/clvmjitlistener.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ static void dumpObjectFile(const llvm::object::ObjectFile &Obj)
2323
qDebug()<<Obj.getType()<<(llvm::isa<llvm::object::ELFObjectFileBase>(pObj));
2424
// <<(llvm::isa<llvm::object::ELFObjectFile<???> >(pObj));
2525

26-
for (auto sym : Obj.symbols()) {
26+
for (llvm::object::SymbolRef sym : Obj.symbols()) {
2727
std::string name;
28-
llvm::StringRef rname(name);
29-
uint64_t sz = 0;
30-
sym.getName(rname);
31-
sym.getSize(sz);
32-
// qDebug()<<"sym:"<<&sym<<sz<<rname.str().c_str();
28+
// llvm::StringRef rname(name);
29+
llvm::ErrorOr<llvm::StringRef> rname = sym.getName();
30+
// sym.getSize(sz);
31+
uint64_t sz = sym.getCommonSize();
32+
qDebug()<<"sym:"<<&sym<<sz<<rname->str().c_str();
3333
}
3434

3535
for (auto sec : Obj.sections()) {

Diff for: namelookup.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <clang/AST/ASTContext.h>
55
#include <clang/AST/Decl.h>
66
#include <clang/AST/DeclCXX.h>
7+
// 需要把Sema.h中的emit()函数改名,否则会与Qt中的emit冲突。
78
#include <clang/Sema/Sema.h>
89
#include <clang/Sema/Lookup.h>
910
#include <clang/Frontend/ASTUnit.h>

0 commit comments

Comments
 (0)