From efda1444166c8d4f8dd7d7b085868f1596b3b9fb Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Thu, 22 Sep 2016 01:03:57 -0600 Subject: more clang hack --- src/chill_ast.cc | 4 ++-- src/chillmodule.cc | 1 + src/ir_clang.cc | 13 ++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/chill_ast.cc b/src/chill_ast.cc index 93afd97..978e303 100644 --- a/src/chill_ast.cc +++ b/src/chill_ast.cc @@ -603,7 +603,7 @@ chillAST_TypedefDecl::chillAST_TypedefDecl() { }; -chillAST_TypedefDecl::chillAST_TypedefDecl(char *t, char *nt, chillAST_node *par) { +chillAST_TypedefDecl::chillAST_TypedefDecl(char *t, const char *nt, chillAST_node *par) { //fprintf(stderr, "chillAST_TypedefDecl::chillAST_TypedefDecl( underlying type %s, newtype %s )\n", t, nt); underlyingtype = strdup(t); newtype = strdup(nt); @@ -619,7 +619,7 @@ chillAST_TypedefDecl::chillAST_TypedefDecl(char *t, char *nt, chillAST_node *par }; -chillAST_TypedefDecl::chillAST_TypedefDecl(char *t, char *a, char *p, chillAST_node *par) { +chillAST_TypedefDecl::chillAST_TypedefDecl(char *t, const char *a, char *p, chillAST_node *par) { underlyingtype = strdup(t); //fprintf(stderr, "chillAST_TypedefDecl::chillAST_TypedefDecl( underlying type %s )\n", underlyingtype); newtype = strdup(a); // the new named type ?? diff --git a/src/chillmodule.cc b/src/chillmodule.cc index 291cb51..fa6e001 100644 --- a/src/chillmodule.cc +++ b/src/chillmodule.cc @@ -80,6 +80,7 @@ static void init_loop(int loop_num_start, int loop_num_end) { } else { if (ir_code == NULL) { + ir_code = new IR_clangCode(source_filename.c_str(),procedure_name.c_str()); IR_Block *block = ir_code->GetCode(); ir_controls = ir_code->FindOneLevelControlStructure(block); for (int i = 0; i < ir_controls.size(); i++) { diff --git a/src/ir_clang.cc b/src/ir_clang.cc index ba11ac5..0157436 100755 --- a/src/ir_clang.cc +++ b/src/ir_clang.cc @@ -1973,8 +1973,7 @@ aClangCompiler::aClangCompiler( char *filename ) { pTextDiagnosticPrinter = new clang::TextDiagnosticPrinter(llvm::errs(), diagnosticOptions); // private member of aClangCompiler //llvm::IntrusiveRefCntPtr DiagID(new clang::DiagnosticIDs()); - diagID = new clang::DiagnosticIDs(); // private member of IR_clangCode_Global_Init - + //clang::DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient); diagnosticsEngine = new clang::DiagnosticsEngine(diagID, diagnosticOptions, pTextDiagnosticPrinter); @@ -2004,10 +2003,10 @@ aClangCompiler::aClangCompiler( char *filename ) { //TargetInfo *TI = TargetInfo::CreateTargetInfo( Clang->getDiagnostics(), TO); // the above causes core dumps, because clang is stupid and frees the target multiple times, corrupting memory - const std::shared_ptr to = std::make_shared(); + targetOptions = std::make_shared(); targetOptions->Triple = llvm::sys::getDefaultTargetTriple(); - TargetInfo *pti = TargetInfo::CreateTargetInfo(Clang->getDiagnostics(),to); + TargetInfo *pti = TargetInfo::CreateTargetInfo(Clang->getDiagnostics(),targetOptions); Clang->setTarget(pti); @@ -2225,7 +2224,7 @@ IR_clangCode_Global_Init::~IR_clangCode_Global_Init() // Class: IR_clangCode // ---------------------------------------------------------------------------- -IR_clangCode::IR_clangCode(const char *fname, char *proc_name): IR_Code() { +IR_clangCode::IR_clangCode(const char *fname, const char *proc_name): IR_Code() { fprintf(stderr, "\nIR_xxxxCode::IR_xxxxCode()\n\n"); //fprintf(stderr, "IR_clangCode::IR_clangCode( filename %s, procedure %s )\n", filename, proc_name); @@ -2234,7 +2233,7 @@ IR_clangCode::IR_clangCode(const char *fname, char *proc_name): IR_Code() { int argc = 2; char *argv[2]; - argv[0] = "chill"; + argv[0] = strdup("chill"); argv[1] = strdup(filename); // use clang to parse the input file ? (or is that already done?) @@ -2253,7 +2252,7 @@ IR_clangCode::IR_clangCode(const char *fname, char *proc_name): IR_Code() { pInstance->setCurrentFunction( NULL ); // we have no function AST yet entire_file_AST = Clang->entire_file_AST; // ugly that same name, different classes - chillAST_FunctionDecl *localFD = Clang->findprocedurebyname( proc_name ); // stored locally + chillAST_FunctionDecl *localFD = Clang->findprocedurebyname( strdup(proc_name) ); // stored locally //fprintf(stderr, "back from findprocedurebyname( %s )\n", proc_name ); //localFD->print(); -- cgit v1.2.3-70-g09d2