mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-23 16:15:07 +00:00
Simplify
This commit is contained in:
parent
5dcccea285
commit
df72a9eb72
@ -8,8 +8,6 @@
|
||||
#include "threaded_queue.h"
|
||||
#include "working_files.h"
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
@ -1,30 +1,14 @@
|
||||
#include "clang_utils.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "filesystem.hh"
|
||||
#include "platform.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <clang/AST/Type.h>
|
||||
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)) {
|
||||
|
@ -1,19 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "lsp_diagnostic.h"
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
#include <clang/Basic/FileManager.h>
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// 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);
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "serializer.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
#include <clang/Basic/FileManager.h>
|
||||
|
||||
#include <mutex>
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "serializer.h"
|
||||
using ccls::Intern;
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
#include <clang/AST/AST.h>
|
||||
#include <clang/Frontend/ASTUnit.h>
|
||||
#include <clang/Frontend/CompilerInstance.h>
|
||||
@ -777,7 +778,7 @@ public:
|
||||
}
|
||||
[[fallthrough]];
|
||||
case Decl::Record: {
|
||||
auto *RD = cast<RecordDecl>(OrigD);
|
||||
auto *RD = cast<RecordDecl>(D);
|
||||
// spec has no Union, use Class
|
||||
type->def.kind = RD->getTagKind() == TTK_Struct ? lsSymbolKind::Struct
|
||||
: lsSymbolKind::Class;
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "serializer.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <llvm/Config/llvm-config.h>
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/prettywriter.h>
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
@ -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",
|
||||
|
@ -3,10 +3,8 @@
|
||||
#include "lsp_diagnostic.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
#include <optional>
|
||||
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
struct WorkingFile {
|
||||
|
Loading…
Reference in New Issue
Block a user