From 83be4b6bbf3cc7c68dd1583c585fe53ac8c86679 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 24 Nov 2012 09:57:00 +0100 Subject: [PATCH] configure.ac: check if TargetInfo::CreateTargetInfo takes TargetOptions pointer Newer versions of clang take a pointer, while older versions take a reference. Signed-off-by: Sven Verdoolaege --- configure.ac | 7 +++++++ pet.cc | 26 +++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index af36abc..230362d 100644 --- a/configure.ac +++ b/configure.ac @@ -86,6 +86,13 @@ AC_CHECK_HEADER([clang/Lex/PreprocessorOptions.h], [AC_DEFINE([HAVE_LEX_PREPROCESSOROPTIONS_H], [], [Define if clang/Lex/PreprocessorOptions.h exists])], [], [#include ]) +AC_TRY_COMPILE([#include ], [ + using namespace clang; + TargetOptions *TO; + DiagnosticsEngine *Diags; + TargetInfo::CreateTargetInfo(*Diags, TO); +], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [], + [Define if TargetInfo::CreateTargetInfo takes pointer])]) AC_LANG_POP CPPFLAGS="$SAVE_CPPFLAGS" diff --git a/pet.cc b/pet.cc index 62e4b42..3ac73ab 100644 --- a/pet.cc +++ b/pet.cc @@ -631,6 +631,28 @@ static MyDiagnosticPrinter *construct_printer(CompilerInstance *Clang) #endif +#ifdef CREATETARGETINFO_TAKES_POINTER + +static TargetInfo *create_target_info(CompilerInstance *Clang, + DiagnosticsEngine &Diags) +{ + TargetOptions &TO = Clang->getTargetOpts(); + TO.Triple = llvm::sys::getDefaultTargetTriple(); + return TargetInfo::CreateTargetInfo(Diags, &TO); +} + +#else + +static TargetInfo *create_target_info(CompilerInstance *Clang, + DiagnosticsEngine &Diags) +{ + TargetOptions &TO = Clang->getTargetOpts(); + TO.Triple = llvm::sys::getDefaultTargetTriple(); + return TargetInfo::CreateTargetInfo(Diags, TO); +} + +#endif + /* Extract a pet_scop from the C source file called "filename". * If "function" is not NULL, extract the pet_scop from the function * with that name. @@ -666,9 +688,7 @@ static struct pet_scop *scop_extract_from_C_source(isl_ctx *ctx, delete printer; Clang->createFileManager(); Clang->createSourceManager(Clang->getFileManager()); - TargetOptions &TO = Clang->getTargetOpts(); - TO.Triple = llvm::sys::getDefaultTargetTriple(); - TargetInfo *target = TargetInfo::CreateTargetInfo(Diags, TO); + TargetInfo *target = create_target_info(Clang, Diags); Clang->setTarget(target); CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C, LangStandard::lang_unspecified); -- 2.11.4.GIT