mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-27 10:02:03 +00:00
Simplify
This commit is contained in:
parent
5dcccea285
commit
df72a9eb72
@ -8,8 +8,6 @@
|
|||||||
#include "threaded_queue.h"
|
#include "threaded_queue.h"
|
||||||
#include "working_files.h"
|
#include "working_files.h"
|
||||||
|
|
||||||
#include <clang-c/Index.h>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -1,30 +1,14 @@
|
|||||||
#include "clang_utils.h"
|
#include "clang_utils.h"
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "filesystem.hh"
|
#include "filesystem.hh"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <clang/AST/Type.h>
|
#include <clang/AST/Type.h>
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
using namespace llvm;
|
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) {
|
std::string FileName(const FileEntry& file) {
|
||||||
StringRef Name = file.tryGetRealPathName();
|
StringRef Name = file.tryGetRealPathName();
|
||||||
if (Name.empty())
|
if (Name.empty())
|
||||||
@ -39,19 +23,6 @@ std::string FileName(const FileEntry& file) {
|
|||||||
return ret;
|
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
|
// clang::BuiltinType::getName without PrintingPolicy
|
||||||
const char* ClangBuiltinTypeName(int kind) {
|
const char* ClangBuiltinTypeName(int kind) {
|
||||||
switch (BuiltinType::Kind(kind)) {
|
switch (BuiltinType::Kind(kind)) {
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "lsp_diagnostic.h"
|
|
||||||
|
|
||||||
#include <clang-c/Index.h>
|
|
||||||
#include <clang/Basic/FileManager.h>
|
#include <clang/Basic/FileManager.h>
|
||||||
|
|
||||||
#include <optional>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// Returns the absolute path to |file|.
|
// Returns the absolute path to |file|.
|
||||||
std::string FileName(CXFile file);
|
|
||||||
std::string FileName(const clang::FileEntry& file);
|
std::string FileName(const clang::FileEntry& file);
|
||||||
|
|
||||||
std::string ToString(CXString cx_string);
|
|
||||||
|
|
||||||
std::string ToString(CXCursorKind cursor_kind);
|
|
||||||
|
|
||||||
const char* ClangBuiltinTypeName(int);
|
const char* ClangBuiltinTypeName(int);
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <clang-c/Index.h>
|
|
||||||
#include <clang/Basic/FileManager.h>
|
#include <clang/Basic/FileManager.h>
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
using ccls::Intern;
|
using ccls::Intern;
|
||||||
|
|
||||||
|
#include <clang-c/Index.h>
|
||||||
#include <clang/AST/AST.h>
|
#include <clang/AST/AST.h>
|
||||||
#include <clang/Frontend/ASTUnit.h>
|
#include <clang/Frontend/ASTUnit.h>
|
||||||
#include <clang/Frontend/CompilerInstance.h>
|
#include <clang/Frontend/CompilerInstance.h>
|
||||||
@ -777,7 +778,7 @@ public:
|
|||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case Decl::Record: {
|
case Decl::Record: {
|
||||||
auto *RD = cast<RecordDecl>(OrigD);
|
auto *RD = cast<RecordDecl>(D);
|
||||||
// spec has no Union, use Class
|
// spec has no Union, use Class
|
||||||
type->def.kind = RD->getTagKind() == TTK_Struct ? lsSymbolKind::Struct
|
type->def.kind = RD->getTagKind() == TTK_Struct ? lsSymbolKind::Struct
|
||||||
: lsSymbolKind::Class;
|
: lsSymbolKind::Class;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "file_consumer.h"
|
#include "file_consumer.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "lsp.h"
|
#include "lsp.h"
|
||||||
|
#include "lsp_diagnostic.h"
|
||||||
#include "maybe.h"
|
#include "maybe.h"
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
|
@ -125,7 +125,7 @@ bool Expand(MessageHandler* m,
|
|||||||
bool qualified,
|
bool qualified,
|
||||||
int levels) {
|
int levels) {
|
||||||
if (0 < entry->usr && entry->usr <= BuiltinType::LastKind) {
|
if (0 < entry->usr && entry->usr <= BuiltinType::LastKind) {
|
||||||
entry->name = ClangBuiltinTypeName(CXTypeKind(entry->usr));
|
entry->name = ClangBuiltinTypeName(int(entry->usr));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const QueryType& type = m->db->Type(entry->usr);
|
const QueryType& type = m->db->Type(entry->usr);
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <llvm/Config/llvm-config.h>
|
||||||
|
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <rapidjson/prettywriter.h>
|
#include <rapidjson/prettywriter.h>
|
||||||
#include <rapidjson/stringbuffer.h>
|
#include <rapidjson/stringbuffer.h>
|
||||||
@ -227,13 +229,12 @@ IndexFile* FindDbForPathEnding(
|
|||||||
|
|
||||||
bool RunIndexTests(const std::string& filter_path, bool enable_update) {
|
bool RunIndexTests(const std::string& filter_path, bool enable_update) {
|
||||||
gTestOutputMode = true;
|
gTestOutputMode = true;
|
||||||
std::string version = ToString(clang_getClangVersion());
|
std::string version = LLVM_VERSION_STRING;
|
||||||
|
|
||||||
// Index tests change based on the version of clang used.
|
// Index tests change based on the version of clang used.
|
||||||
static const char kRequiredClangVersion[] =
|
static const char kRequiredClangVersion[] = "6.0.0";
|
||||||
"clang version 6.0.0 (tags/RELEASE_600/final)";
|
|
||||||
if (version != kRequiredClangVersion &&
|
if (version != kRequiredClangVersion &&
|
||||||
version.find("trunk") == std::string::npos) {
|
version.find("svn") == std::string::npos) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Index tests must be run using clang version %s, ccls is running "
|
"Index tests must be run using clang version %s, ccls is running "
|
||||||
"with %s\n",
|
"with %s\n",
|
||||||
|
@ -3,10 +3,8 @@
|
|||||||
#include "lsp_diagnostic.h"
|
#include "lsp_diagnostic.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <clang-c/Index.h>
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct WorkingFile {
|
struct WorkingFile {
|
||||||
|
Loading…
Reference in New Issue
Block a user