| 
7 | 7 | 
 
  | 
8 | 8 | namespace sarif {  | 
9 | 9 | 
 
  | 
10 |  | -namespace {  | 
11 |  | -    [[nodiscard]] fs::path getUtbotDir() {  | 
12 |  | -        return fs::current_path().parent_path().parent_path();  | 
13 |  | -    }  | 
14 |  | - | 
15 |  | -    [[nodiscard]] fs::path getKleeDir() {  | 
16 |  | -        fs::path utbotDir = getUtbotDir();  | 
17 |  | -        fs::path kleeDir = utbotDir / "submodules" / "klee";  | 
18 |  | -        if (!fs::exists(kleeDir)) {  | 
19 |  | -            LOG_S(ERROR) << "Klee directory is not " << kleeDir;  | 
20 |  | -            return "/";  | 
21 |  | -        }  | 
22 |  | -        return kleeDir;  | 
23 |  | -    }  | 
24 |  | - | 
25 |  | -    [[nodiscard]] fs::path getKleeRuntimeDir() {  | 
26 |  | -        return getKleeDir() / "runtime";  | 
27 |  | -    }  | 
28 |  | - | 
29 |  | -    [[nodiscard]] bool inKleeRuntimeDir(const fs::path &path) {  | 
30 |  | -        if (fs::exists(path)) {  | 
31 |  | -            return Paths::isSubPathOf(getKleeRuntimeDir(), path);  | 
32 |  | -        }  | 
33 |  | -        if (StringUtils::startsWith(path.c_str(), "runtime")) {  | 
34 |  | -            fs::path absPath = getKleeRuntimeDir().parent_path() / path;  | 
35 |  | -            return fs::exists(absPath);  | 
36 |  | -        } else {  | 
37 |  | -            return false;  | 
38 |  | -        }  | 
39 |  | -    }  | 
40 |  | - | 
41 |  | -    [[nodiscard]] bool inKleeTmpDir(const fs::path &path) {  | 
42 |  | -        return fs::exists(Paths::tmpPath / path);  | 
43 |  | -    }  | 
44 |  | - | 
45 |  | -    [[nodiscard]] std::optional<fs::path> isRelevant(const fs::path &path) {  | 
46 |  | -        if (inKleeTmpDir(path)) {  | 
47 |  | -            return std::nullopt;  | 
48 |  | -        }  | 
49 |  | -        if (inKleeRuntimeDir(path)) {  | 
50 |  | -            fs::path relativePath = fs::relative(getKleeRuntimeDir().parent_path() / path,  | 
51 |  | -                                                 getKleeRuntimeDir());  | 
52 |  | -            bool b = (relativePath.string().find("lib") != std::string::npos);  | 
53 |  | -            if (b) {  | 
54 |  | -                return getKleeRuntimeDir().parent_path() / path;  | 
55 |  | -            }  | 
56 |  | -            return std::nullopt;  | 
57 |  | -        }  | 
58 |  | -        return path;  | 
59 |  | -    }  | 
60 |  | -}  | 
61 |  | - | 
62 | 10 |     FileSarif::FileSarif(const tests::Tests &tests, bool writeFlag) : ProjectSarif(tests.sourceFileNameNoExt,  | 
63 | 11 |                                                                                    tests.relativeFileDir, writeFlag),  | 
64 | 12 |                                                                       sourcePath(tests.sourceFilePath) {}  | 
 | 
0 commit comments