10
10
#include " Config.h"
11
11
#include " ConfigFragment.h"
12
12
#include " support/FileCache.h"
13
+ #include " support/Path.h"
13
14
#include " support/ThreadsafeFS.h"
14
15
#include " support/Trace.h"
16
+ #include " llvm/ADT/STLExtras.h"
15
17
#include " llvm/ADT/ScopeExit.h"
16
18
#include " llvm/ADT/StringMap.h"
17
19
#include " llvm/ADT/StringRef.h"
@@ -96,16 +98,10 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath,
96
98
return {};
97
99
98
100
// Compute absolute paths to all ancestors (substrings of P.Path).
99
- llvm::StringRef Parent = path::parent_path (P.Path );
100
101
llvm::SmallVector<llvm::StringRef, 8 > Ancestors;
101
- for (auto I = path::begin (Parent, path::Style ::posix),
102
- E = path::end (Parent);
103
- I != E; ++I) {
104
- // Avoid weird non-substring cases like phantom "." components.
105
- // In practice, Component is a substring for all "normal" ancestors.
106
- if (I->end () < Parent.begin () || I->end () > Parent.end ())
107
- continue ;
108
- Ancestors.emplace_back (Parent.begin (), I->end () - Parent.begin ());
102
+ for (auto Ancestor = absoluteParent (P.Path ); !Ancestor.empty ();
103
+ Ancestor = absoluteParent (Ancestor)) {
104
+ Ancestors.emplace_back (Ancestor);
109
105
}
110
106
// Ensure corresponding cache entries exist in the map.
111
107
llvm::SmallVector<FileConfigCache *, 8 > Caches;
@@ -127,7 +123,7 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath,
127
123
// Finally query each individual file.
128
124
// This will take a (per-file) lock for each file that actually exists.
129
125
std::vector<CompiledFragment> Result;
130
- for (FileConfigCache *Cache : Caches)
126
+ for (FileConfigCache *Cache : llvm::reverse ( Caches) )
131
127
Cache->get (FS, DC, P.FreshTime , Result);
132
128
return Result;
133
129
};
0 commit comments