mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +00:00 
			
		
		
		
	Drop support for clang 6
This commit is contained in:
		
							parent
							
								
									d556a0803b
								
							
						
					
					
						commit
						6a517223eb
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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})
 | 
			
		||||
 | 
			
		||||
@ -143,7 +143,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:
 | 
			
		||||
@ -192,7 +191,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:
 | 
			
		||||
@ -200,10 +198,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:
 | 
			
		||||
 | 
			
		||||
@ -579,11 +579,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;
 | 
			
		||||
@ -674,41 +670,15 @@ public:
 | 
			
		||||
  }
 | 
			
		||||
  bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
 | 
			
		||||
                           ArrayRef<index::SymbolRelation> 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);
 | 
			
		||||
@ -1072,12 +1042,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;
 | 
			
		||||
@ -1260,9 +1226,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<FrontendAction> Action = createIndexingAction(
 | 
			
		||||
      DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param));
 | 
			
		||||
 | 
			
		||||
@ -424,7 +424,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 =
 | 
			
		||||
@ -432,7 +431,6 @@ public:
 | 
			
		||||
        for (size_t j = first_idx; j < ls_items.size(); j++)
 | 
			
		||||
          ls_items[j].additionalTextEdits.push_back(ls_edit);
 | 
			
		||||
      }
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -462,9 +460,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 &&
 | 
			
		||||
 | 
			
		||||
@ -178,11 +178,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());
 | 
			
		||||
@ -292,15 +289,10 @@ std::unique_ptr<CompilerInstance> BuildCompilerInstance(
 | 
			
		||||
    IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS, DiagnosticConsumer &DC,
 | 
			
		||||
    const PreambleData *preamble, const std::string &main,
 | 
			
		||||
    std::unique_ptr<llvm::MemoryBuffer> &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<CompilerInstance>(session.PCH);
 | 
			
		||||
  Clang->setInvocation(std::move(CI));
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user