diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f68f84c..8888e40 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,7 +27,7 @@ message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") Find_Package(Clang REQUIRED CONFIG HINTS "${LLVM_INSTALL_PREFIX}/lib/cmake/clang") message(STATUS "Found Clang in ${CLANG_INSTALL_PREFIX}") -set (CMAKE_CXX_STANDARD 11) +set (CMAKE_CXX_STANDARD 14) SET(common_srcs mocng.cpp generator.cpp propertyparser.cpp mocppcallbacks.cpp mocastconsumer.cpp qbjs.cpp clangversionabstraction.cpp workaroundtests.cpp) diff --git a/src/main.cpp b/src/main.cpp index ed8132c..4e8f8d0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -448,7 +448,13 @@ int main(int argc, const char **argv) if (PreprocessorOnly) { Argv.push_back("-P"); - clang::tooling::ToolInvocation Inv(Argv, new clang::PrintPreprocessedAction, &FM); + clang::tooling::ToolInvocation Inv(Argv, + #if CLANG_VERSION_MAJOR >= 10 + std::make_unique(), + #else + new clang::PrintPreprocessedAction, + #endif + &FM); return !Inv.run(); } @@ -462,7 +468,13 @@ int main(int argc, const char **argv) Argv.push_back("QtCore/qobject.h"); } - clang::tooling::ToolInvocation Inv(Argv, new MocAction, &FM); + clang::tooling::ToolInvocation Inv(Argv, + #if CLANG_VERSION_MAJOR >= 10 + std::make_unique(), + #else + new MocAction, + #endif + &FM); const EmbeddedFile *f = EmbeddedFiles; while (f->filename) { diff --git a/src/mocng.cpp b/src/mocng.cpp index b6ef0d9..242384a 100644 --- a/src/mocng.cpp +++ b/src/mocng.cpp @@ -156,20 +156,33 @@ static void parsePluginMetaData(ClassDef &Def, clang::Expr *Content, clang::Sema else { llvm::StringRef Filename = Literal.GetString(); const clang::DirectoryLookup *CurDir; - const clang::FileEntry *File = PP.LookupFile( - Val->getSourceRange().getBegin(), - Filename, false, nullptr, -#if CLANG_VERSION_MAJOR!=3 || CLANG_VERSION_MINOR>5 - nullptr, -#endif - CurDir, nullptr, nullptr, nullptr -#if CLANG_VERSION_MAJOR >= 5 - , nullptr +#if CLANG_VERSION_MAJOR < 10 + const clang::FileEntry *File = +#else + const clang::Optional fileRef + { #endif -#if CLANG_VERSION_MAJOR >= 9 - , nullptr + PP.LookupFile( + Val->getSourceRange().getBegin(), + Filename, false, nullptr, + #if CLANG_VERSION_MAJOR!=3 || CLANG_VERSION_MINOR>5 + nullptr, + #endif + CurDir, nullptr, nullptr, nullptr + #if CLANG_VERSION_MAJOR >= 5 + , nullptr + #endif + #if CLANG_VERSION_MAJOR >= 9 + , nullptr + #endif + ) +#if CLANG_VERSION_MAJOR >= 10 + }; + + const clang::FileEntry *File = fileRef ? &fileRef->getFileEntry() : nullptr; +#else + ; #endif - ); if (!File) { PP.getDiagnostics().Report(GetFromLiteral(StrToks.front(), Val, PP), clang::diag::err_pp_file_not_found)