mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Make CL mode detection fool-proof (#528)
This commit is contained in:
parent
2d1c990f1a
commit
193d42ea78
@ -160,9 +160,22 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
||||
if (args.empty())
|
||||
return result;
|
||||
|
||||
bool clang_cl = strstr(args[0].c_str(), "clang-cl") ||
|
||||
strstr(args[0].c_str(), "cl.exe") ||
|
||||
AnyStartsWith(args, "--driver-mode=cl");
|
||||
std::string first_arg = args[0];
|
||||
// Windows' filesystem is not case sensitive, so we compare only
|
||||
// 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;
|
||||
|
||||
// If |compilationDatabaseCommand| is specified, the external command provides
|
||||
|
Loading…
Reference in New Issue
Block a user