diff --git a/interface/Makefile.am b/interface/Makefile.am index 58bd0e60..0a36a43f 100644 --- a/interface/Makefile.am +++ b/interface/Makefile.am @@ -17,6 +17,7 @@ extract_interface_SOURCES = \ cpp.cc \ cpp_conversion.h \ cpp_conversion.cc \ + set_lang_defaults_arg4.h \ extract_interface.h \ extract_interface.cc extract_interface_LDFLAGS = $(CLANG_LDFLAGS) $(CLANG_RFLAG) diff --git a/interface/extract_interface.cc b/interface/extract_interface.cc index 26027503..e432c031 100644 --- a/interface/extract_interface.cc +++ b/interface/extract_interface.cc @@ -420,12 +420,15 @@ static void create_main_file_id(SourceManager &SM, const FileEntry *file) #ifdef SETLANGDEFAULTS_TAKES_5_ARGUMENTS +#include "set_lang_defaults_arg4.h" + static void set_lang_defaults(CompilerInstance *Clang) { PreprocessorOptions &PO = Clang->getPreprocessorOpts(); TargetOptions &TO = Clang->getTargetOpts(); llvm::Triple T(TO.Triple); - CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C, T, PO, + CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C, T, + setLangDefaultsArg4(PO), LangStandard::lang_unspecified); } diff --git a/interface/set_lang_defaults_arg4.h b/interface/set_lang_defaults_arg4.h new file mode 100644 index 00000000..82af7ff6 --- /dev/null +++ b/interface/set_lang_defaults_arg4.h @@ -0,0 +1,16 @@ +#include +#include + +#include + +/* Convert a clang::PreprocessorOptions to the fourth argument + * of CompilerInvocation::setLangDefaults, which may be either + * a clang::PreprocessorOptions itself or its Includes. + */ +struct setLangDefaultsArg4 { + setLangDefaultsArg4(clang::PreprocessorOptions &PO) : PO(PO) {} + operator clang::PreprocessorOptions &() { return PO; } + operator std::vector &() { return PO.Includes; } + + clang::PreprocessorOptions &PO; +}; diff --git a/m4/ax_detect_clang.m4 b/m4/ax_detect_clang.m4 index 85920a21..e5cc7aaa 100644 --- a/m4/ax_detect_clang.m4 +++ b/m4/ax_detect_clang.m4 @@ -75,7 +75,7 @@ CC="$SAVE_CC" AC_LANG_PUSH(C++) SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS" +CPPFLAGS="$CLANG_CXXFLAGS -I$srcdir $CPPFLAGS" AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [], [AC_ERROR([clang header file not found])]) AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [], @@ -194,6 +194,8 @@ AC_TRY_COMPILE([ #include #include #include + + #include "set_lang_defaults_arg4.h" ], [ using namespace clang; CompilerInstance *Clang; @@ -201,7 +203,8 @@ AC_TRY_COMPILE([ llvm::Triple T(TO.Triple); PreprocessorOptions PO; CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C, - T, PO, LangStandard::lang_unspecified); + T, setLangDefaultsArg4(PO), + LangStandard::lang_unspecified); ], [AC_DEFINE([SETLANGDEFAULTS_TAKES_5_ARGUMENTS], [], [Define if CompilerInvocation::setLangDefaults takes 5 arguments])]) AC_TRY_COMPILE([