mirror of
https://github.com/MaskRay/ccls.git
synced 2025-12-19 13:42:08 +00:00
Compare commits
4 Commits
37c68e4e7b
...
e097bd6ffd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e097bd6ffd | ||
|
|
3799e38920 | ||
|
|
5d401fc95d | ||
|
|
e55cc6865c |
@ -377,10 +377,17 @@ const Decl *getAdjustedDecl(const Decl *d) {
|
|||||||
if (!s->isExplicitSpecialization()) {
|
if (!s->isExplicitSpecialization()) {
|
||||||
llvm::PointerUnion<ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl *> result =
|
llvm::PointerUnion<ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl *> result =
|
||||||
s->getSpecializedTemplateOrPartial();
|
s->getSpecializedTemplateOrPartial();
|
||||||
if (result.is<ClassTemplateDecl *>())
|
#if LLVM_VERSION_MAJOR >= 21
|
||||||
|
if (auto *ctd = dyn_cast<ClassTemplateDecl *>(result))
|
||||||
|
d = ctd;
|
||||||
|
else
|
||||||
|
d = cast<ClassTemplatePartialSpecializationDecl *>(result);
|
||||||
|
#else
|
||||||
|
if (isa<ClassTemplateDecl *>(result))
|
||||||
d = result.get<ClassTemplateDecl *>();
|
d = result.get<ClassTemplateDecl *>();
|
||||||
else
|
else
|
||||||
d = result.get<ClassTemplatePartialSpecializationDecl *>();
|
d = result.get<ClassTemplatePartialSpecializationDecl *>();
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (auto *d1 = r->getInstantiatedFromMemberClass()) {
|
} else if (auto *d1 = r->getInstantiatedFromMemberClass()) {
|
||||||
@ -964,10 +971,17 @@ public:
|
|||||||
else if (auto *sd = dyn_cast<ClassTemplateSpecializationDecl>(rd)) {
|
else if (auto *sd = dyn_cast<ClassTemplateSpecializationDecl>(rd)) {
|
||||||
llvm::PointerUnion<ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl *> result =
|
llvm::PointerUnion<ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl *> result =
|
||||||
sd->getSpecializedTemplateOrPartial();
|
sd->getSpecializedTemplateOrPartial();
|
||||||
|
#if LLVM_VERSION_MAJOR >= 21
|
||||||
|
if (auto *ctd = dyn_cast<ClassTemplateDecl *>(result))
|
||||||
|
d1 = ctd;
|
||||||
|
else
|
||||||
|
d1 = cast<ClassTemplatePartialSpecializationDecl *>(result);
|
||||||
|
#else
|
||||||
if (result.is<ClassTemplateDecl *>())
|
if (result.is<ClassTemplateDecl *>())
|
||||||
d1 = result.get<ClassTemplateDecl *>();
|
d1 = result.get<ClassTemplateDecl *>();
|
||||||
else
|
else
|
||||||
d1 = result.get<ClassTemplatePartialSpecializationDecl *>();
|
d1 = result.get<ClassTemplatePartialSpecializationDecl *>();
|
||||||
|
#endif
|
||||||
|
|
||||||
} else
|
} else
|
||||||
d1 = rd->getInstantiatedFromMemberClass();
|
d1 = rd->getInstantiatedFromMemberClass();
|
||||||
@ -1241,15 +1255,23 @@ IndexResult index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs, const st
|
|||||||
}
|
}
|
||||||
|
|
||||||
IndexDiags dc;
|
IndexDiags dc;
|
||||||
|
#if LLVM_VERSION_MAJOR >= 21
|
||||||
|
auto clang = std::make_unique<CompilerInstance>(std::move(ci), pch);
|
||||||
|
#else
|
||||||
auto clang = std::make_unique<CompilerInstance>(pch);
|
auto clang = std::make_unique<CompilerInstance>(pch);
|
||||||
clang->setInvocation(std::move(ci));
|
clang->setInvocation(std::move(ci));
|
||||||
|
#endif
|
||||||
clang->createDiagnostics(
|
clang->createDiagnostics(
|
||||||
#if LLVM_VERSION_MAJOR >= 20
|
#if LLVM_VERSION_MAJOR >= 20
|
||||||
*fs,
|
*fs,
|
||||||
#endif
|
#endif
|
||||||
&dc, false);
|
&dc, false);
|
||||||
clang->getDiagnostics().setIgnoreAllWarnings(true);
|
clang->getDiagnostics().setIgnoreAllWarnings(true);
|
||||||
|
#if LLVM_VERSION_MAJOR >= 21
|
||||||
|
clang->setTarget(TargetInfo::CreateTargetInfo(clang->getDiagnostics(), clang->getTargetOpts()));
|
||||||
|
#else
|
||||||
clang->setTarget(TargetInfo::CreateTargetInfo(clang->getDiagnostics(), clang->getInvocation().TargetOpts));
|
clang->setTarget(TargetInfo::CreateTargetInfo(clang->getDiagnostics(), clang->getInvocation().TargetOpts));
|
||||||
|
#endif
|
||||||
if (!clang->hasTarget())
|
if (!clang->hasTarget())
|
||||||
return {};
|
return {};
|
||||||
clang->getPreprocessorOpts().RetainRemappedFileBuffers = true;
|
clang->getPreprocessorOpts().RetainRemappedFileBuffers = true;
|
||||||
|
|||||||
@ -296,7 +296,7 @@ private:
|
|||||||
void textDocument_signatureHelp(TextDocumentPositionParam &, ReplyOnce &);
|
void textDocument_signatureHelp(TextDocumentPositionParam &, ReplyOnce &);
|
||||||
void textDocument_switchSourceHeader(TextDocumentIdentifier &, ReplyOnce &);
|
void textDocument_switchSourceHeader(TextDocumentIdentifier &, ReplyOnce &);
|
||||||
void textDocument_typeDefinition(TextDocumentPositionParam &, ReplyOnce &);
|
void textDocument_typeDefinition(TextDocumentPositionParam &, ReplyOnce &);
|
||||||
void workspace_didChangeConfiguration(EmptyParam &);
|
void workspace_didChangeConfiguration(JsonReader &);
|
||||||
void workspace_didChangeWatchedFiles(DidChangeWatchedFilesParam &);
|
void workspace_didChangeWatchedFiles(DidChangeWatchedFilesParam &);
|
||||||
void workspace_didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParam &);
|
void workspace_didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParam &);
|
||||||
void workspace_executeCommand(JsonReader &, ReplyOnce &);
|
void workspace_executeCommand(JsonReader &, ReplyOnce &);
|
||||||
|
|||||||
@ -13,6 +13,9 @@
|
|||||||
#include <llvm/ADT/StringRef.h>
|
#include <llvm/ADT/StringRef.h>
|
||||||
#include <llvm/Support/Path.h>
|
#include <llvm/Support/Path.h>
|
||||||
|
|
||||||
|
#include <rapidjson/document.h>
|
||||||
|
#include <rapidjson/writer.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -22,13 +25,31 @@ using namespace llvm;
|
|||||||
namespace ccls {
|
namespace ccls {
|
||||||
REFLECT_STRUCT(SymbolInformation, name, kind, location, containerName);
|
REFLECT_STRUCT(SymbolInformation, name, kind, location, containerName);
|
||||||
|
|
||||||
void MessageHandler::workspace_didChangeConfiguration(EmptyParam &) {
|
void MessageHandler::workspace_didChangeConfiguration(JsonReader &reader) {
|
||||||
|
auto it = reader.m->FindMember("settings");
|
||||||
|
if (!(it != reader.m->MemberEnd() && it->value.IsObject()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Similar to MessageHandler::initialize.
|
||||||
|
rapidjson::StringBuffer output;
|
||||||
|
rapidjson::Writer<rapidjson::StringBuffer> writer(output);
|
||||||
|
JsonReader m1(&it->value);
|
||||||
|
it->value.Accept(writer);
|
||||||
|
LOG_S(INFO) << "didChangeConfiguration: " << output.GetString();
|
||||||
|
try {
|
||||||
|
reflect(m1, *g_config);
|
||||||
|
} catch (std::invalid_argument &) {
|
||||||
|
reader.path_.push_back("settings");
|
||||||
|
reader.path_.insert(reader.path_.end(), m1.path_.begin(), m1.path_.end());
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &[folder, _] : g_config->workspaceFolders)
|
for (auto &[folder, _] : g_config->workspaceFolders)
|
||||||
project->load(folder);
|
project->load(folder);
|
||||||
project->index(wfiles, RequestId());
|
project->index(wfiles, RequestId());
|
||||||
|
|
||||||
manager->clear();
|
manager->clear();
|
||||||
};
|
}
|
||||||
|
|
||||||
void MessageHandler::workspace_didChangeWatchedFiles(DidChangeWatchedFilesParam ¶m) {
|
void MessageHandler::workspace_didChangeWatchedFiles(DidChangeWatchedFilesParam ¶m) {
|
||||||
for (auto &event : param.changes) {
|
for (auto &event : param.changes) {
|
||||||
|
|||||||
@ -261,14 +261,22 @@ std::unique_ptr<CompilerInstance> buildCompilerInstance(Session &session, std::u
|
|||||||
else
|
else
|
||||||
ci->getPreprocessorOpts().addRemappedFile(main, buf.get());
|
ci->getPreprocessorOpts().addRemappedFile(main, buf.get());
|
||||||
|
|
||||||
|
#if LLVM_VERSION_MAJOR >= 21
|
||||||
|
auto clang = std::make_unique<CompilerInstance>(std::move(ci), session.pch);
|
||||||
|
#else
|
||||||
auto clang = std::make_unique<CompilerInstance>(session.pch);
|
auto clang = std::make_unique<CompilerInstance>(session.pch);
|
||||||
clang->setInvocation(std::move(ci));
|
clang->setInvocation(std::move(ci));
|
||||||
|
#endif
|
||||||
clang->createDiagnostics(
|
clang->createDiagnostics(
|
||||||
#if LLVM_VERSION_MAJOR >= 20
|
#if LLVM_VERSION_MAJOR >= 20
|
||||||
*fs,
|
*fs,
|
||||||
#endif
|
#endif
|
||||||
&dc, false);
|
&dc, false);
|
||||||
|
#if LLVM_VERSION_MAJOR >= 21
|
||||||
|
clang->setTarget(TargetInfo::CreateTargetInfo(clang->getDiagnostics(), clang->getTargetOpts()));
|
||||||
|
#else
|
||||||
clang->setTarget(TargetInfo::CreateTargetInfo(clang->getDiagnostics(), clang->getInvocation().TargetOpts));
|
clang->setTarget(TargetInfo::CreateTargetInfo(clang->getDiagnostics(), clang->getInvocation().TargetOpts));
|
||||||
|
#endif
|
||||||
if (!clang->hasTarget())
|
if (!clang->hasTarget())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
clang->getPreprocessorOpts().RetainRemappedFileBuffers = true;
|
clang->getPreprocessorOpts().RetainRemappedFileBuffers = true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user