diff --git a/src/clang_complete.h b/src/clang_complete.h index d9874c91..8633ddce 100644 --- a/src/clang_complete.h +++ b/src/clang_complete.h @@ -8,8 +8,6 @@ #include "threaded_queue.h" #include "working_files.h" -#include - #include #include #include diff --git a/src/clang_utils.cc b/src/clang_utils.cc index d1d141ea..8e0b1125 100644 --- a/src/clang_utils.cc +++ b/src/clang_utils.cc @@ -1,30 +1,14 @@ #include "clang_utils.h" +#include "config.h" #include "filesystem.hh" #include "platform.h" +#include "utils.h" #include using namespace clang; using namespace llvm; -std::string FileName(CXFile file) { - std::string ret; - // clang > 6 -#if CINDEX_VERSION >= 48 - ret = ToString(clang_File_tryGetRealPathName(file)); -#endif - if (ret.empty()) - // clang_getFileName return values may contain .. - ret = NormalizePath(ToString(clang_getFileName(file))); - // Resolve /usr/include/c++/7.3.0 symlink. - if (!StartsWith(ret, g_config->projectRoot)) { - SmallString<256> dest; - sys::fs::real_path(ret, dest); - ret = dest.str(); - } - return ret; -} - std::string FileName(const FileEntry& file) { StringRef Name = file.tryGetRealPathName(); if (Name.empty()) @@ -39,19 +23,6 @@ std::string FileName(const FileEntry& file) { return ret; } -std::string ToString(CXString cx_string) { - std::string string; - if (cx_string.data != nullptr) { - string = clang_getCString(cx_string); - clang_disposeString(cx_string); - } - return string; -} - -std::string ToString(CXCursorKind kind) { - return ToString(clang_getCursorKindSpelling(kind)); -} - // clang::BuiltinType::getName without PrintingPolicy const char* ClangBuiltinTypeName(int kind) { switch (BuiltinType::Kind(kind)) { diff --git a/src/clang_utils.h b/src/clang_utils.h index 7f52eded..6bf5d04e 100644 --- a/src/clang_utils.h +++ b/src/clang_utils.h @@ -1,19 +1,10 @@ #pragma once -#include "lsp_diagnostic.h" - -#include #include -#include -#include +#include // Returns the absolute path to |file|. -std::string FileName(CXFile file); std::string FileName(const clang::FileEntry& file); -std::string ToString(CXString cx_string); - -std::string ToString(CXCursorKind cursor_kind); - const char* ClangBuiltinTypeName(int); diff --git a/src/file_consumer.h b/src/file_consumer.h index a2ec0129..2dcb9622 100644 --- a/src/file_consumer.h +++ b/src/file_consumer.h @@ -4,7 +4,6 @@ #include "serializer.h" #include "utils.h" -#include #include #include diff --git a/src/indexer.cc b/src/indexer.cc index 0ac6c676..d624935b 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -6,6 +6,7 @@ #include "serializer.h" using ccls::Intern; +#include #include #include #include @@ -774,7 +775,7 @@ public: } [[fallthrough]]; case Decl::Record: { - auto *RD = cast(OrigD); + auto *RD = cast(D); // spec has no Union, use Class type->def.kind = RD->getTagKind() == TTK_Struct ? lsSymbolKind::Struct : lsSymbolKind::Class; diff --git a/src/indexer.h b/src/indexer.h index 7d2bc137..0e925e85 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -4,6 +4,7 @@ #include "file_consumer.h" #include "language.h" #include "lsp.h" +#include "lsp_diagnostic.h" #include "maybe.h" #include "position.h" #include "serializer.h" diff --git a/src/messages/ccls_memberHierarchy.cc b/src/messages/ccls_memberHierarchy.cc index 653b773d..e40244c4 100644 --- a/src/messages/ccls_memberHierarchy.cc +++ b/src/messages/ccls_memberHierarchy.cc @@ -125,7 +125,7 @@ bool Expand(MessageHandler* m, bool qualified, int levels) { if (0 < entry->usr && entry->usr <= BuiltinType::LastKind) { - entry->name = ClangBuiltinTypeName(CXTypeKind(entry->usr)); + entry->name = ClangBuiltinTypeName(int(entry->usr)); return true; } const QueryType& type = m->db->Type(entry->usr); diff --git a/src/test.cc b/src/test.cc index cade7314..83ba466c 100644 --- a/src/test.cc +++ b/src/test.cc @@ -6,6 +6,8 @@ #include "serializer.h" #include "utils.h" +#include + #include #include #include @@ -227,13 +229,12 @@ IndexFile* FindDbForPathEnding( bool RunIndexTests(const std::string& filter_path, bool enable_update) { gTestOutputMode = true; - std::string version = ToString(clang_getClangVersion()); + std::string version = LLVM_VERSION_STRING; // Index tests change based on the version of clang used. - static const char kRequiredClangVersion[] = - "clang version 6.0.0 (tags/RELEASE_600/final)"; + static const char kRequiredClangVersion[] = "6.0.0"; if (version != kRequiredClangVersion && - version.find("trunk") == std::string::npos) { + version.find("svn") == std::string::npos) { fprintf(stderr, "Index tests must be run using clang version %s, ccls is running " "with %s\n", diff --git a/src/working_files.h b/src/working_files.h index d5a960ac..a1758b74 100644 --- a/src/working_files.h +++ b/src/working_files.h @@ -3,10 +3,8 @@ #include "lsp_diagnostic.h" #include "utils.h" -#include -#include - #include +#include #include struct WorkingFile {