[PATCH] D92268: [clang-tidy][NFC] Skip intermediate cache directories when inheriting configs.

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 28 06:37:56 PST 2020


njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman, gribozavr2.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

If an configuration specifies InheritParentOption and is cached in child directories, When trying to inherit, it will keep reading the same cache directory file until it reaches the parent directory of where the config was actually stored.
To stop this just set where we are searching from to where the config was actually stored when trying to inherit configs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92268

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92268.308161.patch
Type: text/x-patch
Size: 1089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201128/f31da497/attachment-0001.bin>


More information about the cfe-commits mailing list