mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 11:01:57 +00:00
Fix .. in compdb path; better type alias
This commit is contained in:
parent
1830103ec6
commit
9b9bf1cd19
@ -65,6 +65,15 @@ OUTPUT:
|
|||||||
"types": [],
|
"types": [],
|
||||||
"funcs": [],
|
"funcs": [],
|
||||||
"vars": [{
|
"vars": [{
|
||||||
|
"L": 3348817847649945564,
|
||||||
|
"R": -1
|
||||||
|
}, {
|
||||||
|
"L": 4821094820988543895,
|
||||||
|
"R": -1
|
||||||
|
}, {
|
||||||
|
"L": 15292551660437765731,
|
||||||
|
"R": -1
|
||||||
|
}, {
|
||||||
"L": 1963212417280098348,
|
"L": 1963212417280098348,
|
||||||
"R": 0
|
"R": 0
|
||||||
}],
|
}],
|
||||||
|
@ -401,12 +401,9 @@ std::unique_ptr<ClangTranslationUnit> ClangTranslationUnit::Create(
|
|||||||
std::unique_ptr<ClangTranslationUnit> ClangTranslationUnit::Reparse(
|
std::unique_ptr<ClangTranslationUnit> ClangTranslationUnit::Reparse(
|
||||||
std::unique_ptr<ClangTranslationUnit> tu,
|
std::unique_ptr<ClangTranslationUnit> tu,
|
||||||
std::vector<CXUnsavedFile>& unsaved) {
|
std::vector<CXUnsavedFile>& unsaved) {
|
||||||
int error_code;
|
int error_code = clang_reparseTranslationUnit(
|
||||||
{
|
|
||||||
error_code = clang_reparseTranslationUnit(
|
|
||||||
tu->cx_tu, (unsigned)unsaved.size(), unsaved.data(),
|
tu->cx_tu, (unsigned)unsaved.size(), unsaved.data(),
|
||||||
clang_defaultReparseOptions(tu->cx_tu));
|
clang_defaultReparseOptions(tu->cx_tu));
|
||||||
}
|
|
||||||
|
|
||||||
if (error_code != CXError_Success && tu->cx_tu)
|
if (error_code != CXError_Success && tu->cx_tu)
|
||||||
EmitDiagnostics("<unknown>", {}, tu->cx_tu);
|
EmitDiagnostics("<unknown>", {}, tu->cx_tu);
|
||||||
|
@ -1655,16 +1655,23 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
|
|
||||||
case CXIdxEntity_Typedef:
|
case CXIdxEntity_Typedef:
|
||||||
case CXIdxEntity_CXXTypeAlias: {
|
case CXIdxEntity_CXXTypeAlias: {
|
||||||
|
IndexType& type = db->ToType(HashUsr(decl->entityInfo->USR));
|
||||||
|
CXType Type = clang_getCursorType(decl->entityInfo->cursor);
|
||||||
|
CXType CanonType = clang_getCanonicalType(Type);;
|
||||||
|
if (clang_equalTypes(Type, CanonType) == 0) {
|
||||||
|
Usr type_usr = ClangType(CanonType).get_usr_hash();
|
||||||
|
if (db->usr2type.count(type_usr)) {
|
||||||
|
type.def.alias_of = type_usr;
|
||||||
|
} else {
|
||||||
// Note we want to fetch the first TypeRef. Running
|
// Note we want to fetch the first TypeRef. Running
|
||||||
// ResolveCursorType(decl->cursor) would return
|
// ResolveCursorType(decl->cursor) would return
|
||||||
// the type of the typedef/using, not the type of the referenced type.
|
// the type of the typedef/using, not the type of the referenced type.
|
||||||
IndexType* alias_of = AddDeclTypeUsages(
|
IndexType* alias_of = AddDeclTypeUsages(
|
||||||
db, cursor, nullptr, decl->semanticContainer, decl->lexicalContainer);
|
db, cursor, nullptr, decl->semanticContainer, decl->lexicalContainer);
|
||||||
|
|
||||||
IndexType& type = db->ToType(HashUsr(decl->entityInfo->USR));
|
|
||||||
|
|
||||||
if (alias_of)
|
if (alias_of)
|
||||||
type.def.alias_of = alias_of->usr;
|
type.def.alias_of = alias_of->usr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Range spell = cursor.get_spell();
|
Range spell = cursor.get_spell();
|
||||||
Range extent = cursor.get_extent();
|
Range extent = cursor.get_extent();
|
||||||
@ -1709,17 +1716,11 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
|
|
||||||
IndexType& type = db->ToType(HashUsr(decl->entityInfo->USR));
|
IndexType& type = db->ToType(HashUsr(decl->entityInfo->USR));
|
||||||
|
|
||||||
// TODO: Eventually run with this if. Right now I want to iron out bugs
|
|
||||||
// this may shadow.
|
|
||||||
// TODO: For type section, verify if this ever runs for non definitions?
|
|
||||||
// if (!decl->isRedeclaration) {
|
|
||||||
|
|
||||||
SetTypeName(type, cursor, decl->semanticContainer, decl->entityInfo->name,
|
SetTypeName(type, cursor, decl->semanticContainer, decl->entityInfo->name,
|
||||||
param);
|
param);
|
||||||
type.def.kind = GetSymbolKind(decl->entityInfo->kind);
|
type.def.kind = GetSymbolKind(decl->entityInfo->kind);
|
||||||
if (g_config->index.comments)
|
if (g_config->index.comments)
|
||||||
type.def.comments = Intern(cursor.get_comments());
|
type.def.comments = Intern(cursor.get_comments());
|
||||||
// }
|
|
||||||
|
|
||||||
if (decl->isDefinition) {
|
if (decl->isDefinition) {
|
||||||
type.def.spell = SetUse(db, spell, sem_parent, Role::Definition);
|
type.def.spell = SetUse(db, spell, sem_parent, Role::Definition);
|
||||||
@ -1781,12 +1782,6 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// type_def->alias_of
|
|
||||||
// type_def->funcs
|
|
||||||
// type_def->types
|
|
||||||
// type_def->uses
|
|
||||||
// type_def->vars
|
|
||||||
|
|
||||||
// Add type-level inheritance information.
|
// Add type-level inheritance information.
|
||||||
CXIdxCXXClassDeclInfo const* class_info =
|
CXIdxCXXClassDeclInfo const* class_info =
|
||||||
clang_index_getCXXClassDeclInfo(decl);
|
clang_index_getCXXClassDeclInfo(decl);
|
||||||
|
@ -94,17 +94,9 @@ bool FileNeedsParse(int64_t write_time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Command-line arguments changed.
|
// Command-line arguments changed.
|
||||||
auto is_file = [](const std::string& arg) {
|
|
||||||
return EndsWithAny(arg, {".h", ".c", ".cc", ".cpp", ".hpp", ".m", ".mm"});
|
|
||||||
};
|
|
||||||
if (opt_previous_index) {
|
if (opt_previous_index) {
|
||||||
auto& prev_args = opt_previous_index->args;
|
auto& prev_args = opt_previous_index->args;
|
||||||
bool same = prev_args.size() == args.size();
|
if (prev_args != args) {
|
||||||
for (size_t i = 0; i < args.size() && same; ++i) {
|
|
||||||
same = prev_args[i] == args[i] ||
|
|
||||||
(is_file(prev_args[i]) && is_file(args[i]));
|
|
||||||
}
|
|
||||||
if (!same) {
|
|
||||||
LOG_S(INFO) << "args changed for " << path << (from ? " (via " + *from + ")" : std::string());
|
LOG_S(INFO) << "args changed for " << path << (from ? " (via " + *from + ")" : std::string());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -483,12 +475,11 @@ void MainLoop() {
|
|||||||
Main_OnIndexed(&db, &semantic_cache, &working_files, &*update);
|
Main_OnIndexed(&db, &semantic_cache, &working_files, &*update);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup and free any unused memory.
|
if (!did_work) {
|
||||||
FreeUnusedMemory();
|
FreeUnusedMemory();
|
||||||
|
|
||||||
if (!did_work)
|
|
||||||
main_waiter->Wait(on_indexed, on_request);
|
main_waiter->Wait(on_indexed, on_request);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Index(const std::string& path,
|
void Index(const std::string& path,
|
||||||
|
@ -48,7 +48,7 @@ struct CompileCommandsEntry {
|
|||||||
return path;
|
return path;
|
||||||
SmallString<256> Ret;
|
SmallString<256> Ret;
|
||||||
sys::path::append(Ret, directory, path);
|
sys::path::append(Ret, directory, path);
|
||||||
return Ret.str();
|
return NormalizePath(Ret.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(CompileCommandsEntry, directory, file, command, args);
|
MAKE_REFLECT_STRUCT(CompileCommandsEntry, directory, file, command, args);
|
||||||
|
Loading…
Reference in New Issue
Block a user