diff --git a/trick_source/codegen/Interface_Code_Gen/CMakeLists.txt b/trick_source/codegen/Interface_Code_Gen/CMakeLists.txt index 088d4863..9a2b5684 100644 --- a/trick_source/codegen/Interface_Code_Gen/CMakeLists.txt +++ b/trick_source/codegen/Interface_Code_Gen/CMakeLists.txt @@ -31,6 +31,7 @@ target_compile_options( trick-ICG PUBLIC -DLIBCLANG_MAJOR=${LLVM_VERSION_MAJOR} target_include_directories( trick-ICG PUBLIC ${UDUNITS2_INCLUDES} ) target_include_directories( trick-ICG PUBLIC ${LLVM_INCLUDE_DIRS} ) set_property(SOURCE trick-ICG APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/include/mongoose/mongoose.h) +set_target_properties( trick-ICG PROPERTIES CXX_STANDARD 14) target_link_libraries( trick-ICG -lclangFrontend diff --git a/trick_source/codegen/Interface_Code_Gen/main.cpp b/trick_source/codegen/Interface_Code_Gen/main.cpp index 519a23c5..e9ed3bdd 100644 --- a/trick_source/codegen/Interface_Code_Gen/main.cpp +++ b/trick_source/codegen/Interface_Code_Gen/main.cpp @@ -10,6 +10,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" +#include "clang/Basic/Builtins.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Basic/TargetOptions.h" #include "clang/Basic/TargetInfo.h" @@ -93,6 +94,9 @@ int main(int argc, char * argv[]) { ci.getLangOpts().WChar = true ; ci.getLangOpts().CPlusPlus = true ; ci.getLangOpts().CPlusPlus11 = true ; +#if (LIBCLANG_MAJOR >= 6) + ci.getLangOpts().CPlusPlus14 = true ; +#endif ci.getLangOpts().CXXOperatorNames = true ; #if (LIBCLANG_MAJOR >= 6) ci.getLangOpts().DoubleSquareBracketAttributes = true ; @@ -133,13 +137,18 @@ int main(int argc, char * argv[]) { // Set all of the defaults to c++ #if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 9)) llvm::Triple trip (to.Triple) ; -#if (LIBCLANG_MAJOR >= 5) +#if (LIBCLANG_MAJOR >= 10) + clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::Language::CXX, trip, ppo) ; +#elif (LIBCLANG_MAJOR >= 5) clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::InputKind::CXX, trip, ppo) ; #else clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::IK_CXX, trip, ppo) ; #endif // setting the language defaults clears the c++11 flag. ci.getLangOpts().CPlusPlus11 = true ; +#if (LIBCLANG_MAJOR >= 6) + ci.getLangOpts().CPlusPlus14 = true ; +#endif #endif clang::Preprocessor& pp = ci.getPreprocessor(); @@ -201,7 +210,11 @@ int main(int argc, char * argv[]) { exit(-1); } // Open up the input file and parse it +#if (LIBCLANG_MAJOR >= 10) + const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath).get(); +#else const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath); +#endif free(inputFilePath); #if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(fileEntry, clang::SourceLocation(), clang::SrcMgr::C_User)); diff --git a/trick_source/codegen/Interface_Code_Gen/makefile b/trick_source/codegen/Interface_Code_Gen/makefile index dcaf84ec..7715cdaa 100644 --- a/trick_source/codegen/Interface_Code_Gen/makefile +++ b/trick_source/codegen/Interface_Code_Gen/makefile @@ -2,7 +2,7 @@ TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../../..) # The config_${HOST_TYPE}.mk file provides LLVM_HOME include ${TRICK_HOME}/share/trick/makefiles/Makefile.common -CXXFLAGS := -g -I$(shell $(LLVM_HOME)/bin/llvm-config --includedir) -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti $(UDUNITS_INCLUDES) -std=c++11 +CXXFLAGS := -g -I$(shell $(LLVM_HOME)/bin/llvm-config --includedir) -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti $(UDUNITS_INCLUDES) CLANG_MAJOR := $(shell $(LLVM_HOME)/bin/llvm-config --version | cut -f1 -d.) CLANG_MINOR := $(shell $(LLVM_HOME)/bin/llvm-config --version | cut -f2 -d.) @@ -10,6 +10,13 @@ CLANG_PATCHLEVEL := $(shell $(LLVM_HOME)/bin/llvm-config --version | cut -f3 -d. # check to see if version is greater than 3.5 CLANG_MINOR_GTEQ5 := $(shell [ $(CLANG_MAJOR) -gt 3 -o \( $(CLANG_MAJOR) -eq 3 -a $(CLANG_MINOR) -ge 5 \) ] && echo 1) +CLANG_MAJOR_GTEQ10 := $(shell [ $(CLANG_MAJOR) -ge 10 ] && echo 1) +ifeq ($(CLANG_MAJOR_GTEQ10),1) +CXXFLAGS += -std=c++14 +else +CXXFLAGS += -std=c++11 +endif + LLVMLDFLAGS := $(shell $(LLVM_HOME)/bin/llvm-config --ldflags) $(UDUNITS_LDFLAGS) OBJ_DIR := object_$(TRICK_HOST_CPU)