@@ -34,7 +34,7 @@ class FileConfigCache : public FileCache {
3434 : FileCache(Path), Directory(Directory) {}
3535
3636 void get (const ThreadsafeFS &TFS, DiagnosticCallback DC,
37- std::chrono::steady_clock::time_point FreshTime,
37+ std::chrono::steady_clock::time_point FreshTime, bool Trusted,
3838 std::vector<CompiledFragment> &Out) const {
3939 read (
4040 TFS, FreshTime,
@@ -43,6 +43,7 @@ class FileConfigCache : public FileCache {
4343 if (Data)
4444 for (auto &Fragment : Fragment::parseYAML (*Data, path (), DC)) {
4545 Fragment.Source .Directory = Directory;
46+ Fragment.Source .Trusted = Trusted;
4647 CachedValue.push_back (std::move (Fragment).compile (DC));
4748 }
4849 },
@@ -52,35 +53,38 @@ class FileConfigCache : public FileCache {
5253
5354std::unique_ptr<Provider> Provider::fromYAMLFile (llvm::StringRef AbsPath,
5455 llvm::StringRef Directory,
55- const ThreadsafeFS &FS) {
56+ const ThreadsafeFS &FS,
57+ bool Trusted) {
5658 class AbsFileProvider : public Provider {
5759 mutable FileConfigCache Cache; // threadsafe
5860 const ThreadsafeFS &FS;
61+ bool Trusted;
5962
6063 std::vector<CompiledFragment>
6164 getFragments (const Params &P, DiagnosticCallback DC) const override {
6265 std::vector<CompiledFragment> Result;
63- Cache.get (FS, DC, P.FreshTime , Result);
66+ Cache.get (FS, DC, P.FreshTime , Trusted, Result);
6467 return Result;
6568 };
6669
6770 public:
6871 AbsFileProvider (llvm::StringRef Path, llvm::StringRef Directory,
69- const ThreadsafeFS &FS)
70- : Cache(Path, Directory), FS(FS) {
72+ const ThreadsafeFS &FS, bool Trusted )
73+ : Cache(Path, Directory), FS(FS), Trusted(Trusted) {
7174 assert (llvm::sys::path::is_absolute (Path));
7275 }
7376 };
7477
75- return std::make_unique<AbsFileProvider>(AbsPath, Directory, FS);
78+ return std::make_unique<AbsFileProvider>(AbsPath, Directory, FS, Trusted );
7679}
7780
7881std::unique_ptr<Provider>
7982Provider::fromAncestorRelativeYAMLFiles (llvm::StringRef RelPath,
80- const ThreadsafeFS &FS) {
83+ const ThreadsafeFS &FS, bool Trusted ) {
8184 class RelFileProvider : public Provider {
8285 std::string RelPath;
8386 const ThreadsafeFS &FS;
87+ bool Trusted;
8488
8589 mutable std::mutex Mu;
8690 // Keys are the (posix-style) ancestor directory, not the config within it.
@@ -128,18 +132,19 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath,
128132 // This will take a (per-file) lock for each file that actually exists.
129133 std::vector<CompiledFragment> Result;
130134 for (FileConfigCache *Cache : Caches)
131- Cache->get (FS, DC, P.FreshTime , Result);
135+ Cache->get (FS, DC, P.FreshTime , Trusted, Result);
132136 return Result;
133137 };
134138
135139 public:
136- RelFileProvider (llvm::StringRef RelPath, const ThreadsafeFS &FS)
137- : RelPath(RelPath), FS(FS) {
140+ RelFileProvider (llvm::StringRef RelPath, const ThreadsafeFS &FS,
141+ bool Trusted)
142+ : RelPath(RelPath), FS(FS), Trusted(Trusted) {
138143 assert (llvm::sys::path::is_relative (RelPath));
139144 }
140145 };
141146
142- return std::make_unique<RelFileProvider>(RelPath, FS);
147+ return std::make_unique<RelFileProvider>(RelPath, FS, Trusted );
143148}
144149
145150std::unique_ptr<Provider>
0 commit comments