github-actions[bot] wrote: <!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash darker --check --diff -r 342fa15a44721799c9314c58df0d803f13f9d805...faf8597dbb58a08991e11e9c4b9a0aad2f0b4234 clang/utils/generate_unsupported_in_drivermode.py `````````` </details> <details> <summary> View the diff from darker here. </summary> ``````````diff --- generate_unsupported_in_drivermode.py 2024-12-22 14:42:36.000000 +0000 +++ generate_unsupported_in_drivermode.py 2024-12-22 15:02:21.191490 +0000 @@ -44,12 +44,12 @@ OPTION_FLANG = "FlangOption" # Error messages output from each driver ERROR_MSG_CC1AS = ": error: unknown argument" ERROR_MSG_CC1 = "error: unknown argument" -ERROR_MSG_CL = "" # TODO -ERROR_MSG_DXC = "" # TODO +ERROR_MSG_CL = "" # TODO +ERROR_MSG_DXC = "" # TODO ERROR_MSG_DEFAULT = "clang: error: unknown argument" ERROR_MSG_FC1 = "error: unknown argument" ERROR_MSG_FLANG = "flang: error: unknown argument" # Lit CHECK prefixes @@ -59,51 +59,56 @@ CHECK_PREFIX_DXC = PREFIX + OPTION_DXC CHECK_PREFIX_DEFAULT = PREFIX + OPTION_DEFAULT CHECK_PREFIX_FC1 = PREFIX + OPTION_FC1 CHECK_PREFIX_FLANG = PREFIX + OPTION_FLANG -LIT_TEST_NOTE = ("; NOTE: This lit test was automatically generated to validate " + - "unintentionally exposed arguments to various driver flavours.\n" - "; NOTE: To make changes, see " + Path(__file__).resolve().as_posix() - + " from which it was generated.\n\n") +LIT_TEST_NOTE = ( + "; NOTE: This lit test was automatically generated to validate " + + "unintentionally exposed arguments to various driver flavours.\n" + "; NOTE: To make changes, see " + + Path(__file__).resolve().as_posix() + + " from which it was generated.\n\n" +) + def print_usage(): - """ Print valid usage of this script - """ - sys.exit( "usage: python " + sys.argv[0] + " <path>/Options.td [<path>/llvm-tblgen]" ) + """Print valid usage of this script""" + sys.exit("usage: python " + sys.argv[0] + " <path>/Options.td [<path>/llvm-tblgen]") + def find_file(file_name, search_path): - """ Find the given file name under a search path - """ + """Find the given file name under a search path""" result = [] for root, dir, files in os.walk(search_path): if file_name in files: result.append(os.path.join(root, file_name)) return result + def is_valid_file(path, expected_name): - """ Is a file valid + """Is a file valid Check if a given path is to a file, and if it matches the expected file name """ if path.is_file() and path.name == expected_name: return True else: return False + def find_tablegen(): - """ Validate the TableGen executable - """ + """Validate the TableGen executable""" result = shutil.which(LLVM_TABLEGEN) if result is None: sys.exit("Unable to find " + LLVM_TABLEGEN + ".\nExiting") else: print("TableGen found: " + result) return result + def find_groups(group_sequence, options_json, option): - """ Find the groups for a given option + """Find the groups for a given option Note that groups can themselves be part of groups, hence the recursion """ group_json = options_json[option]["Group"] if group_json is None: @@ -116,14 +121,15 @@ group_sequence.append(group_json["def"]) return find_groups(group_sequence, options_json, option) -class UnsupportedDriverOption(): +class UnsupportedDriverOption: def __init__(self, driver, option): self.driver = driver self.option = option + # Validate the number of arguments have been passed argc = len(sys.argv) if argc < 2 or argc > 3: print_usage() @@ -165,12 +171,21 @@ tablegen = tablegen_input_path.resolve().as_posix() else: tablegen = find_tablegen() # Run TableGen to convert Options.td to json -options_json_str = subprocess.run([ tablegen, "-I", os.path.join(current_path, INCLUDE_PATH), options_td, "-dump-json"], stdout=subprocess.PIPE) -options_json = json.loads(options_json_str.stdout.decode('utf-8')) +options_json_str = subprocess.run( + [ + tablegen, + "-I", + os.path.join(current_path, INCLUDE_PATH), + options_td, + "-dump-json", + ], + stdout=subprocess.PIPE, +) +options_json = json.loads(options_json_str.stdout.decode("utf-8")) # Gather list of driver flavours for i in options_json["!instanceof"]["OptionVisibility"]: driver_sequence.append(i) @@ -206,15 +221,25 @@ lit_file.write(LIT_TEST_NOTE) for i in unsupported_sequence: if i.driver == OPTION_CC1AS: lit_file.write( - "; RUN: not clang -cc1as -" + i.option + " -help 2>&1 | FileCheck -check-prefix=" + CHECK_PREFIX_CC1AS + " %s\n") + "; RUN: not clang -cc1as -" + + i.option + + " -help 2>&1 | FileCheck -check-prefix=" + + CHECK_PREFIX_CC1AS + + " %s\n" + ) continue if i.driver == OPTION_CC1: lit_file.write( - "; RUN: not clang -cc1 -" + i.option + " -help 2>&1 | FileCheck -check-prefix=" + CHECK_PREFIX_CC1 + " %s\n") + "; RUN: not clang -cc1 -" + + i.option + + " -help 2>&1 | FileCheck -check-prefix=" + + CHECK_PREFIX_CC1 + + " %s\n" + ) continue # if i.driver == OPTION_CL: # lit_file.write( # "; RUN: not clang-cl -" + i.option + " -help 2>&1 | FileCheck -check-prefix=" + CHECK_PREFIX_CL + " %s\n") # continue @@ -222,28 +247,45 @@ # lit_file.write( # "; RUN: not clang-dxc -" + i.option + " -help 2>&1 | FileCheck -check-prefix=" + CHECK_PREFIX_DXC + " %s\n") # continue if i.driver == OPTION_DEFAULT: lit_file.write( - "; RUN: not clang -" + i.option + " -help 2>&1 | FileCheck -check-prefix=" + CHECK_PREFIX_DEFAULT + " %s\n") + "; RUN: not clang -" + + i.option + + " -help 2>&1 | FileCheck -check-prefix=" + + CHECK_PREFIX_DEFAULT + + " %s\n" + ) continue if i.driver == OPTION_FC1: lit_file.write( - "; RUN: not flang -fc1 -" + i.option + " -help 2>&1 | FileCheck -check-prefix=" + CHECK_PREFIX_FC1 + " %s\n") + "; RUN: not flang -fc1 -" + + i.option + + " -help 2>&1 | FileCheck -check-prefix=" + + CHECK_PREFIX_FC1 + + " %s\n" + ) continue if i.driver == OPTION_FLANG: lit_file.write( - "; RUN: not flang -" + i.option + " -help 2>&1 | FileCheck -check-prefix=" + CHECK_PREFIX_FLANG + " %s\n") + "; RUN: not flang -" + + i.option + + " -help 2>&1 | FileCheck -check-prefix=" + + CHECK_PREFIX_FLANG + + " %s\n" + ) lit_file.write("; " + CHECK_PREFIX_CC1AS + ": " + ERROR_MSG_CC1AS + "\n") lit_file.write("; " + CHECK_PREFIX_CC1 + ": " + ERROR_MSG_CC1 + "\n") lit_file.write("; " + CHECK_PREFIX_CL + ": " + ERROR_MSG_CL + "\n") lit_file.write("; " + CHECK_PREFIX_DXC + ": " + ERROR_MSG_DXC + "\n") - lit_file.write("; " + CHECK_PREFIX_DEFAULT + ": " + ERROR_MSG_DEFAULT + "\n") + lit_file.write( + "; " + CHECK_PREFIX_DEFAULT + ": " + ERROR_MSG_DEFAULT + "\n" + ) lit_file.write("; " + CHECK_PREFIX_FC1 + ": " + ERROR_MSG_FC1 + "\n") lit_file.write("; " + CHECK_PREFIX_FLANG + ": " + ERROR_MSG_FLANG + "\n") - except(IOError, OSError): + except (IOError, OSError): sys.exit("Error writing to " + "LIT_TEST_PATH. Exiting") -except(FileNotFoundError, PermissionError, OSError): +except (FileNotFoundError, PermissionError, OSError): sys.exit("Error opening " + "LIT_TEST_PATH" + ". Exiting") else: lit_file.close() `````````` </details> https://github.com/llvm/llvm-project/pull/120900 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits