mirror of
https://github.com/MaskRay/ccls.git
synced 2025-12-19 13:42:08 +00:00
Compare commits
5 Commits
118e926343
...
e2ad01eaa3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2ad01eaa3 | ||
|
|
5660367c77 | ||
|
|
cfc7c0208f | ||
|
|
536033c204 | ||
|
|
9a90b44b17 |
307
index_tests/templates/concept.cc
Normal file
307
index_tests/templates/concept.cc
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
|
||||||
|
template <class T> struct type_trait {
|
||||||
|
const static bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <> struct type_trait<int> {
|
||||||
|
const static bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
concept Con1 = type_trait<T>::value;
|
||||||
|
|
||||||
|
constexpr int sizeFunc() { return 4; }
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
concept ConWithLogicalAnd = Con1<T> && sizeof(T) > sizeFunc();
|
||||||
|
|
||||||
|
namespace ns {
|
||||||
|
template <class T>
|
||||||
|
concept ConInNamespace = sizeof(T) > 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T1, class T2>
|
||||||
|
concept ConTwoTemplateParams = ns::ConInNamespace<T1> && ConWithLogicalAnd<T2>;
|
||||||
|
|
||||||
|
/*
|
||||||
|
OUTPUT:
|
||||||
|
{
|
||||||
|
"includes": [],
|
||||||
|
"skipped_ranges": [],
|
||||||
|
"usr2func": [{
|
||||||
|
"usr": 3226866773869731400,
|
||||||
|
"detailed_name": "constexpr int sizeFunc()",
|
||||||
|
"qual_name_offset": 14,
|
||||||
|
"short_name": "sizeFunc",
|
||||||
|
"spell": "13:15-13:23|13:1-13:39|2|-1",
|
||||||
|
"bases": [],
|
||||||
|
"vars": [],
|
||||||
|
"callees": [],
|
||||||
|
"kind": 12,
|
||||||
|
"parent_kind": 1,
|
||||||
|
"storage": 0,
|
||||||
|
"declarations": [],
|
||||||
|
"derived": [],
|
||||||
|
"uses": ["16:52-16:60|36|-1"]
|
||||||
|
}],
|
||||||
|
"usr2type": [{
|
||||||
|
"usr": 436,
|
||||||
|
"detailed_name": "",
|
||||||
|
"qual_name_offset": 0,
|
||||||
|
"short_name": "",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 0,
|
||||||
|
"parent_kind": 0,
|
||||||
|
"declarations": [],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [3643386974125063532, 4683419091429829178],
|
||||||
|
"uses": []
|
||||||
|
}, {
|
||||||
|
"usr": 452,
|
||||||
|
"detailed_name": "",
|
||||||
|
"qual_name_offset": 0,
|
||||||
|
"short_name": "",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 0,
|
||||||
|
"parent_kind": 0,
|
||||||
|
"declarations": [],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [15611304989063975809, 15197037962155352994, 7075924720131397743, 8419381068906673567],
|
||||||
|
"uses": []
|
||||||
|
}, {
|
||||||
|
"usr": 368613743269466510,
|
||||||
|
"detailed_name": "T",
|
||||||
|
"qual_name_offset": 0,
|
||||||
|
"short_name": "",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 26,
|
||||||
|
"parent_kind": 0,
|
||||||
|
"declarations": ["19:17-19:18|19:11-19:18|1025|-1"],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [],
|
||||||
|
"uses": ["20:33-20:34|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 1341599025369786548,
|
||||||
|
"detailed_name": "T1",
|
||||||
|
"qual_name_offset": 0,
|
||||||
|
"short_name": "",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 26,
|
||||||
|
"parent_kind": 0,
|
||||||
|
"declarations": ["23:17-23:19|23:11-23:19|1|-1"],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [],
|
||||||
|
"uses": ["24:51-24:53|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 1789177110200181456,
|
||||||
|
"detailed_name": "T",
|
||||||
|
"qual_name_offset": 0,
|
||||||
|
"short_name": "",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 26,
|
||||||
|
"parent_kind": 0,
|
||||||
|
"declarations": ["15:17-15:18|15:11-15:18|1|-1"],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [],
|
||||||
|
"uses": ["16:34-16:35|4|-1", "16:47-16:48|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 4001289545226345448,
|
||||||
|
"detailed_name": "struct type_trait {}",
|
||||||
|
"qual_name_offset": 7,
|
||||||
|
"short_name": "type_trait",
|
||||||
|
"spell": "2:27-2:37|2:20-4:2|2|-1",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [13813325012676356715],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 23,
|
||||||
|
"parent_kind": 1,
|
||||||
|
"declarations": [],
|
||||||
|
"derived": [10139416838611429657],
|
||||||
|
"instances": [],
|
||||||
|
"uses": ["11:16-11:26|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 8987540007709901036,
|
||||||
|
"detailed_name": "T",
|
||||||
|
"qual_name_offset": 0,
|
||||||
|
"short_name": "",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 26,
|
||||||
|
"parent_kind": 0,
|
||||||
|
"declarations": ["10:17-10:18|10:11-10:18|1|-1"],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [],
|
||||||
|
"uses": ["11:27-11:28|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 10139416838611429657,
|
||||||
|
"detailed_name": "template<> struct type_trait<int> {}",
|
||||||
|
"qual_name_offset": 18,
|
||||||
|
"short_name": "type_trait",
|
||||||
|
"spell": "6:20-6:30|6:1-8:2|2|-1",
|
||||||
|
"bases": [4001289545226345448],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 5,
|
||||||
|
"parent_kind": 1,
|
||||||
|
"declarations": [],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [],
|
||||||
|
"uses": []
|
||||||
|
}, {
|
||||||
|
"usr": 10306412732558468540,
|
||||||
|
"detailed_name": "T2",
|
||||||
|
"qual_name_offset": 0,
|
||||||
|
"short_name": "",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 26,
|
||||||
|
"parent_kind": 0,
|
||||||
|
"declarations": ["23:27-23:29|23:21-23:29|1|-1"],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [],
|
||||||
|
"uses": ["24:76-24:78|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 11072669167287398027,
|
||||||
|
"detailed_name": "namespace ns {}",
|
||||||
|
"qual_name_offset": 10,
|
||||||
|
"short_name": "ns",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [368613743269466510],
|
||||||
|
"vars": [{
|
||||||
|
"L": 7075924720131397743,
|
||||||
|
"R": -1
|
||||||
|
}],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 3,
|
||||||
|
"parent_kind": 0,
|
||||||
|
"declarations": ["18:11-18:13|18:1-21:2|1|-1"],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [],
|
||||||
|
"uses": ["24:32-24:34|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 13813325012676356715,
|
||||||
|
"detailed_name": "T",
|
||||||
|
"qual_name_offset": 0,
|
||||||
|
"short_name": "",
|
||||||
|
"bases": [],
|
||||||
|
"funcs": [],
|
||||||
|
"types": [],
|
||||||
|
"vars": [],
|
||||||
|
"alias_of": 0,
|
||||||
|
"kind": 26,
|
||||||
|
"parent_kind": 0,
|
||||||
|
"declarations": ["2:17-2:18|2:11-2:18|1025|-1"],
|
||||||
|
"derived": [],
|
||||||
|
"instances": [],
|
||||||
|
"uses": []
|
||||||
|
}],
|
||||||
|
"usr2var": [{
|
||||||
|
"usr": 3643386974125063532,
|
||||||
|
"detailed_name": "static const bool type_trait::value",
|
||||||
|
"qual_name_offset": 18,
|
||||||
|
"short_name": "value",
|
||||||
|
"hover": "static const bool type_trait::value = false",
|
||||||
|
"type": 436,
|
||||||
|
"kind": 8,
|
||||||
|
"parent_kind": 23,
|
||||||
|
"storage": 2,
|
||||||
|
"declarations": ["3:21-3:26|3:3-3:34|1025|-1"],
|
||||||
|
"uses": ["11:31-11:36|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 4683419091429829178,
|
||||||
|
"detailed_name": "static const bool type_trait<int>::value",
|
||||||
|
"qual_name_offset": 18,
|
||||||
|
"short_name": "value",
|
||||||
|
"hover": "static const bool type_trait<int>::value = true",
|
||||||
|
"type": 436,
|
||||||
|
"kind": 8,
|
||||||
|
"parent_kind": 5,
|
||||||
|
"storage": 2,
|
||||||
|
"declarations": ["7:21-7:26|7:3-7:33|1025|-1"],
|
||||||
|
"uses": []
|
||||||
|
}, {
|
||||||
|
"usr": 7075924720131397743,
|
||||||
|
"detailed_name": "int ns::ConInNamespace",
|
||||||
|
"qual_name_offset": 4,
|
||||||
|
"short_name": "ConInNamespace",
|
||||||
|
"hover": "int ns::ConInNamespace = sizeof(T) > 4",
|
||||||
|
"spell": "20:9-20:23|20:1-20:39|1026|-1",
|
||||||
|
"type": 452,
|
||||||
|
"kind": 13,
|
||||||
|
"parent_kind": 3,
|
||||||
|
"storage": 0,
|
||||||
|
"declarations": [],
|
||||||
|
"uses": ["24:36-24:50|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 8419381068906673567,
|
||||||
|
"detailed_name": "int ConTwoTemplateParams",
|
||||||
|
"qual_name_offset": 4,
|
||||||
|
"short_name": "ConTwoTemplateParams",
|
||||||
|
"hover": "int ConTwoTemplateParams = ns::ConInNamespace<T1> && ConWithLogicalAnd<T2>",
|
||||||
|
"spell": "24:9-24:29|24:1-24:79|2|-1",
|
||||||
|
"type": 452,
|
||||||
|
"kind": 13,
|
||||||
|
"parent_kind": 1,
|
||||||
|
"storage": 0,
|
||||||
|
"declarations": [],
|
||||||
|
"uses": []
|
||||||
|
}, {
|
||||||
|
"usr": 15197037962155352994,
|
||||||
|
"detailed_name": "int ConWithLogicalAnd",
|
||||||
|
"qual_name_offset": 4,
|
||||||
|
"short_name": "ConWithLogicalAnd",
|
||||||
|
"hover": "int ConWithLogicalAnd = Con1<T> && sizeof(T) > sizeFunc()",
|
||||||
|
"spell": "16:9-16:26|16:1-16:62|2|-1",
|
||||||
|
"type": 452,
|
||||||
|
"kind": 13,
|
||||||
|
"parent_kind": 1,
|
||||||
|
"storage": 0,
|
||||||
|
"declarations": [],
|
||||||
|
"uses": ["24:58-24:75|4|-1"]
|
||||||
|
}, {
|
||||||
|
"usr": 15611304989063975809,
|
||||||
|
"detailed_name": "int Con1",
|
||||||
|
"qual_name_offset": 4,
|
||||||
|
"short_name": "Con1",
|
||||||
|
"hover": "int Con1 = type_trait<T>::value",
|
||||||
|
"spell": "11:9-11:13|11:1-11:36|2|-1",
|
||||||
|
"type": 452,
|
||||||
|
"kind": 13,
|
||||||
|
"parent_kind": 1,
|
||||||
|
"storage": 0,
|
||||||
|
"declarations": [],
|
||||||
|
"uses": ["16:29-16:33|4|-1"]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
*/
|
||||||
@ -88,7 +88,11 @@ struct Config {
|
|||||||
// ["-fopenmp", "-m*", "-Wall"].
|
// ["-fopenmp", "-m*", "-Wall"].
|
||||||
std::vector<std::string> excludeArgs;
|
std::vector<std::string> excludeArgs;
|
||||||
|
|
||||||
// Additional arguments to pass to clang.
|
// Arguments to be inserted after the compiler driver name. These serve as default arguments that can be overridden
|
||||||
|
// by user-provided arguments.
|
||||||
|
std::vector<std::string> prependArgs;
|
||||||
|
|
||||||
|
// Additional arguments to be appended at the end of the argument list.
|
||||||
std::vector<std::string> extraArgs;
|
std::vector<std::string> extraArgs;
|
||||||
|
|
||||||
// Translate absolute paths in compile_commands.json entries, .ccls options
|
// Translate absolute paths in compile_commands.json entries, .ccls options
|
||||||
@ -329,7 +333,7 @@ REFLECT_STRUCT(Config::ServerCap::DocumentOnTypeFormattingOptions, firstTriggerC
|
|||||||
REFLECT_STRUCT(Config::ServerCap::Workspace::WorkspaceFolders, supported, changeNotifications);
|
REFLECT_STRUCT(Config::ServerCap::Workspace::WorkspaceFolders, supported, changeNotifications);
|
||||||
REFLECT_STRUCT(Config::ServerCap::Workspace, workspaceFolders);
|
REFLECT_STRUCT(Config::ServerCap::Workspace, workspaceFolders);
|
||||||
REFLECT_STRUCT(Config::ServerCap, documentOnTypeFormattingProvider, foldingRangeProvider, workspace);
|
REFLECT_STRUCT(Config::ServerCap, documentOnTypeFormattingProvider, foldingRangeProvider, workspace);
|
||||||
REFLECT_STRUCT(Config::Clang, excludeArgs, extraArgs, pathMappings, resourceDir);
|
REFLECT_STRUCT(Config::Clang, excludeArgs, prependArgs, extraArgs, pathMappings, resourceDir);
|
||||||
REFLECT_STRUCT(Config::ClientCapability, diagnosticsRelatedInformation, hierarchicalDocumentSymbolSupport, linkSupport,
|
REFLECT_STRUCT(Config::ClientCapability, diagnosticsRelatedInformation, hierarchicalDocumentSymbolSupport, linkSupport,
|
||||||
snippetSupport);
|
snippetSupport);
|
||||||
REFLECT_STRUCT(Config::CodeLens, localVariables);
|
REFLECT_STRUCT(Config::CodeLens, localVariables);
|
||||||
|
|||||||
@ -127,6 +127,7 @@ Kind getKind(const Decl *d, SymbolKind &kind) {
|
|||||||
case Decl::NamespaceAlias:
|
case Decl::NamespaceAlias:
|
||||||
kind = SymbolKind::Namespace;
|
kind = SymbolKind::Namespace;
|
||||||
return Kind::Type;
|
return Kind::Type;
|
||||||
|
case Decl::Concept:
|
||||||
case Decl::ObjCCategory:
|
case Decl::ObjCCategory:
|
||||||
case Decl::ObjCCategoryImpl:
|
case Decl::ObjCCategoryImpl:
|
||||||
case Decl::ObjCImplementation:
|
case Decl::ObjCImplementation:
|
||||||
@ -333,7 +334,11 @@ try_again:
|
|||||||
break;
|
break;
|
||||||
case Type::Record:
|
case Type::Record:
|
||||||
case Type::Enum:
|
case Type::Enum:
|
||||||
|
#if LLVM_VERSION_MAJOR >= 22 // llvmorg-22-init-3166-g91cdd35008e9
|
||||||
|
d = cast<TagType>(tp)->getOriginalDecl();
|
||||||
|
#else
|
||||||
d = cast<TagType>(tp)->getDecl();
|
d = cast<TagType>(tp)->getDecl();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case Type::TemplateTypeParm:
|
case Type::TemplateTypeParm:
|
||||||
d = cast<TemplateTypeParmType>(tp)->getDecl();
|
d = cast<TemplateTypeParmType>(tp)->getDecl();
|
||||||
@ -341,10 +346,15 @@ try_again:
|
|||||||
case Type::TemplateSpecialization:
|
case Type::TemplateSpecialization:
|
||||||
if (specialization)
|
if (specialization)
|
||||||
*specialization = true;
|
*specialization = true;
|
||||||
if (const RecordType *record = tp->getAs<RecordType>())
|
if (const RecordType *record = tp->getAs<RecordType>()) {
|
||||||
|
#if LLVM_VERSION_MAJOR >= 22 // llvmorg-22-init-3166-g91cdd35008e9
|
||||||
|
d = record->getOriginalDecl();
|
||||||
|
#else
|
||||||
d = record->getDecl();
|
d = record->getDecl();
|
||||||
else
|
#endif
|
||||||
|
} else {
|
||||||
d = cast<TemplateSpecializationType>(tp)->getTemplateName().getAsTemplateDecl();
|
d = cast<TemplateSpecializationType>(tp)->getTemplateName().getAsTemplateDecl();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Type::Auto:
|
case Type::Auto:
|
||||||
@ -355,14 +365,20 @@ try_again:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Type::InjectedClassName:
|
case Type::InjectedClassName:
|
||||||
|
#if LLVM_VERSION_MAJOR >= 22 // llvmorg-22-init-3166-g91cdd35008e9
|
||||||
|
d = cast<InjectedClassNameType>(tp)->getOriginalDecl();
|
||||||
|
#else
|
||||||
d = cast<InjectedClassNameType>(tp)->getDecl();
|
d = cast<InjectedClassNameType>(tp)->getDecl();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// FIXME: Template type parameters!
|
// FIXME: Template type parameters!
|
||||||
|
|
||||||
|
#if LLVM_VERSION_MAJOR < 22 // llvmorg-22-init-3166-g91cdd35008e9
|
||||||
case Type::Elaborated:
|
case Type::Elaborated:
|
||||||
tp = cast<ElaboratedType>(tp)->getNamedType().getTypePtrOrNull();
|
tp = cast<ElaboratedType>(tp)->getNamedType().getTypePtrOrNull();
|
||||||
goto try_again;
|
goto try_again;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -411,7 +427,11 @@ bool validateRecord(const RecordDecl *rd) {
|
|||||||
if (fqt->isIncompleteType() || fqt->isDependentType())
|
if (fqt->isIncompleteType() || fqt->isDependentType())
|
||||||
return false;
|
return false;
|
||||||
if (const RecordType *childType = i->getType()->getAs<RecordType>())
|
if (const RecordType *childType = i->getType()->getAs<RecordType>())
|
||||||
|
#if LLVM_VERSION_MAJOR >= 22 // llvmorg-22-init-3166-g91cdd35008e9
|
||||||
|
if (const RecordDecl *child = childType->getOriginalDecl())
|
||||||
|
#else
|
||||||
if (const RecordDecl *child = childType->getDecl())
|
if (const RecordDecl *child = childType->getDecl())
|
||||||
|
#endif
|
||||||
if (!validateRecord(child))
|
if (!validateRecord(child))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -685,7 +705,11 @@ public:
|
|||||||
if (fd->getIdentifier())
|
if (fd->getIdentifier())
|
||||||
type.def.vars.emplace_back(getUsr(fd), offset1);
|
type.def.vars.emplace_back(getUsr(fd), offset1);
|
||||||
else if (const auto *rt1 = fd->getType()->getAs<RecordType>()) {
|
else if (const auto *rt1 = fd->getType()->getAs<RecordType>()) {
|
||||||
|
#if LLVM_VERSION_MAJOR >= 22 // llvmorg-22-init-3166-g91cdd35008e9
|
||||||
|
if (const RecordDecl *rd1 = rt1->getOriginalDecl())
|
||||||
|
#else
|
||||||
if (const RecordDecl *rd1 = rt1->getDecl())
|
if (const RecordDecl *rd1 = rt1->getDecl())
|
||||||
|
#endif
|
||||||
if (seen.insert(rd1).second)
|
if (seen.insert(rd1).second)
|
||||||
stack.push_back({rd1, offset1});
|
stack.push_back({rd1, offset1});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -323,6 +323,9 @@ void Project::loadDirectory(const std::string &root, Project::Folder &folder) {
|
|||||||
rmdir(cdbDir.c_str());
|
rmdir(cdbDir.c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#if LLVM_VERSION_MAJOR >= 10
|
||||||
|
cdb = tooling::expandResponseFiles(std::move(cdb), vfs::getRealFileSystem());
|
||||||
|
#endif
|
||||||
|
|
||||||
ProjectProcessor proc(folder);
|
ProjectProcessor proc(folder);
|
||||||
StringSet<> seen;
|
StringSet<> seen;
|
||||||
@ -490,14 +493,22 @@ Project::Entry Project::findEntry(const std::string &path, bool can_redirect, bo
|
|||||||
for (const std::string &arg : g_config->clang.extraArgs)
|
for (const std::string &arg : g_config->clang.extraArgs)
|
||||||
ret.args.push_back(intern(arg));
|
ret.args.push_back(intern(arg));
|
||||||
ret.args.push_back(intern("-working-directory=" + ret.directory));
|
ret.args.push_back(intern("-working-directory=" + ret.directory));
|
||||||
|
if (g_config->clang.prependArgs.size()) {
|
||||||
|
std::vector<const char *> args;
|
||||||
|
for (StringRef arg : g_config->clang.prependArgs)
|
||||||
|
args.push_back(intern(arg));
|
||||||
|
ret.args.insert(ret.args.begin() + 1, args.begin(), args.end());
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::index(WorkingFiles *wfiles, const RequestId &id) {
|
void Project::index(WorkingFiles *wfiles, const RequestId &id) {
|
||||||
auto &gi = g_config->index;
|
auto &gi = g_config->index;
|
||||||
GroupMatch match(gi.whitelist, gi.blacklist), match_i(gi.initialWhitelist, gi.initialBlacklist);
|
GroupMatch match(gi.whitelist, gi.blacklist), match_i(gi.initialWhitelist, gi.initialBlacklist);
|
||||||
std::vector<const char *> args, extra_args;
|
std::vector<const char *> args, prepend_args, extra_args;
|
||||||
for (const std::string &arg : g_config->clang.extraArgs)
|
for (StringRef arg : g_config->clang.prependArgs)
|
||||||
|
prepend_args.push_back(intern(arg));
|
||||||
|
for (StringRef arg : g_config->clang.extraArgs)
|
||||||
extra_args.push_back(intern(arg));
|
extra_args.push_back(intern(arg));
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mtx);
|
std::lock_guard lock(mtx);
|
||||||
@ -510,6 +521,7 @@ void Project::index(WorkingFiles *wfiles, const RequestId &id) {
|
|||||||
args = entry.args;
|
args = entry.args;
|
||||||
args.insert(args.end(), extra_args.begin(), extra_args.end());
|
args.insert(args.end(), extra_args.begin(), extra_args.end());
|
||||||
args.push_back(intern("-working-directory=" + entry.directory));
|
args.push_back(intern("-working-directory=" + entry.directory));
|
||||||
|
args.insert(args.begin() + 1, prepend_args.begin(), prepend_args.end());
|
||||||
pipeline::index(entry.filename, args, interactive ? IndexMode::Normal : IndexMode::Background, false, id);
|
pipeline::index(entry.filename, args, interactive ? IndexMode::Normal : IndexMode::Background, false, id);
|
||||||
} else {
|
} else {
|
||||||
LOG_V(1) << "[" << i << "/" << folder.entries.size() << "]: " << reason << "; skip " << entry.filename;
|
LOG_V(1) << "[" << i << "/" << folder.entries.size() << "]: " << reason << "; skip " << entry.filename;
|
||||||
@ -529,8 +541,10 @@ void Project::indexRelated(const std::string &path) {
|
|||||||
auto &gi = g_config->index;
|
auto &gi = g_config->index;
|
||||||
GroupMatch match(gi.whitelist, gi.blacklist);
|
GroupMatch match(gi.whitelist, gi.blacklist);
|
||||||
StringRef stem = sys::path::stem(path);
|
StringRef stem = sys::path::stem(path);
|
||||||
std::vector<const char *> args, extra_args;
|
std::vector<const char *> args, prepend_args, extra_args;
|
||||||
for (const std::string &arg : g_config->clang.extraArgs)
|
for (StringRef arg : g_config->clang.prependArgs)
|
||||||
|
prepend_args.push_back(intern(arg));
|
||||||
|
for (StringRef arg : g_config->clang.extraArgs)
|
||||||
extra_args.push_back(intern(arg));
|
extra_args.push_back(intern(arg));
|
||||||
std::lock_guard lock(mtx);
|
std::lock_guard lock(mtx);
|
||||||
for (auto &[root, folder] : root2folder)
|
for (auto &[root, folder] : root2folder)
|
||||||
@ -540,6 +554,7 @@ void Project::indexRelated(const std::string &path) {
|
|||||||
args = entry.args;
|
args = entry.args;
|
||||||
args.insert(args.end(), extra_args.begin(), extra_args.end());
|
args.insert(args.end(), extra_args.begin(), extra_args.end());
|
||||||
args.push_back(intern("-working-directory=" + entry.directory));
|
args.push_back(intern("-working-directory=" + entry.directory));
|
||||||
|
args.insert(args.begin() + 1, prepend_args.begin(), prepend_args.end());
|
||||||
if (sys::path::stem(entry.filename) == stem && entry.filename != path && match.matches(entry.filename, &reason))
|
if (sys::path::stem(entry.filename) == stem && entry.filename != path && match.matches(entry.filename, &reason))
|
||||||
pipeline::index(entry.filename, args, IndexMode::Background, true);
|
pipeline::index(entry.filename, args, IndexMode::Background, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user