(self, cmd: str)
| 168 | json.dump(data, f) |
| 169 | |
| 170 | def normalize_command(self, cmd: str) -> str: |
| 171 | cmd_pattern = re.compile(r"(ar|llvm-ar|llvm-ar-10|clang|clang\+\+) ") |
| 172 | unnecessary_opts = { |
| 173 | "-O4", |
| 174 | "-O3", |
| 175 | "-O2", |
| 176 | "-O1", |
| 177 | "-Og", |
| 178 | "-Os", |
| 179 | "-Oz", |
| 180 | "-Ofast", |
| 181 | "-O0", |
| 182 | "-O", |
| 183 | "-DNDEBUG", |
| 184 | "-fno-exceptions", |
| 185 | "-std=gnu99", |
| 186 | } |
| 187 | |
| 188 | cmd = cmd[cmd_pattern.search(cmd).start() :] |
| 189 | tokens = [] |
| 190 | for token in cmd.split(): |
| 191 | token = token.strip() |
| 192 | if ( |
| 193 | not token |
| 194 | or token in unnecessary_opts |
| 195 | or token.startswith("-Werror") |
| 196 | or token.startswith("-fsanitize") |
| 197 | ): |
| 198 | continue |
| 199 | if token.startswith("&&"): |
| 200 | tokens.clear() |
| 201 | tokens.append(token) |
| 202 | |
| 203 | return " ".join(tokens) |
no test coverage detected