diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp @@ -275,9 +275,15 @@ } CachedOptions[Path] = *Result; - CurOptions.push_back(*Result); - if (!Result->first.InheritParentConfig.getValueOr(false)) + CurOptions.push_back(std::move(*Result)); + if (!CurOptions.back().first.InheritParentConfig.getValueOr(false)) break; + // Set search path to where the file where this config was loaded. If the + // Options were sourced from the cache, the actual source may be a parent + // directory of this. In which case we will then read a config that is + // identical to this on the next loop iteration. + // parent_path is used as OptionsSource contains directory and filename. + CurrentPath = llvm::sys::path::parent_path(CurOptions.back().second); } } // Reverse order of file configs because closer configs should have higher