mirror of
https://github.com/MaskRay/ccls.git
synced 2025-03-30 13:32:13 +00:00
Make CL mode detection fool-proof (#528)
This commit is contained in:
parent
b9c3af0be9
commit
0b087421a7
@ -160,9 +160,22 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
if (args.empty())
|
if (args.empty())
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
bool clang_cl = strstr(args[0].c_str(), "clang-cl") ||
|
std::string first_arg = args[0];
|
||||||
strstr(args[0].c_str(), "cl.exe") ||
|
// Windows' filesystem is not case sensitive, so we compare only
|
||||||
AnyStartsWith(args, "--driver-mode=cl");
|
// the lower case variant.
|
||||||
|
std::transform(first_arg.begin(), first_arg.end(), first_arg.begin(),
|
||||||
|
tolower);
|
||||||
|
bool clang_cl = strstr(first_arg.c_str(), "clang-cl") ||
|
||||||
|
strstr(first_arg.c_str(), "cl.exe");
|
||||||
|
// Clang only cares about the last --driver-mode flag, so the loop
|
||||||
|
// iterates in reverse to find the last one as soon as possible
|
||||||
|
// in case of multiple --driver-mode flags.
|
||||||
|
for (int i = args.size() - 1; i >= 0; --i) {
|
||||||
|
if (strstr(args[i].c_str(), "--dirver-mode=")) {
|
||||||
|
clang_cl = clang_cl || strstr(args[i].c_str(), "--driver-mode=cl");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
size_t i = 1;
|
size_t i = 1;
|
||||||
|
|
||||||
// If |compilationDatabaseCommand| is specified, the external command provides
|
// If |compilationDatabaseCommand| is specified, the external command provides
|
||||||
|
Loading…
Reference in New Issue
Block a user