Fix hierarchical .cquery

This commit is contained in:
Fangrui Song 2018-03-10 19:48:40 -08:00
parent 640f548e7c
commit 2a7117e6e5
2 changed files with 7 additions and 7 deletions

View File

@ -334,16 +334,16 @@ std::vector<Project::Entry> LoadFromDirectoryListing(Config* init_opts,
auto GetCompilerArgumentForFile = [&config, auto GetCompilerArgumentForFile = [&config,
&folder_args](const std::string& path) { &folder_args](const std::string& path) {
for (std::string cur = GetDirName(path); ; cur = GetDirName(cur)) { for (std::string cur = GetDirName(path);; cur = GetDirName(cur)) {
auto it = folder_args.find(cur);
if (it != folder_args.end())
return it->second;
std::string normalized = NormalizePath(cur); std::string normalized = NormalizePath(cur);
// Break if outside of the project root.
if (normalized.size() <= config->project_dir.size() || if (normalized.size() <= config->project_dir.size() ||
normalized.compare(0, config->project_dir.size(), normalized.compare(0, config->project_dir.size(),
config->project_dir) != 0) config->project_dir) != 0)
break; break;
auto it = folder_args.find(cur);
if (it != folder_args.end()) {
return it->second;
}
} }
return folder_args[config->project_dir]; return folder_args[config->project_dir];
}; };

View File

@ -33,10 +33,10 @@ struct MultiQueueLock {
MultiQueueLock(Queue... lockable) : tuple_{lockable...} { lock(); } MultiQueueLock(Queue... lockable) : tuple_{lockable...} { lock(); }
~MultiQueueLock() { unlock(); } ~MultiQueueLock() { unlock(); }
void lock() { void lock() {
lock_impl(typename std::make_index_sequence<sizeof...(Queue)>{}); lock_impl(typename std::index_sequence_for<Queue...>{});
} }
void unlock() { void unlock() {
unlock_impl(typename std::make_index_sequence<sizeof...(Queue)>{}); unlock_impl(typename std::index_sequence_for<Queue...>{});
} }
private: private: