configure.ac: check if TargetInfo::CreateTargetInfo takes TargetOptions pointer
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 23 Nov 2012 20:43:29 +0000 (23 21:43 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 24 Nov 2012 08:45:52 +0000 (24 09:45 +0100)
Newer versions of clang take a pointer, while older versions take a reference.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
configure.ac
interface/extract_interface.cc

index 5ec7f7b..a0a3791 100644 (file)
@@ -167,6 +167,13 @@ system)
        AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
                [AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
                           [Define if clang/Basic/DiagnosticOptions.h exists])])
+       AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
+               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"
 
index f39febc..db59342 100644 (file)
@@ -210,6 +210,28 @@ static TextDiagnosticPrinter *construct_printer(void)
 
 #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
+
 int main(int argc, char *argv[])
 {
        llvm::cl::ParseCommandLineOptions(argc, argv);
@@ -224,9 +246,7 @@ int main(int argc, char *argv[])
                Clang->setInvocation(invocation);
        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);