From fe672fe3de576dbbf9a91a1add66a1f18d5e5b74 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 4 Nov 2012 10:42:00 +0100 Subject: [PATCH] update for change in clang's DiagnosticOptions DiagnosticOptions was moved from Frontend to Basic and createDiagnostics now takes a pointer to a DiagnosticOptions object. Signed-off-by: Sven Verdoolaege --- configure.ac | 3 +++ isl | 2 +- pet.cc | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index d4a9464..b241fb1 100644 --- a/configure.ac +++ b/configure.ac @@ -75,6 +75,9 @@ AC_EGREP_HEADER([isEnclosingLocal,], [clang/AST/Expr.h], AC_EGREP_HEADER([HasTemplateKWAndArgsInfo], [clang/AST/Expr.h], [AC_DEFINE([DECLREFEXPR_CREATE_REQUIRES_SOURCELOCATION], [], [Define if DeclRefExpr::Create takes SourceLocation argument])]) +AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h], + [AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [], + [Define if clang/Basic/DiagnosticOptions.h exists])]) AC_LANG_POP CPPFLAGS="$SAVE_CPPFLAGS" diff --git a/isl b/isl index 5770cf8..5510326 160000 --- a/isl +++ b/isl @@ -1 +1 @@ -Subproject commit 5770cf8a4545a0d6b5c45c6980f8f6444191bf8e +Subproject commit 5510326edbbcf2225cba7630af6cd329a58ff4a7 diff --git a/pet.cc b/pet.cc index 5d2b8c6..51497f4 100644 --- a/pet.cc +++ b/pet.cc @@ -32,6 +32,8 @@ * Leiden University. */ +#include "config.h" + #include #include #include @@ -48,7 +50,11 @@ #include #include #include +#ifdef HAVE_BASIC_DIAGNOSTICOPTIONS_H +#include +#else #include +#endif #include #include #include @@ -71,8 +77,6 @@ #include "options.h" #include "scan.h" -#include "config.h" - #define ARRAY_SIZE(array) (sizeof(array)/sizeof(*array)) using namespace std; @@ -474,12 +478,21 @@ static bool is_implicit(const IdentifierInfo *ident) struct MyDiagnosticPrinter : public TextDiagnosticPrinter { const DiagnosticOptions *DiagOpts; static bool cloned; +#ifdef HAVE_BASIC_DIAGNOSTICOPTIONS_H + MyDiagnosticPrinter(DiagnosticOptions *DO) : + TextDiagnosticPrinter(llvm::errs(), DO) {} + virtual DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const { + cloned = true; + return new MyDiagnosticPrinter(&Diags.getDiagnosticOptions()); + } +#else MyDiagnosticPrinter(const DiagnosticOptions &DO) : DiagOpts(&DO), TextDiagnosticPrinter(llvm::errs(), DO) {} virtual DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const { cloned = true; return new MyDiagnosticPrinter(*DiagOpts); } +#endif virtual void HandleDiagnostic(DiagnosticsEngine::Level level, const DiagnosticInfo &info) { if (info.getID() == diag::ext_implicit_function_decl && @@ -594,6 +607,23 @@ static CompilerInvocation *construct_invocation(const char *filename, #endif +#ifdef HAVE_BASIC_DIAGNOSTICOPTIONS_H + +static MyDiagnosticPrinter *construct_printer(void) +{ + return new MyDiagnosticPrinter(new DiagnosticOptions()); +} + +#else + +static MyDiagnosticPrinter *construct_printer(void) +{ + DiagnosticOptions DO; + return new MyDiagnosticPrinter(DO); +} + +#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. @@ -617,8 +647,7 @@ static struct pet_scop *scop_extract_from_C_source(isl_ctx *ctx, isl_union_map *value_bounds; CompilerInstance *Clang = new CompilerInstance(); - DiagnosticOptions DO; - MyDiagnosticPrinter *printer = new MyDiagnosticPrinter(DO); + MyDiagnosticPrinter *printer = construct_printer(); Clang->createDiagnostics(0, NULL, printer); if (printer->cloned) delete printer; -- 2.11.4.GIT