mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 09:05:10 +00:00
indexer: handle DecltypeType and empty main file; diag: -Wno-unused-function for headers
Don't replace name with qualified name in Cls::*name
This commit is contained in:
parent
e27a5eaff9
commit
8f442c6c35
@ -470,6 +470,9 @@ void *DiagnosticMain(void *manager_) {
|
|||||||
BuildCompilerInvocation(session->file.args, FS);
|
BuildCompilerInvocation(session->file.args, FS);
|
||||||
if (!CI)
|
if (!CI)
|
||||||
continue;
|
continue;
|
||||||
|
// If main file is a header, add -Wno-unused-function
|
||||||
|
if (lookupExtension(session->file.filename).second)
|
||||||
|
CI->getDiagnosticOpts().Warnings.push_back("no-unused-function");
|
||||||
CI->getDiagnosticOpts().IgnoreWarnings = false;
|
CI->getDiagnosticOpts().IgnoreWarnings = false;
|
||||||
CI->getLangOpts()->SpellChecking = g_config->diagnostics.spellChecking;
|
CI->getLangOpts()->SpellChecking = g_config->diagnostics.spellChecking;
|
||||||
StoreDiags DC(path);
|
StoreDiags DC(path);
|
||||||
|
@ -513,11 +513,12 @@ public:
|
|||||||
// e.g. operator type-parameter-1
|
// e.g. operator type-parameter-1
|
||||||
i = 0;
|
i = 0;
|
||||||
def.short_name_offset = 0;
|
def.short_name_offset = 0;
|
||||||
} else if (short_name.size() && (!i || name[i - 1] != ':')) {
|
} else if (short_name.empty() || (i >= 2 && name[i - 2] == ':')) {
|
||||||
|
// Don't replace name with qualified name in ns::name Cls::*name
|
||||||
|
def.short_name_offset = i;
|
||||||
|
} else {
|
||||||
name.replace(i, short_name.size(), qualified);
|
name.replace(i, short_name.size(), qualified);
|
||||||
def.short_name_offset = i + qualified.size() - short_name.size();
|
def.short_name_offset = i + qualified.size() - short_name.size();
|
||||||
} else {
|
|
||||||
def.short_name_offset = i;
|
|
||||||
}
|
}
|
||||||
def.short_name_size = short_name.size();
|
def.short_name_size = short_name.size();
|
||||||
for (int paren = 0; i; i--) {
|
for (int paren = 0; i; i--) {
|
||||||
@ -538,7 +539,7 @@ public:
|
|||||||
std::string_view qualified, IndexVar::Def &def) {
|
std::string_view qualified, IndexVar::Def &def) {
|
||||||
QualType T;
|
QualType T;
|
||||||
const Expr *init = nullptr;
|
const Expr *init = nullptr;
|
||||||
bool binding = false;
|
bool deduced = false;
|
||||||
if (auto *VD = dyn_cast<VarDecl>(D)) {
|
if (auto *VD = dyn_cast<VarDecl>(D)) {
|
||||||
T = VD->getType();
|
T = VD->getType();
|
||||||
init = VD->getAnyInitializer();
|
init = VD->getAnyInitializer();
|
||||||
@ -548,9 +549,21 @@ public:
|
|||||||
init = FD->getInClassInitializer();
|
init = FD->getInClassInitializer();
|
||||||
} else if (auto *BD = dyn_cast<BindingDecl>(D)) {
|
} else if (auto *BD = dyn_cast<BindingDecl>(D)) {
|
||||||
T = BD->getType();
|
T = BD->getType();
|
||||||
binding = true;
|
deduced = true;
|
||||||
}
|
}
|
||||||
if (!T.isNull() && (binding || T->getContainedDeducedType())) {
|
if (!T.isNull()) {
|
||||||
|
if (T->getContainedDeducedType()) {
|
||||||
|
deduced = true;
|
||||||
|
} else if (auto *DT = dyn_cast<DecltypeType>(T)) {
|
||||||
|
// decltype(y) x;
|
||||||
|
while (DT && !DT->getUnderlyingType().isNull()) {
|
||||||
|
T = DT->getUnderlyingType();
|
||||||
|
DT = dyn_cast<DecltypeType>(T);
|
||||||
|
}
|
||||||
|
deduced = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!T.isNull() && deduced) {
|
||||||
SmallString<256> Str;
|
SmallString<256> Str;
|
||||||
llvm::raw_svector_ostream OS(Str);
|
llvm::raw_svector_ostream OS(Str);
|
||||||
PrintingPolicy PP = GetDefaultPolicy();
|
PrintingPolicy PP = GetDefaultPolicy();
|
||||||
@ -657,7 +670,11 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
IndexDataConsumer(IndexParam ¶m) : param(param) {}
|
IndexDataConsumer(IndexParam ¶m) : param(param) {}
|
||||||
void initialize(ASTContext &Ctx) override { this->Ctx = param.Ctx = &Ctx; }
|
void initialize(ASTContext &Ctx) override {
|
||||||
|
this->Ctx = param.Ctx = &Ctx;
|
||||||
|
SourceManager &SM = Ctx.getSourceManager();
|
||||||
|
(void)param.ConsumeFile(*SM.getFileEntryForID(SM.getMainFileID()));
|
||||||
|
}
|
||||||
bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
|
bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
|
||||||
ArrayRef<index::SymbolRelation> Relations,
|
ArrayRef<index::SymbolRelation> Relations,
|
||||||
#if LLVM_VERSION_MAJOR >= 7
|
#if LLVM_VERSION_MAJOR >= 7
|
||||||
|
Loading…
Reference in New Issue
Block a user