mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-23 08:05:07 +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
2d00b62f63
commit
008b1762c1
@ -470,6 +470,9 @@ void *DiagnosticMain(void *manager_) {
|
||||
BuildCompilerInvocation(session->file.args, FS);
|
||||
if (!CI)
|
||||
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->getLangOpts()->SpellChecking = g_config->diagnostics.spellChecking;
|
||||
StoreDiags DC(path);
|
||||
|
@ -513,11 +513,12 @@ public:
|
||||
// e.g. operator type-parameter-1
|
||||
i = 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);
|
||||
def.short_name_offset = i + qualified.size() - short_name.size();
|
||||
} else {
|
||||
def.short_name_offset = i;
|
||||
}
|
||||
def.short_name_size = short_name.size();
|
||||
for (int paren = 0; i; i--) {
|
||||
@ -538,7 +539,7 @@ public:
|
||||
std::string_view qualified, IndexVar::Def &def) {
|
||||
QualType T;
|
||||
const Expr *init = nullptr;
|
||||
bool binding = false;
|
||||
bool deduced = false;
|
||||
if (auto *VD = dyn_cast<VarDecl>(D)) {
|
||||
T = VD->getType();
|
||||
init = VD->getAnyInitializer();
|
||||
@ -548,9 +549,21 @@ public:
|
||||
init = FD->getInClassInitializer();
|
||||
} else if (auto *BD = dyn_cast<BindingDecl>(D)) {
|
||||
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;
|
||||
llvm::raw_svector_ostream OS(Str);
|
||||
PrintingPolicy PP = GetDefaultPolicy();
|
||||
@ -657,7 +670,11 @@ public:
|
||||
|
||||
public:
|
||||
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,
|
||||
ArrayRef<index::SymbolRelation> Relations,
|
||||
#if LLVM_VERSION_MAJOR >= 7
|
||||
|
Loading…
Reference in New Issue
Block a user