Drop support for clang 6

This commit is contained in:
Fangrui Song 2019-01-21 10:44:44 +08:00
parent 26fb0a9dd3
commit 0dbf6c89f1
6 changed files with 9 additions and 62 deletions

View File

@ -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

View File

@ -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})

View File

@ -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:

View File

@ -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<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);
@ -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<FrontendAction> Action = createIndexingAction(
DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param));

View File

@ -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 &param,
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 &&

View File

@ -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<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));