From 5455a4578479e856f9c54df4bcf14187a0d53f34 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Wed, 8 Mar 2017 13:23:36 +0100 Subject: [PATCH] Clang: Compile against llvm/clang 4.0 Task-number: QTCREATORBUG-17692 Change-Id: I2781129543c09aa64938c9570896d592b57a753c Reviewed-by: Tim Jenssen --- .../source/collectincludespreprocessorcallbacks.h | 4 ++++ .../source/collectincludestoolaction.h | 8 +++++++- .../source/refactoringcompilationdatabase.cpp | 4 ++++ .../clangrefactoringbackend/source/sourcelocationsutils.h | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h b/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h index 44ad8cfb963..ba86822fce3 100644 --- a/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h +++ b/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h @@ -165,7 +165,11 @@ public: if (!realPath.empty()) return fromNativePath({realPath.data(), realPath.size()}); +#if LLVM_VERSION_MAJOR >= 4 + return fromNativePath({file->getName().data(), file->getName().size()}); +#else return fromNativePath(file->getName()); +#endif } private: diff --git a/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h b/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h index 6cff7808e46..87e92c1df3e 100644 --- a/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h +++ b/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h @@ -44,7 +44,13 @@ public: m_excludedIncludes(excludedIncludes) {} - bool runInvocation(clang::CompilerInvocation *invocation, + + bool runInvocation( +#if LLVM_VERSION_MAJOR >= 4 + std::shared_ptr invocation, +#else + clang::CompilerInvocation *invocation, +#endif clang::FileManager *fileManager, std::shared_ptr pchContainerOperations, clang::DiagnosticConsumer *diagnosticConsumer) override diff --git a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp index 555a50f96b1..24061fb7fbb 100644 --- a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp +++ b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp @@ -82,7 +82,11 @@ void RefactoringCompilationDatabase::addFile(const std::string &directory, const std::string &fileName, const std::vector &commandLine) { +#if LLVM_VERSION_MAJOR >= 4 + compileCommands.emplace_back(directory, fileName, commandLine, nullptr); +#else compileCommands.emplace_back(directory, fileName, commandLine); +#endif } } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h b/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h index 0747d803bb3..78076f5f2bd 100644 --- a/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h +++ b/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h @@ -53,7 +53,7 @@ namespace ClangBackEnd { inline -llvm::SmallString<256> absolutePath(const char *path) +llvm::SmallString<256> absolutePath(const llvm::StringRef &path) { llvm::SmallString<256> absolutePath(path);