File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,13 +86,29 @@ static fs::path GetExecutableDir() {
8686 return " ." ;
8787}
8888
89+ static bool HasIRFiles (const fs::path &dir) {
90+ std::error_code ec;
91+ for (auto it = fs::recursive_directory_iterator (dir, ec);
92+ !ec && it != fs::recursive_directory_iterator (); it.increment (ec)) {
93+ if (!it->is_directory ()) {
94+ continue ;
95+ }
96+ const auto &p = it->path ();
97+ if (fs::exists (p / " ir_src.json" ) && (fs::exists (p / " ir_unsafe.json" ) ||
98+ fs::exists (p / " ir_refcount.json" ))) {
99+ return true ;
100+ }
101+ }
102+ return false ;
103+ }
104+
89105static bool ResolveRulesDir () {
90106 std::array<fs::path, 3 > candidates = {fs::path (" ./rules" ),
91107 fs::path (" ../rules" ),
92108 GetExecutableDir () / " ../../rules" };
93109
94110 for (const auto &dir : candidates) {
95- if (fs::exists (dir) && fs::is_directory (dir)) {
111+ if (fs::exists (dir) && fs::is_directory (dir) && HasIRFiles (dir) ) {
96112 RulesDir = fs::canonical (dir).string ();
97113 llvm::errs () << " Using rules directory: " << RulesDir << ' \n ' ;
98114 return true ;
You can’t perform that action at this time.
0 commit comments