diff options
25 files changed, 85 insertions, 125 deletions
@@ -22,7 +22,7 @@ Prerequisites: * jom * On Mac OS X: latest Xcode * On Linux: g++ 4.9 or later -* LLVM/Clang 3.9.0 or later (optional, needed for the Clang Code Model, see the +* LLVM/Clang 5.0.0 or later (optional, needed for the Clang Code Model, see the section "Get LLVM/Clang for the Clang Code Model") * CMake (only for manual builds of LLVM/Clang) * Qbs 1.7.x (optional, sources also contain Qbs itself) @@ -203,7 +203,7 @@ or using shadow builds. ## Get LLVM/Clang for the Clang Code Model The Clang Code Model depends on the LLVM/Clang libraries. The currently -supported LLVM/Clang version is 3.9. +supported LLVM/Clang version is 5.0. ### Prebuilt LLVM/Clang packages @@ -224,9 +224,9 @@ GCC 4 binaries. On Ubuntu, you can download the package from http://apt.llvm.org/ with: wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt-add-repository "deb http://apt.llvm.org/`lsb_release -cs`/ llvm-toolchain-`lsb_release -cs`-3.9 main" + sudo apt-add-repository "deb http://apt.llvm.org/`lsb_release -cs`/ llvm-toolchain-`lsb_release -cs`-5.0 main" sudo apt-get update - sudo apt-get install llvm-3.9 libclang-3.9-dev + sudo apt-get install llvm-5.0 libclang-5.0-dev There is a workaround to set _GLIBCXX_USE_CXX11_ABI to 1 or 0, but we recommend to download the package from http://apt.llvm.org/. diff --git a/qbs/modules/libclang/functions.js b/qbs/modules/libclang/functions.js index 5ea298b954..3b74066562 100644 --- a/qbs/modules/libclang/functions.js +++ b/qbs/modules/libclang/functions.js @@ -1,7 +1,7 @@ var Environment = require("qbs.Environment") var File = require("qbs.File") var FileInfo = require("qbs.FileInfo") -var MinimumLLVMVersion = "3.9.0" // CLANG-UPGRADE-CHECK: Adapt minimum version numbers. +var MinimumLLVMVersion = "5.0.0" // CLANG-UPGRADE-CHECK: Adapt minimum version numbers. var Process = require("qbs.Process") function readOutput(executable, args) @@ -33,7 +33,7 @@ function llvmConfig(qbs, qtcFunctions) { var llvmInstallDirFromEnv = Environment.getEnv("LLVM_INSTALL_DIR") var llvmConfigVariants = [ - "llvm-config", "llvm-config-3.9", "llvm-config-4.0", "llvm-config-4.1" + "llvm-config", "llvm-config-5.0", "llvm-config-6.0", "llvm-config-7.0", "llvm-config-8.0", ]; // Prefer llvm-config* from LLVM_INSTALL_DIR diff --git a/qbs/modules/libclang/libclang.qbs b/qbs/modules/libclang/libclang.qbs index 402e492217..44096275b1 100644 --- a/qbs/modules/libclang/libclang.qbs +++ b/qbs/modules/libclang/libclang.qbs @@ -50,8 +50,8 @@ Module { }) property stringList llvmToolingCxxFlags: clangProbe.llvmToolingCxxFlags property bool toolingEnabled: !Environment.getEnv("QTC_NO_CLANG_LIBTOOLING") - && Utilities.versionCompare(llvmVersion, "3.9") > 0 - && Utilities.versionCompare(llvmVersion, "4") < 0 + && Utilities.versionCompare(llvmVersion, "5") > 0 + && Utilities.versionCompare(llvmVersion, "6") < 0 validate: { if (!clangProbe.found) { diff --git a/src/libs/clangsupport/dynamicastmatcherdiagnosticmessagecontainer.cpp b/src/libs/clangsupport/dynamicastmatcherdiagnosticmessagecontainer.cpp index e17ecd4da9..8b2decbef6 100644 --- a/src/libs/clangsupport/dynamicastmatcherdiagnosticmessagecontainer.cpp +++ b/src/libs/clangsupport/dynamicastmatcherdiagnosticmessagecontainer.cpp @@ -71,7 +71,7 @@ Utils::SmallString DynamicASTMatcherDiagnosticMessageContainer::errorTypeText() RETURN_CASE(ParserInvalidToken) RETURN_CASE(ParserMalformedBindExpr) RETURN_CASE(ParserTrailingCode) - RETURN_CASE(ParserUnsignedError) + RETURN_CASE(ParserNumberError) RETURN_CASE(ParserOverloadedType) } diff --git a/src/libs/clangsupport/dynamicmatcherdiagnostics.h b/src/libs/clangsupport/dynamicmatcherdiagnostics.h index 52bcbcb8e5..7f58ad934a 100644 --- a/src/libs/clangsupport/dynamicmatcherdiagnostics.h +++ b/src/libs/clangsupport/dynamicmatcherdiagnostics.h @@ -51,7 +51,7 @@ enum class ClangQueryDiagnosticErrorType { ParserInvalidToken, ParserMalformedBindExpr, ParserTrailingCode, - ParserUnsignedError, + ParserNumberError, ParserOverloadedType }; diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerutils.h b/src/plugins/clangstaticanalyzer/clangstaticanalyzerutils.h index c18317237c..b026822bf0 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerutils.h +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerutils.h @@ -59,12 +59,12 @@ public: bool isSupportedVersion() const { - return majorVersion() == 3 && minorVersion() == 9; + return majorVersion() == 5 && minorVersion() == 0; } static QString supportedVersionAsString() { - return QLatin1String("3.9"); + return QLatin1String("5.0"); } }; diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp index 72498021c6..15a9ee430d 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder.cpp @@ -55,7 +55,6 @@ QStringList CompilerOptionsBuilder::build(CppTools::ProjectFile::Kind fileKind, addOptionsForLanguage(/*checkForBorlandExtensions*/ true); enableExceptions(); - addDefineFloat128ForMingw(); addToolchainAndProjectMacros(); undefineClangVersionMacrosForMsvc(); undefineCppLanguageFeatureMacrosForMsvc2015(); @@ -271,15 +270,13 @@ void CompilerOptionsBuilder::addOptionsForLanguage(bool checkForBorlandExtension opts << (gnuExtensions ? QLatin1String("-std=gnu++98") : QLatin1String("-std=c++98")); break; case ProjectPart::CXX03: - // CLANG-UPGRADE-CHECK: Clang 3.6/3.9 does not know -std=gnu++03, but 5.0 does. - opts << QLatin1String("-std=c++03"); + opts << (gnuExtensions ? QLatin1String("-std=gnu++03") : QLatin1String("-std=c++03")); break; case ProjectPart::CXX14: opts << (gnuExtensions ? QLatin1String("-std=gnu++14") : QLatin1String("-std=c++14")); break; case ProjectPart::CXX17: - // CLANG-UPGRADE-CHECK: Change to "gnu++17"/"c++17" for clang 5.0. - opts << (gnuExtensions ? QLatin1String("-std=gnu++1z") : QLatin1String("-std=c++1z")); + opts << (gnuExtensions ? QLatin1String("-std=gnu++17") : QLatin1String("-std=c++17")); break; } @@ -326,24 +323,39 @@ void CompilerOptionsBuilder::addMsvcCompatibilityVersion() static QStringList languageFeatureMacros() { // CLANG-UPGRADE-CHECK: Update known language features macros. - // Collected with: - // $ CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 - // $ D:\usr\llvm-3.8.0\bin\clang++.exe -fms-compatibility-version=19 -std=c++1y -dM -E D:\empty.cpp | grep __cpp_ + // Collected with the following command line. + // * Use latest -fms-compatibility-version and -std possible. + // * Compatibility version 19 vs 1910 did not matter. + // $ clang++ -fms-compatibility-version=19 -std=c++1z -dM -E D:\empty.cpp | grep __cpp_ static QStringList macros{ + QLatin1String("__cpp_aggregate_bases"), QLatin1String("__cpp_aggregate_nsdmi"), QLatin1String("__cpp_alias_templates"), + QLatin1String("__cpp_aligned_new"), QLatin1String("__cpp_attributes"), QLatin1String("__cpp_binary_literals"), + QLatin1String("__cpp_capture_star_this"), QLatin1String("__cpp_constexpr"), QLatin1String("__cpp_decltype"), QLatin1String("__cpp_decltype_auto"), + QLatin1String("__cpp_deduction_guides"), QLatin1String("__cpp_delegating_constructors"), QLatin1String("__cpp_digit_separators"), + QLatin1String("__cpp_enumerator_attributes"), + QLatin1String("__cpp_exceptions"), + QLatin1String("__cpp_fold_expressions"), QLatin1String("__cpp_generic_lambdas"), + QLatin1String("__cpp_hex_float"), + QLatin1String("__cpp_if_constexpr"), QLatin1String("__cpp_inheriting_constructors"), QLatin1String("__cpp_init_captures"), QLatin1String("__cpp_initializer_lists"), + QLatin1String("__cpp_inline_variables"), QLatin1String("__cpp_lambdas"), + QLatin1String("__cpp_namespace_attributes"), + QLatin1String("__cpp_nested_namespace_definitions"), + QLatin1String("__cpp_noexcept_function_type"), + QLatin1String("__cpp_nontype_template_args"), QLatin1String("__cpp_nsdmi"), QLatin1String("__cpp_range_based_for"), QLatin1String("__cpp_raw_strings"), @@ -352,11 +364,15 @@ static QStringList languageFeatureMacros() QLatin1String("__cpp_rtti"), QLatin1String("__cpp_rvalue_references"), QLatin1String("__cpp_static_assert"), + QLatin1String("__cpp_structured_bindings"), + QLatin1String("__cpp_template_auto"), + QLatin1String("__cpp_threadsafe_static_init"), QLatin1String("__cpp_unicode_characters"), QLatin1String("__cpp_unicode_literals"), QLatin1String("__cpp_user_defined_literals"), QLatin1String("__cpp_variable_templates"), QLatin1String("__cpp_variadic_templates"), + QLatin1String("__cpp_variadic_using"), }; return macros; @@ -366,21 +382,13 @@ void CompilerOptionsBuilder::undefineCppLanguageFeatureMacrosForMsvc2015() { if (m_projectPart.toolchainType == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID && m_projectPart.isMsvc2015Toolchain) { - // Undefine the language feature macros that are pre-defined in clang-cl 3.8.0, - // but not in MSVC2015's cl.exe. + // Undefine the language feature macros that are pre-defined in clang-cl, + // but not in MSVC's cl.exe. foreach (const QString ¯oName, languageFeatureMacros()) m_options.append(undefineOption() + macroName); } } -void CompilerOptionsBuilder::addDefineFloat128ForMingw() -{ - // CLANG-UPGRADE-CHECK: Workaround still needed? - // https://llvm.org/bugs/show_bug.cgi?id=30685 - if (m_projectPart.toolchainType == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) - addDefine({"__float128", "short", ProjectExplorer::MacroType::Define}); -} - QString CompilerOptionsBuilder::includeDirOption() const { return QLatin1String("-I"); diff --git a/src/plugins/cpptools/compileroptionsbuilder.h b/src/plugins/cpptools/compileroptionsbuilder.h index 5f5e3d5e8d..6cd8d79be6 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.h +++ b/src/plugins/cpptools/compileroptionsbuilder.h @@ -70,7 +70,6 @@ public: void addMsvcCompatibilityVersion(); void undefineCppLanguageFeatureMacrosForMsvc2015(); - void addDefineFloat128ForMingw(); void addProjectConfigFileInclude(); void undefineClangVersionMacrosForMsvc(); diff --git a/src/shared/clang/clang_installation.pri b/src/shared/clang/clang_installation.pri index 45fb643b5c..572d0441b2 100644 --- a/src/shared/clang/clang_installation.pri +++ b/src/shared/clang/clang_installation.pri @@ -119,20 +119,20 @@ LIBCLANG_LIBS += $${CLANG_LIB} QTC_NO_CLANG_LIBTOOLING=$$(QTC_NO_CLANG_LIBTOOLING) isEmpty(QTC_NO_CLANG_LIBTOOLING) { QTC_FORCE_CLANG_LIBTOOLING = $$(QTC_FORCE_CLANG_LIBTOOLING) - versionIsEqual($$LLVM_VERSION, 3, 9)|!isEmpty(QTC_FORCE_CLANG_LIBTOOLING) { + versionIsEqual($$LLVM_VERSION, 5, 0)|!isEmpty(QTC_FORCE_CLANG_LIBTOOLING) { !contains(QMAKE_DEFAULT_LIBDIRS, $$LLVM_LIBDIR): LIBTOOLING_LIBS = -L$${LLVM_LIBDIR} LIBTOOLING_LIBS += $$CLANGTOOLING_LIBS $$LLVM_STATIC_LIBS contains(QMAKE_DEFAULT_INCDIRS, $$LLVM_INCLUDEPATH): LLVM_INCLUDEPATH = } else { - warning("Clang LibTooling is disabled because only version 3.9 is supported.") + warning("Clang LibTooling is disabled because only version 5.0 is supported.") } } else { warning("Clang LibTooling is disabled.") } isEmpty(LLVM_VERSION): error("Cannot determine clang version at $$LLVM_INSTALL_DIR") -!versionIsAtLeast($$LLVM_VERSION, 3, 9, 0): { # CLANG-UPGRADE-CHECK: Adapt minimum version numbers. - error("LLVM/Clang version >= 3.9.0 required, version provided: $$LLVM_VERSION") +!versionIsAtLeast($$LLVM_VERSION, 5, 0, 0): { # CLANG-UPGRADE-CHECK: Adapt minimum version numbers. + error("LLVM/Clang version >= 5.0.0 required, version provided: $$LLVM_VERSION") } # Remove unwanted flags. It is a workaround for linking. It is not intended for cross compiler linking. diff --git a/src/tools/clangbackend/source/clangbackend_global.h b/src/tools/clangbackend/source/clangbackend_global.h index d806afc98c..e62c9a3513 100644 --- a/src/tools/clangbackend/source/clangbackend_global.h +++ b/src/tools/clangbackend/source/clangbackend_global.h @@ -36,9 +36,4 @@ enum class PreferredTranslationUnit LastUninitialized, }; -// CLANG-UPGRADE-CHECK: Remove IS_SUSPEND_SUPPORTED once we require clang >= 5.0 -#if defined(CINDEX_VERSION_HAS_BACKPORTED_SUSPEND) || CINDEX_VERSION_MINOR >= 41 -# define IS_SUSPEND_SUPPORTED -#endif - } // namespace ClangBackEnd diff --git a/src/tools/clangbackend/source/clangdocumentsuspenderresumer.cpp b/src/tools/clangbackend/source/clangdocumentsuspenderresumer.cpp index cd0e29b5d0..6be3aaa7c5 100644 --- a/src/tools/clangbackend/source/clangdocumentsuspenderresumer.cpp +++ b/src/tools/clangbackend/source/clangdocumentsuspenderresumer.cpp @@ -64,7 +64,6 @@ void categorizeHotColdDocuments(int hotDocumentsSize, } } -#ifdef IS_SUSPEND_SUPPORTED static int hotDocumentsSize() { static int hotDocuments = -1; @@ -108,17 +107,11 @@ static bool isResumable(const Document &document) && document.isVisibleInEditor(); } -#endif // IS_SUSPEND_SUPPORTED - SuspendResumeJobs createSuspendResumeJobs(const std::vector<Document> &documents, int customHotDocumentSize) { - Q_UNUSED(documents); - Q_UNUSED(customHotDocumentSize); - SuspendResumeJobs jobs; -#ifdef IS_SUSPEND_SUPPORTED std::vector<Document> hotDocuments; std::vector<Document> coldDocuments; @@ -134,7 +127,6 @@ SuspendResumeJobs createSuspendResumeJobs(const std::vector<Document> &documents const std::vector<Document> toResume = Utils::filtered(hotDocuments, &isResumable); for (const Document &document : toResume) jobs += createJobs(document, JobRequest::Type::ResumeDocument); -#endif // IS_SUSPEND_SUPPORTED return jobs; } diff --git a/src/tools/clangbackend/source/clangtranslationunit.cpp b/src/tools/clangbackend/source/clangtranslationunit.cpp index 720bfb9255..6951551985 100644 --- a/src/tools/clangbackend/source/clangtranslationunit.cpp +++ b/src/tools/clangbackend/source/clangtranslationunit.cpp @@ -108,12 +108,7 @@ TranslationUnitUpdateResult TranslationUnit::reparse( bool TranslationUnit::suspend() const { -#ifdef IS_SUSPEND_SUPPORTED return clang_suspendTranslationUnit(cxTranslationUnit()); -#else - QTC_CHECK(false && "clang_suspendTranslationUnit() not supported."); - return false; -#endif } TranslationUnit::CodeCompletionResult TranslationUnit::complete( diff --git a/src/tools/clangpchmanagerbackend/source/collectincludesaction.h b/src/tools/clangpchmanagerbackend/source/collectincludesaction.h index c61dfecb61..9469e16fb0 100644 --- a/src/tools/clangpchmanagerbackend/source/collectincludesaction.h +++ b/src/tools/clangpchmanagerbackend/source/collectincludesaction.h @@ -50,20 +50,21 @@ public: { } - bool BeginSourceFileAction(clang::CompilerInstance &compilerInstance, - llvm::StringRef filename) override + bool BeginSourceFileAction(clang::CompilerInstance &compilerInstance) override { - if (clang::PreprocessOnlyAction::BeginSourceFileAction(compilerInstance, filename)) { + if (clang::PreprocessOnlyAction::BeginSourceFileAction(compilerInstance)) { auto &preprocessor = compilerInstance.getPreprocessor(); auto &headerSearch = preprocessor.getHeaderSearchInfo(); preprocessor.SetSuppressIncludeNotFoundError(true); - auto macroPreprocessorCallbacks = new CollectIncludesPreprocessorCallbacks(headerSearch, - m_includeIds, - m_filePathCache, - m_excludedIncludeUID, - m_alreadyIncludedFileUIDs); + auto macroPreprocessorCallbacks = new CollectIncludesPreprocessorCallbacks( + headerSearch, + m_includeIds, + m_filePathCache, + m_excludedIncludeUID, + m_alreadyIncludedFileUIDs, + compilerInstance.getSourceManager()); preprocessor.addPPCallbacks(std::unique_ptr<clang::PPCallbacks>(macroPreprocessorCallbacks)); diff --git a/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h b/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h index dff1dc39ce..4c7254145a 100644 --- a/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h +++ b/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h @@ -25,6 +25,7 @@ #pragma once +#include "sourcelocationsutils.h" #include <filepathcachinginterface.h> #include <filepathid.h> @@ -51,15 +52,17 @@ public: FilePathIds &includeIds, FilePathCachingInterface &filePathCache, const std::vector<uint> &excludedIncludeUID, - std::vector<uint> &alreadyIncludedFileUIDs) + std::vector<uint> &alreadyIncludedFileUIDs, + clang::SourceManager &sourceManager) : m_headerSearch(headerSearch), m_includeIds(includeIds), m_filePathCache(filePathCache), m_excludedIncludeUID(excludedIncludeUID), - m_alreadyIncludedFileUIDs(alreadyIncludedFileUIDs) + m_alreadyIncludedFileUIDs(alreadyIncludedFileUIDs), + m_sourceManager(sourceManager) {} - void InclusionDirective(clang::SourceLocation /*hashLocation*/, + void InclusionDirective(clang::SourceLocation hashLocation, const clang::Token &/*includeToken*/, llvm::StringRef /*fileName*/, bool /*isAngled*/, @@ -71,8 +74,9 @@ public: { if (!m_skipInclude && file) { auto fileUID = file->getUID(); - if (isNotInExcludedIncludeUID(fileUID)) { - flagIncludeAlreadyRead(file); + auto sourceFileID = m_sourceManager.getFileID(hashLocation); + auto sourceFileUID = m_sourceManager.getFileEntryForID(sourceFileID)->getUID(); + if (isNotInExcludedIncludeUID(fileUID) && isNotAlreadyIncluded(sourceFileUID).first) { auto notAlreadyIncluded = isNotAlreadyIncluded(fileUID); if (notAlreadyIncluded.first) { @@ -142,35 +146,13 @@ public: return {range.first == range.second, range.first}; } - void flagIncludeAlreadyRead(const clang::FileEntry *file) - { - auto &headerFileInfo = m_headerSearch.getFileInfo(file); - - headerFileInfo.isImport = true; - ++headerFileInfo.NumIncludes; - } - - static Utils::PathString fromNativePath(Utils::PathString &&filePath) - { -#ifdef _WIN32 - if (filePath.startsWith("\\\\?\\")) - filePath = Utils::PathString(filePath.mid(4)); - filePath.replace('\\', '/'); -#endif - return std::move(filePath); - } - static Utils::PathString filePathFromFile(const clang::FileEntry *file) { clang::StringRef realPath = file->tryGetRealPathName(); if (!realPath.empty()) - return fromNativePath({realPath.data(), realPath.size()}); + return fromNativePath(realPath); -#if LLVM_VERSION_MAJOR >= 4 - return fromNativePath({file->getName().data(), file->getName().size()}); -#else - return fromNativePath(file->getName()); -#endif + return fromNativePath(absolutePath(file->getName())); } private: @@ -179,6 +161,7 @@ private: FilePathCachingInterface &m_filePathCache; const std::vector<uint> &m_excludedIncludeUID; std::vector<uint> &m_alreadyIncludedFileUIDs; + clang::SourceManager &m_sourceManager; bool m_skipInclude = false; }; diff --git a/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h b/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h index 969a8ddb8b..d8fa4ef24b 100644 --- a/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h +++ b/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h @@ -46,12 +46,7 @@ public: {} - bool runInvocation( -#if LLVM_VERSION_MAJOR >= 4 - std::shared_ptr<clang::CompilerInvocation> invocation, -#else - clang::CompilerInvocation *invocation, -#endif + bool runInvocation(std::shared_ptr<clang::CompilerInvocation> invocation, clang::FileManager *fileManager, std::shared_ptr<clang::PCHContainerOperations> pchContainerOperations, clang::DiagnosticConsumer *diagnosticConsumer) override diff --git a/src/tools/clangrefactoringbackend/source/clangquery.cpp b/src/tools/clangrefactoringbackend/source/clangquery.cpp index fc9dd868c0..1524e36da5 100644 --- a/src/tools/clangrefactoringbackend/source/clangquery.cpp +++ b/src/tools/clangrefactoringbackend/source/clangquery.cpp @@ -132,7 +132,7 @@ ClangQueryDiagnosticErrorType convertToErrorType(Diagnostics::ErrorType clangErr ERROR_RETURN_CASE(ParserInvalidToken) ERROR_RETURN_CASE(ParserMalformedBindExpr) ERROR_RETURN_CASE(ParserTrailingCode) - ERROR_RETURN_CASE(ParserUnsignedError) + ERROR_RETURN_CASE(ParserNumberError) ERROR_RETURN_CASE(ParserOverloadedType) } diff --git a/src/tools/clangrefactoringbackend/source/locationsourcefilecallbacks.cpp b/src/tools/clangrefactoringbackend/source/locationsourcefilecallbacks.cpp index 3dd43976a0..9502c3e9c0 100644 --- a/src/tools/clangrefactoringbackend/source/locationsourcefilecallbacks.cpp +++ b/src/tools/clangrefactoringbackend/source/locationsourcefilecallbacks.cpp @@ -57,7 +57,7 @@ LocationSourceFileCallbacks::LocationSourceFileCallbacks(uint line, { } -bool LocationSourceFileCallbacks::handleBeginSource(clang::CompilerInstance &compilerInstance, llvm::StringRef /*fileName*/) +bool LocationSourceFileCallbacks::handleBeginSource(clang::CompilerInstance &compilerInstance) { auto &preprocessor = compilerInstance.getPreprocessor(); diff --git a/src/tools/clangrefactoringbackend/source/locationsourcefilecallbacks.h b/src/tools/clangrefactoringbackend/source/locationsourcefilecallbacks.h index 5b7fe2af4a..85ce5b413d 100644 --- a/src/tools/clangrefactoringbackend/source/locationsourcefilecallbacks.h +++ b/src/tools/clangrefactoringbackend/source/locationsourcefilecallbacks.h @@ -48,8 +48,7 @@ class LocationSourceFileCallbacks : public clang::tooling::SourceFileCallbacks public: LocationSourceFileCallbacks(uint line, uint column, FilePathCachingInterface &filePathCache); - bool handleBeginSource(clang::CompilerInstance &compilerInstance, - llvm::StringRef fileName) override; + bool handleBeginSource(clang::CompilerInstance &compilerInstance) override; SourceLocationsContainer takeSourceLocations(); Utils::SmallString takeSymbolName(); diff --git a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp index 38d89a39d0..4699ec3818 100644 --- a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp +++ b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp @@ -82,11 +82,8 @@ void RefactoringCompilationDatabase::addFile(const std::string &directory, const std::string &fileName, const std::vector<std::string> &commandLine) { -#if LLVM_VERSION_MAJOR >= 4 - compileCommands.emplace_back(directory, fileName, commandLine, std::string()); -#else - compileCommands.emplace_back(directory, fileName, commandLine); -#endif + + compileCommands.emplace_back(directory, fileName, commandLine, llvm::StringRef()); } } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h b/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h index c7d11da517..3d5fb8d3e8 100644 --- a/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h +++ b/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h @@ -42,9 +42,11 @@ namespace ClangBackEnd { inline llvm::SmallString<256> absolutePath(clang::StringRef path) { - llvm::SmallString<256> absolutePath(path); + llvm::SmallString<256> absolutePath; - if (!llvm::sys::path::is_absolute(absolutePath)) + std::error_code errorCode = llvm::sys::fs::real_path(path, absolutePath, true); + + if (!errorCode && !llvm::sys::path::is_absolute(absolutePath)) llvm::sys::fs::make_absolute(absolutePath); return absolutePath; diff --git a/tests/unit/unittest/clangdocumentsuspenderresumer-test.cpp b/tests/unit/unittest/clangdocumentsuspenderresumer-test.cpp index 8f51e7b089..8c1954410f 100644 --- a/tests/unit/unittest/clangdocumentsuspenderresumer-test.cpp +++ b/tests/unit/unittest/clangdocumentsuspenderresumer-test.cpp @@ -183,7 +183,7 @@ TEST_F(DocumentSuspenderResumer, CategorizeWithMoreVisibleDocumentsThanHotDocume ASSERT_THAT(coldDocuments, IsEmpty()); } -TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(CreateSuspendJobForInvisible)) +TEST_F(DocumentSuspenderResumer, CreateSuspendJobForInvisible) { Document document = documents.create({fileContainer1})[0]; document.setIsSuspended(false); @@ -199,7 +199,7 @@ TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(CreateSuspendJob ASSERT_THAT(jobs, ContainerEq(expectedJobs)); } -TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(DoNotCreateSuspendJobForVisible)) +TEST_F(DocumentSuspenderResumer, DoNotCreateSuspendJobForVisible) { Document document = documents.create({fileContainer1})[0]; document.setIsSuspended(false); @@ -210,7 +210,7 @@ TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(DoNotCreateSuspe ASSERT_THAT(jobs, IsEmpty()); } -TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(DoNotCreateSuspendJobForUnparsed)) +TEST_F(DocumentSuspenderResumer, DoNotCreateSuspendJobForUnparsed) { Document document = documents.create({fileContainer1})[0]; document.setIsSuspended(false); @@ -221,7 +221,7 @@ TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(DoNotCreateSuspe ASSERT_THAT(jobs, IsEmpty()); } -TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(CreateSuspendJobsForDocumentWithSupportiveTranslationUnit)) +TEST_F(DocumentSuspenderResumer, CreateSuspendJobsForDocumentWithSupportiveTranslationUnit) { Document document = documents.create({fileContainer1})[0]; document.setIsSuspended(false); @@ -238,7 +238,7 @@ TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(CreateSuspendJob ASSERT_THAT(jobs, ContainerEq(expectedJobs)); } -TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(CreateResumeJob)) +TEST_F(DocumentSuspenderResumer, CreateResumeJob) { Document document = documents.create({fileContainer1})[0]; document.setIsSuspended(true); @@ -252,7 +252,7 @@ TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(CreateResumeJob) ASSERT_THAT(jobs, ContainerEq(expectedJobs)); } -TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(DoNotCreateResumeJobForInvisible)) +TEST_F(DocumentSuspenderResumer, DoNotCreateResumeJobForInvisible) { Document document = documents.create({fileContainer1})[0]; document.setIsSuspended(true); @@ -263,7 +263,7 @@ TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(DoNotCreateResum ASSERT_THAT(jobs, IsEmpty()); } -TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(CreateResumeJobsForDocumentWithSupportiveTranslationUnit)) +TEST_F(DocumentSuspenderResumer, CreateResumeJobsForDocumentWithSupportiveTranslationUnit) { Document document = documents.create({fileContainer1})[0]; document.setIsSuspended(true); @@ -279,7 +279,7 @@ TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(CreateResumeJobs ASSERT_THAT(jobs, ContainerEq(expectedJobs)); } -TEST_F(DocumentSuspenderResumer, DISABLED_WITHOUT_SUSPEND_PATCH(CreateSuspendAndResumeJobs)) +TEST_F(DocumentSuspenderResumer, CreateSuspendAndResumeJobs) { Document hotDocument = documents.create({fileContainer1})[0]; hotDocument.setIsSuspended(true); diff --git a/tests/unit/unittest/clangsuspenddocumentjob-test.cpp b/tests/unit/unittest/clangsuspenddocumentjob-test.cpp index a6aeaf9efe..b9f92f3beb 100644 --- a/tests/unit/unittest/clangsuspenddocumentjob-test.cpp +++ b/tests/unit/unittest/clangsuspenddocumentjob-test.cpp @@ -58,7 +58,7 @@ TEST_F(SuspendDocumentJob, RunAsync) ASSERT_TRUE(waitUntilJobFinished(job)); } -TEST_F(SuspendDocumentJob, DISABLED_WITHOUT_SUSPEND_PATCH(DocumentIsSuspendedAfterRun)) +TEST_F(SuspendDocumentJob, DocumentIsSuspendedAfterRun) { document.parse(); job.setContext(jobContext); diff --git a/tests/unit/unittest/codecompletionsextractor-test.cpp b/tests/unit/unittest/codecompletionsextractor-test.cpp index 7c89fe58e9..194459f179 100644 --- a/tests/unit/unittest/codecompletionsextractor-test.cpp +++ b/tests/unit/unittest/codecompletionsextractor-test.cpp @@ -622,9 +622,9 @@ TEST_F(CodeCompletionsExtractorSlowTest, CompletionChunksFunctionWithOptionalChu {CodeCompletionChunk::LeftParen, Utf8StringLiteral("(")}, {CodeCompletionChunk::Placeholder, Utf8StringLiteral("int x")}, {CodeCompletionChunk::Comma, Utf8StringLiteral(", "), true}, - {CodeCompletionChunk::Placeholder, Utf8StringLiteral("char y"), true}, + {CodeCompletionChunk::Placeholder, Utf8StringLiteral("char y = 1"), true}, {CodeCompletionChunk::Comma, Utf8StringLiteral(", "), true}, - {CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z"), true}, + {CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z = 5"), true}, {CodeCompletionChunk::RightParen, Utf8StringLiteral(")")}}))); } diff --git a/tests/unit/unittest/conditionally-disabled-tests.h b/tests/unit/unittest/conditionally-disabled-tests.h index 29879bbee5..40251a13f4 100644 --- a/tests/unit/unittest/conditionally-disabled-tests.h +++ b/tests/unit/unittest/conditionally-disabled-tests.h @@ -39,9 +39,3 @@ #else # define DISABLED_ON_CLANG3(x) x #endif - -#ifdef IS_SUSPEND_SUPPORTED -# define DISABLED_WITHOUT_SUSPEND_PATCH(x) x -#else -# define DISABLED_WITHOUT_SUSPEND_PATCH(x) DISABLED_##x -#endif diff --git a/tests/unit/unittest/creator_dependency.pri b/tests/unit/unittest/creator_dependency.pri index 2a960f323e..f86f9e9967 100644 --- a/tests/unit/unittest/creator_dependency.pri +++ b/tests/unit/unittest/creator_dependency.pri @@ -19,7 +19,7 @@ include($$PWD/../../../src/shared/clang/clang_defines.pri) include($$PWD/../../../src/tools/clangbackend/source/clangbackendclangipc-source.pri) include($$PWD/../../../src/plugins/clangcodemodel/clangcodemodelunittestfiles.pri) } else { -DEFINES += CLANG_VERSION=\\\"3.9.1\\\" +DEFINES += CLANG_VERSION=\\\"5.0.0\\\" DEFINES += "\"CLANG_RESOURCE_DIR=\\\"/usr/include\\\"\"" } |