From 0dbf6c89f119c43a4ec94586127cc1f5216888c3 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 21 Jan 2019 10:44:44 +0800 Subject: [PATCH] Drop support for clang 6 --- CMakeLists.txt | 2 +- cmake/FindClang.cmake | 1 - src/clang_tu.cc | 4 --- src/indexer.cc | 44 +++---------------------- src/messages/textDocument_completion.cc | 4 --- src/sema_manager.cc | 16 +++------ 6 files changed, 9 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf39ebfd..f84d67ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,7 @@ endif() ### Libraries # See cmake/FindClang.cmake -find_package(Clang 6.0.0) +find_package(Clang 7.0.0) target_link_libraries(ccls PRIVATE Clang::Clang) # Enable threading support diff --git a/cmake/FindClang.cmake b/cmake/FindClang.cmake index 19402900..078395dd 100644 --- a/cmake/FindClang.cmake +++ b/cmake/FindClang.cmake @@ -72,7 +72,6 @@ _Clang_find_library(Clang_LIBRARY clangIndex) _Clang_find_add_library(clangFormat) _Clang_find_add_library(clangTooling) -# TODO Remove after dropping clang 6 _Clang_find_library(clangToolingInclusions_LIBRARY clangToolingInclusions) if (clangToolingInclusions_LIBRARY) list(APPEND _Clang_LIBRARIES ${clangToolingInclusions_LIBRARY}) diff --git a/src/clang_tu.cc b/src/clang_tu.cc index a2d982b4..70078c61 100644 --- a/src/clang_tu.cc +++ b/src/clang_tu.cc @@ -156,7 +156,6 @@ const char *ClangBuiltinTypeName(int kind) { return "double"; case BuiltinType::LongDouble: return "long double"; -#if LLVM_VERSION_MAJOR >= 7 case BuiltinType::ShortAccum: return "short _Accum"; case BuiltinType::Accum: @@ -205,7 +204,6 @@ const char *ClangBuiltinTypeName(int kind) { return "_Sat unsigned _Fract"; case BuiltinType::BuiltinType::SatULongFract: return "_Sat unsigned long _Fract"; -#endif case BuiltinType::Float16: return "_Float16"; case BuiltinType::Float128: @@ -213,10 +211,8 @@ const char *ClangBuiltinTypeName(int kind) { case BuiltinType::WChar_S: case BuiltinType::WChar_U: return "wchar_t"; -#if LLVM_VERSION_MAJOR >= 7 case BuiltinType::Char8: return "char8_t"; -#endif case BuiltinType::Char16: return "char16_t"; case BuiltinType::Char32: diff --git a/src/indexer.cc b/src/indexer.cc index 43969f23..716a092f 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -593,11 +593,7 @@ public: if (init) { SourceManager &SM = Ctx->getSourceManager(); const LangOptions &Lang = Ctx->getLangOpts(); - SourceRange R = SM.getExpansionRange(init->getSourceRange()) -#if LLVM_VERSION_MAJOR >= 7 - .getAsRange() -#endif - ; + SourceRange R = SM.getExpansionRange(init->getSourceRange()).getAsRange(); SourceLocation L = D->getLocation(); if (L.isMacroID() || !SM.isBeforeInTranslationUnit(L, R.getBegin())) return; @@ -688,41 +684,15 @@ public: } bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles, ArrayRef Relations, -#if LLVM_VERSION_MAJOR >= 7 - SourceLocation Loc, -#else - FileID LocFID, unsigned LocOffset, -#endif - ASTNodeInfo ASTNode) override { + SourceLocation Loc, ASTNodeInfo ASTNode) override { SourceManager &SM = Ctx->getSourceManager(); const LangOptions &Lang = Ctx->getLangOpts(); -#if LLVM_VERSION_MAJOR < 7 - SourceLocation Loc; - { - const SrcMgr::SLocEntry &Entry = SM.getSLocEntry(LocFID); - unsigned off = Entry.getOffset() + LocOffset; - if (!Entry.isFile()) - off |= 1u << 31; - Loc = SourceLocation::getFromRawEncoding(off); - } -#else FileID LocFID; -#endif SourceLocation Spell = SM.getSpellingLoc(Loc); const FileEntry *FE; Range loc; -#if LLVM_VERSION_MAJOR < 7 - CharSourceRange R; - if (SM.isMacroArgExpansion(Loc)) - R = CharSourceRange::getTokenRange(Spell); - else { - auto P = SM.getExpansionRange(Loc); - R = CharSourceRange::getTokenRange(P.first, P.second); - } -#else auto R = SM.isMacroArgExpansion(Loc) ? CharSourceRange::getTokenRange(Spell) : SM.getExpansionRange(Loc); -#endif loc = FromCharSourceRange(SM, Lang, R); LocFID = SM.getFileID(R.getBegin()); FE = SM.getFileEntryForID(LocFID); @@ -1085,12 +1055,8 @@ public: StringRef Included, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported -#if LLVM_VERSION_MAJOR >= 7 - , - SrcMgr::CharacteristicKind FileType -#endif - ) override { + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override { if (!File) return; llvm::sys::fs::UniqueID UniqueID; @@ -1283,9 +1249,7 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs, IndexOpts.SystemSymbolFilter = index::IndexingOptions::SystemSymbolFilterKind::All; IndexOpts.IndexFunctionLocals = true; -#if LLVM_VERSION_MAJOR >= 7 IndexOpts.IndexImplicitInstantiation = true; -#endif std::unique_ptr Action = createIndexingAction( DataConsumer, IndexOpts, std::make_unique(param)); diff --git a/src/messages/textDocument_completion.cc b/src/messages/textDocument_completion.cc index f401931e..a1f0884e 100644 --- a/src/messages/textDocument_completion.cc +++ b/src/messages/textDocument_completion.cc @@ -436,7 +436,6 @@ public: ls_items[j].label = ls_items[j].filterText; } } -#if LLVM_VERSION_MAJOR >= 7 for (const FixItHint &FixIt : R.FixIts) { auto &AST = S.getASTContext(); TextEdit ls_edit = @@ -444,7 +443,6 @@ public: for (size_t j = first_idx; j < ls_items.size(); j++) ls_items[j].additionalTextEdits.push_back(ls_edit); } -#endif } } @@ -474,9 +472,7 @@ void MessageHandler::textDocument_completion(CompletionParam ¶m, clang::CodeCompleteOptions CCOpts; CCOpts.IncludeBriefComments = true; CCOpts.IncludeCodePatterns = StringRef(buffer_line).ltrim().startswith("#"); -#if LLVM_VERSION_MAJOR >= 7 CCOpts.IncludeFixIts = true; -#endif CCOpts.IncludeMacros = true; if (param.context.triggerKind == CompletionTriggerKind::TriggerCharacter && diff --git a/src/sema_manager.cc b/src/sema_manager.cc index c352f0f4..a80bd0d7 100644 --- a/src/sema_manager.cc +++ b/src/sema_manager.cc @@ -190,11 +190,8 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const clang::Module *Imported -#if LLVM_VERSION_MAJOR >= 7 - , SrcMgr::CharacteristicKind FileKind -#endif - ) override { + const clang::Module *Imported, + SrcMgr::CharacteristicKind FileKind) override { (void)SM; if (File && Seen.insert(File).second) out.emplace_back(PathFromFileEntry(*File), File->getModificationTime()); @@ -304,15 +301,10 @@ std::unique_ptr BuildCompilerInstance( IntrusiveRefCntPtr FS, DiagnosticConsumer &DC, const PreambleData *preamble, const std::string &main, std::unique_ptr &Buf) { - if (preamble) { -#if LLVM_VERSION_MAJOR >= 7 + if (preamble) preamble->Preamble.OverridePreamble(*CI, FS, Buf.get()); -#else - preamble->Preamble.AddImplicitPreamble(*CI, FS, Buf.get()); -#endif - } else { + else CI->getPreprocessorOpts().addRemappedFile(main, Buf.get()); - } auto Clang = std::make_unique(session.PCH); Clang->setInvocation(std::move(CI));