[Mlir-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

Eisuke Kawashima llvmlistbot at llvm.org
Sat May 11 08:06:26 PDT 2024


https://github.com/e-kwsm created https://github.com/llvm/llvm-project/pull/91857

None

>From c450df191a6b96591d7c7a7454b6e15cb925520f Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima <e-kwsm at users.noreply.github.com>
Date: Sat, 11 May 2024 23:57:11 +0900
Subject: [PATCH] fix(python): fix comparison to None

---
 .../clang-tidy/checks/gen-static-analyzer-docs.py    |  2 +-
 clang/docs/DebuggingCoroutines.rst                   |  8 ++++----
 clang/tools/include-mapping/gen_std.py               |  2 +-
 clang/utils/check_cfc/obj_diff.py                    |  2 +-
 clang/utils/module-deps-to-rsp.py                    |  2 +-
 compiler-rt/test/asan/lit.cfg.py                     |  2 +-
 compiler-rt/test/builtins/Unit/lit.cfg.py            |  2 +-
 compiler-rt/test/ctx_profile/lit.cfg.py              |  2 +-
 compiler-rt/test/lsan/lit.common.cfg.py              |  2 +-
 compiler-rt/test/memprof/lit.cfg.py                  |  2 +-
 compiler-rt/test/profile/lit.cfg.py                  |  2 +-
 .../android_commands/android_compile.py              |  2 +-
 .../sanitizer_common/ios_commands/iossim_compile.py  |  2 +-
 compiler-rt/test/ubsan/lit.common.cfg.py             |  2 +-
 compiler-rt/test/ubsan_minimal/lit.common.cfg.py     |  2 +-
 .../dexter/dex/command/ParseCommand.py               |  2 +-
 .../DebuggerControllers/ConditionalController.py     |  4 ++--
 .../DebuggerControllers/ControllerHelpers.py         |  2 +-
 .../debuginfo-tests/dexter/dex/debugger/Debuggers.py |  2 +-
 .../dexter/dex/debugger/visualstudio/VisualStudio.py |  2 +-
 .../debuginfo-tests/dexter/dex/tools/test/Tool.py    |  2 +-
 cross-project-tests/lit.cfg.py                       |  2 +-
 lldb/docs/use/python.rst                             |  4 ++--
 .../python/armv7_cortex_m_target_defintion.py        |  2 +-
 lldb/packages/Python/lldbsuite/test/dotest.py        |  2 +-
 lldb/packages/Python/lldbsuite/test/lldbtest.py      |  6 +++---
 lldb/packages/Python/lldbsuite/test/lldbutil.py      |  6 +++---
 .../lldbsuite/test/tools/intelpt/intelpt_testcase.py |  2 +-
 .../address_breakpoints/TestBadAddressBreakpoints.py |  2 +-
 .../step_scripted/TestStepScripted.py                |  2 +-
 .../TestStopOnSharedlibraryEvents.py                 |  2 +-
 lldb/test/API/lua_api/TestLuaAPI.py                  |  2 +-
 .../thread_suspend/TestInternalThreadSuspension.py   |  2 +-
 lldb/test/API/python_api/event/TestEvents.py         |  2 +-
 .../process/read-mem-cstring/TestReadMemCString.py   |  2 +-
 lldb/test/API/python_api/type/TestTypeList.py        |  2 +-
 .../API/python_api/was_interrupted/interruptible.py  |  2 +-
 lldb/test/Shell/lit.cfg.py                           |  2 +-
 llvm/utils/indirect_calls.py                         |  2 +-
 llvm/utils/lit/lit/TestRunner.py                     |  2 +-
 llvm/utils/lit/lit/util.py                           |  2 +-
 llvm/utils/schedcover.py                             |  2 +-
 llvm/utils/shuffle_select_fuzz_tester.py             | 12 ++++++------
 mlir/test/python/ir/affine_expr.py                   |  2 +-
 mlir/test/python/ir/attributes.py                    |  8 ++++----
 mlir/test/python/ir/builtin_types.py                 |  8 ++++----
 openmp/libompd/gdb-plugin/ompd/ompd_callbacks.py     |  2 +-
 polly/lib/External/isl/libisl-gdb.py                 |  4 ++--
 polly/lib/External/isl/python/isl.py.top             |  4 ++--
 polly/utils/pyscop/isl.py                            |  8 ++++----
 50 files changed, 75 insertions(+), 75 deletions(-)

diff --git a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
index 6545a3906fa50..53ecb60dec539 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
+++ b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
@@ -47,7 +47,7 @@ def get_checkers(checkers_td, checkers_rst):
         parent_package_ = package["ParentPackage"]
         hidden = (checker["Hidden"] != 0) or (package["Hidden"] != 0)
 
-        while parent_package_ != None:
+        while parent_package_ is not None:
             parent_package = table_entries[parent_package_["def"]]
             checker_package_prefix = (
                 parent_package["PackageName"] + "." + checker_package_prefix
diff --git a/clang/docs/DebuggingCoroutines.rst b/clang/docs/DebuggingCoroutines.rst
index 53bdd08fdbc02..7f464c1f4f28c 100644
--- a/clang/docs/DebuggingCoroutines.rst
+++ b/clang/docs/DebuggingCoroutines.rst
@@ -513,7 +513,7 @@ So we can use the ``continuation`` field to construct the asynchronous stack:
           self.coro_frame = coro_frame
           self.resume_func = dereference(self.coro_frame.resume_addr)
           self.resume_func_block = gdb.block_for_pc(self.resume_func)
-          if self.resume_func_block == None:
+          if self.resume_func_block is None:
               raise Exception('Not stackless coroutine.')
           self.line_info = gdb.find_pc_line(self.resume_func)
 
@@ -543,8 +543,8 @@ So we can use the ``continuation`` field to construct the asynchronous stack:
           self.function_name = f
 
       def __str__(self, shift = 2):
-          addr = "" if self.address() == None else '%#x' % self.address() + " in "
-          location = "" if self.filename() == None else " at " + self.filename() + ":" + str(self.line())
+          addr = "" if self.address() is None else '%#x' % self.address() + " in "
+          location = "" if self.filename() is None else " at " + self.filename() + ":" + str(self.line())
           return addr + self.function() + " " + str([str(args) for args in self.frame_args()]) + location
 
   class CoroutineFilter:
@@ -598,7 +598,7 @@ So we can use the ``continuation`` field to construct the asynchronous stack:
 
           addr = int(argv[0], 16)
           block = gdb.block_for_pc(long(cast_addr2long_pointer(addr).dereference()))
-          if block == None:
+          if block is None:
               print "block " + str(addr) + "  is none."
               return
 
diff --git a/clang/tools/include-mapping/gen_std.py b/clang/tools/include-mapping/gen_std.py
index fcd3bd0d843ea..f362227bc6aab 100755
--- a/clang/tools/include-mapping/gen_std.py
+++ b/clang/tools/include-mapping/gen_std.py
@@ -215,7 +215,7 @@ def GetCCompatibilitySymbols(symbol):
     # Introduce two more entries, both in the global namespace, one using the
     # C++-compat header and another using the C header.
     results = []
-    if symbol.namespace != None:
+    if symbol.namespace is not None:
         # avoid printing duplicated entries, for C macros!
         results.append(cppreference_parser.Symbol(symbol.name, None, [header]))
     c_header = "<" + header[2:-1] + ".h>"  # <cstdio> => <stdio.h>
diff --git a/clang/utils/check_cfc/obj_diff.py b/clang/utils/check_cfc/obj_diff.py
index 99ed19e522be2..9d602593a4e1a 100755
--- a/clang/utils/check_cfc/obj_diff.py
+++ b/clang/utils/check_cfc/obj_diff.py
@@ -57,7 +57,7 @@ def first_diff(a, b, fromfile, tofile):
             first_diff_idx = idx
             break
 
-    if first_diff_idx == None:
+    if first_diff_idx is None:
         # No difference
         return None
 
diff --git a/clang/utils/module-deps-to-rsp.py b/clang/utils/module-deps-to-rsp.py
index 6c9f263a786ef..b57a44e5c8780 100755
--- a/clang/utils/module-deps-to-rsp.py
+++ b/clang/utils/module-deps-to-rsp.py
@@ -74,7 +74,7 @@ def main():
 
         if args.module_name:
             cmd = findModule(args.module_name, full_deps)["command-line"]
-        elif args.tu_index != None:
+        elif args.tu_index is not None:
             tu = full_deps.translation_units[args.tu_index]
             cmd = tu["commands"][args.tu_cmd_index]["command-line"]
 
diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index 83b3cbe789cac..7491568e55808 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -10,7 +10,7 @@
 
 def get_required_attr(config, attr_name):
     attr_value = getattr(config, attr_name, None)
-    if attr_value == None:
+    if attr_value is None:
         lit_config.fatal(
             "No attribute %r in test configuration! You may need to run "
             "tests from your build directory or add this attribute "
diff --git a/compiler-rt/test/builtins/Unit/lit.cfg.py b/compiler-rt/test/builtins/Unit/lit.cfg.py
index f63d15919888e..c18c973d54c13 100644
--- a/compiler-rt/test/builtins/Unit/lit.cfg.py
+++ b/compiler-rt/test/builtins/Unit/lit.cfg.py
@@ -21,7 +21,7 @@
 
 def get_required_attr(config, attr_name):
     attr_value = getattr(config, attr_name, None)
-    if attr_value == None:
+    if attr_value is None:
         lit_config.fatal(
             "No attribute %r in test configuration! You may need to run "
             "tests from your build directory or add this attribute "
diff --git a/compiler-rt/test/ctx_profile/lit.cfg.py b/compiler-rt/test/ctx_profile/lit.cfg.py
index a56dabb8ebeb3..1bcfc6485ef8e 100644
--- a/compiler-rt/test/ctx_profile/lit.cfg.py
+++ b/compiler-rt/test/ctx_profile/lit.cfg.py
@@ -13,7 +13,7 @@
 
 def get_required_attr(config, attr_name):
     attr_value = getattr(config, attr_name, None)
-    if attr_value == None:
+    if attr_value is None:
         lit_config.fatal(
             "No attribute %r in test configuration! You may need to run "
             "tests from your build directory or add this attribute "
diff --git a/compiler-rt/test/lsan/lit.common.cfg.py b/compiler-rt/test/lsan/lit.common.cfg.py
index e9b974955730d..9426b7d108bbf 100644
--- a/compiler-rt/test/lsan/lit.common.cfg.py
+++ b/compiler-rt/test/lsan/lit.common.cfg.py
@@ -10,7 +10,7 @@
 
 def get_required_attr(config, attr_name):
     attr_value = getattr(config, attr_name, None)
-    if attr_value == None:
+    if attr_value is None:
         lit_config.fatal(
             "No attribute %r in test configuration! You may need to run "
             "tests from your build directory or add this attribute "
diff --git a/compiler-rt/test/memprof/lit.cfg.py b/compiler-rt/test/memprof/lit.cfg.py
index 4e5d7ba405a20..4057da0c65b51 100644
--- a/compiler-rt/test/memprof/lit.cfg.py
+++ b/compiler-rt/test/memprof/lit.cfg.py
@@ -9,7 +9,7 @@
 
 def get_required_attr(config, attr_name):
     attr_value = getattr(config, attr_name, None)
-    if attr_value == None:
+    if attr_value is None:
         lit_config.fatal(
             "No attribute %r in test configuration! You may need to run "
             "tests from your build directory or add this attribute "
diff --git a/compiler-rt/test/profile/lit.cfg.py b/compiler-rt/test/profile/lit.cfg.py
index d3ba115731c5d..191947e4f64aa 100644
--- a/compiler-rt/test/profile/lit.cfg.py
+++ b/compiler-rt/test/profile/lit.cfg.py
@@ -6,7 +6,7 @@
 
 def get_required_attr(config, attr_name):
     attr_value = getattr(config, attr_name, None)
-    if attr_value == None:
+    if attr_value is None:
         lit_config.fatal(
             "No attribute %r in test configuration! You may need to run "
             "tests from your build directory or add this attribute "
diff --git a/compiler-rt/test/sanitizer_common/android_commands/android_compile.py b/compiler-rt/test/sanitizer_common/android_commands/android_compile.py
index f86831ffef899..e9c6738a09a3f 100755
--- a/compiler-rt/test/sanitizer_common/android_commands/android_compile.py
+++ b/compiler-rt/test/sanitizer_common/android_commands/android_compile.py
@@ -20,7 +20,7 @@
     elif arg == "-o":
         output = args.pop(0)
 
-if output == None:
+if output is None:
     print("No output file name!")
     sys.exit(1)
 
diff --git a/compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py b/compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py
index 39b211b093c92..2eac1a9bab455 100755
--- a/compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py
+++ b/compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py
@@ -19,7 +19,7 @@
     elif arg == "-o":
         output = args.pop(0)
 
-if output == None:
+if output is None:
     print("No output file name!")
     sys.exit(1)
 
diff --git a/compiler-rt/test/ubsan/lit.common.cfg.py b/compiler-rt/test/ubsan/lit.common.cfg.py
index 61f6818cce064..04d6f24de5a9f 100644
--- a/compiler-rt/test/ubsan/lit.common.cfg.py
+++ b/compiler-rt/test/ubsan/lit.common.cfg.py
@@ -5,7 +5,7 @@
 
 def get_required_attr(config, attr_name):
     attr_value = getattr(config, attr_name, None)
-    if attr_value == None:
+    if attr_value is None:
         lit_config.fatal(
             "No attribute %r in test configuration! You may need to run "
             "tests from your build directory or add this attribute "
diff --git a/compiler-rt/test/ubsan_minimal/lit.common.cfg.py b/compiler-rt/test/ubsan_minimal/lit.common.cfg.py
index d398d3a0a8162..e60aed6512fb9 100644
--- a/compiler-rt/test/ubsan_minimal/lit.common.cfg.py
+++ b/compiler-rt/test/ubsan_minimal/lit.common.cfg.py
@@ -5,7 +5,7 @@
 
 def get_required_attr(config, attr_name):
     attr_value = getattr(config, attr_name, None)
-    if attr_value == None:
+    if attr_value is None:
         lit_config.fatal(
             "No attribute %r in test configuration! You may need to run "
             "tests from your build directory or add this attribute "
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py b/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
index 29d7867e80867..4b086e14d4050 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
@@ -98,7 +98,7 @@ def _build_command(
 
     def label_to_line(label_name: str) -> int:
         line = labels.get(label_name, None)
-        if line != None:
+        if line is not None:
             return line
         raise format_unresolved_label_err(label_name, raw_text, path.base, lineno)
 
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py
index a7d6b570b55e8..ac3054c3a0edf 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py
@@ -62,7 +62,7 @@ def __init__(
         self.finish_on_remove = finish_on_remove
 
     def has_conditions(self):
-        return self.expression != None
+        return self.expression is not None
 
     def get_conditional_expression_list(self):
         conditional_list = []
@@ -76,7 +76,7 @@ def add_hit(self):
         self.current_hit_count += 1
 
     def should_be_removed(self):
-        if self.max_hit_count == None:
+        if self.max_hit_count is None:
             return False
         return self.current_hit_count >= self.max_hit_count
 
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ControllerHelpers.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ControllerHelpers.py
index 3e5a7b919d703..a4ca5ae0158e9 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ControllerHelpers.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ControllerHelpers.py
@@ -39,7 +39,7 @@ def update_step_watches(step_info, watches, commands):
         for watch in towatch:
             loc = step_info.current_location
             if (
-                loc.path != None
+                loc.path is not None
                 and os.path.exists(loc.path)
                 and os.path.samefile(watch.path, loc.path)
                 and have_hit_line(watch, loc)
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
index 1b0d4d5871cbe..67b715af78698 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
@@ -183,7 +183,7 @@ def handle_debugger_tool_options(context, defaults):  # noqa
         if options.debugger == "lldb":
             _warn_meaningless_option(context, "--show-debugger")
 
-    if options.source_root_dir != None:
+    if options.source_root_dir is not None:
         if not os.path.isabs(options.source_root_dir):
             raise ToolArgumentError(
                 f'<d>--source-root-dir: expected absolute path, got</> <r>"{options.source_root_dir}"</>'
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
index 0e20cfbbd264b..f87e1312819e2 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
@@ -235,7 +235,7 @@ def delete_breakpoints(self, ids):
         for bp in self._debugger.Breakpoints:
             # We're looking at the user-set breakpoints so there should be no
             # Parent.
-            assert bp.Parent == None
+            assert bp.Parent is None
             this_vsbp = VSBreakpoint(
                 PurePath(bp.File), bp.FileLine, bp.FileColumn, bp.Condition
             )
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py b/cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py
index f07641041254b..c366062cec7a9 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py
@@ -150,7 +150,7 @@ def _get_results_path(self, test_name):
         """Returns the path to the test results directory for the test denoted
         by test_name.
         """
-        assert self.context.options.results_directory != None
+        assert self.context.options.results_directory is not None
         return os.path.join(
             self.context.options.results_directory,
             self._get_results_basename(test_name),
diff --git a/cross-project-tests/lit.cfg.py b/cross-project-tests/lit.cfg.py
index 774c4eaf4d976..6341d5c300d86 100644
--- a/cross-project-tests/lit.cfg.py
+++ b/cross-project-tests/lit.cfg.py
@@ -54,7 +54,7 @@
 
 def get_required_attr(config, attr_name):
     attr_value = getattr(config, attr_name, None)
-    if attr_value == None:
+    if attr_value is None:
         lit_config.fatal(
             "No attribute %r in test configuration! You may need to run "
             "tests from your build directory or add this attribute "
diff --git a/lldb/docs/use/python.rst b/lldb/docs/use/python.rst
index 6183d6935d80e..d9c29d95708c1 100644
--- a/lldb/docs/use/python.rst
+++ b/lldb/docs/use/python.rst
@@ -75,13 +75,13 @@ later explanations:
    12:     if root_word == word:
    13:         return cur_path
    14:     elif word < root_word:
-   15:         if left_child_ptr.GetValue() == None:
+   15:         if left_child_ptr.GetValue() is None:
    16:             return ""
    17:         else:
    18:             cur_path = cur_path + "L"
    19:             return DFS (left_child_ptr, word, cur_path)
    20:     else:
-   21:         if right_child_ptr.GetValue() == None:
+   21:         if right_child_ptr.GetValue() is None:
    22:             return ""
    23:         else:
    24:             cur_path = cur_path + "R"
diff --git a/lldb/examples/python/armv7_cortex_m_target_defintion.py b/lldb/examples/python/armv7_cortex_m_target_defintion.py
index 42eaa39993dae..8225670f33e6b 100755
--- a/lldb/examples/python/armv7_cortex_m_target_defintion.py
+++ b/lldb/examples/python/armv7_cortex_m_target_defintion.py
@@ -222,7 +222,7 @@ def get_reg_num(reg_num_dict, reg_name):
 
 def get_target_definition():
     global g_target_definition
-    if g_target_definition == None:
+    if g_target_definition is None:
         g_target_definition = {}
         offset = 0
         for reg_info in armv7_register_infos:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index ebabf348643ef..d6757f000c14d 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -47,7 +47,7 @@
 
 def is_exe(fpath):
     """Returns true if fpath is an executable."""
-    if fpath == None:
+    if fpath is None:
         return False
     if sys.platform == "win32":
         if not fpath.endswith(".exe"):
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 5fd686c143e9f..cb3ae0e422975 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -229,7 +229,7 @@ def pointer_size():
 
 def is_exe(fpath):
     """Returns true if fpath is an executable."""
-    if fpath == None:
+    if fpath is None:
         return False
     if sys.platform == "win32":
         if not fpath.endswith(".exe"):
@@ -2191,7 +2191,7 @@ def complete_from_to(self, str_input, patterns):
         if num_matches == 0:
             compare_string = str_input
         else:
-            if common_match != None and len(common_match) > 0:
+            if common_match is not None and len(common_match) > 0:
                 compare_string = str_input + common_match
             else:
                 compare_string = ""
@@ -2552,7 +2552,7 @@ def assertFailure(self, obj, error_str=None, msg=None):
         if obj.Success():
             self.fail(self._formatMessage(msg, "Error not in a fail state"))
 
-        if error_str == None:
+        if error_str is None:
             return
 
         error = obj.GetCString()
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 58eb37fd742d7..629d8ce494b85 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1594,11 +1594,11 @@ def set_actions_for_signal(
 ):
     return_obj = lldb.SBCommandReturnObject()
     command = "process handle {0}".format(signal_name)
-    if pass_action != None:
+    if pass_action is not None:
         command += " -p {0}".format(pass_action)
-    if stop_action != None:
+    if stop_action is not None:
         command += " -s {0}".format(stop_action)
-    if notify_action != None:
+    if notify_action is not None:
         command += " -n {0}".format(notify_action)
 
     testcase.dbg.GetCommandInterpreter().HandleCommand(command, return_obj)
diff --git a/lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py
index fd1eb64219585..f1b7d7c33bf07 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py
@@ -134,7 +134,7 @@ def traceStartProcess(
             self.assertSBError(trace.Start(configuration), error=error)
         else:
             command = "process trace start"
-            if processBufferSizeLimit != None:
+            if processBufferSizeLimit is not None:
                 command += " -l " + str(processBufferSizeLimit)
             if enableTsc:
                 command += " --tsc"
diff --git a/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py b/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
index d120692e4d6e6..3674a8c233c8d 100644
--- a/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
+++ b/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
@@ -32,7 +32,7 @@ def address_breakpoints(self):
         for region_idx in range(regions.GetSize()):
             region = lldb.SBMemoryRegionInfo()
             regions.GetMemoryRegionAtIndex(region_idx, region)
-            if illegal_address == None or region.GetRegionEnd() > illegal_address:
+            if illegal_address is None or region.GetRegionEnd() > illegal_address:
                 illegal_address = region.GetRegionEnd()
 
         if illegal_address is not None:
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 9891a9c23b50c..53901718019f9 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -126,7 +126,7 @@ def run_step(self, stop_others_value, run_mode, token):
         cmd = "thread step-scripted -C Steps.StepReportsStopOthers -k token -v %s" % (
             token
         )
-        if run_mode != None:
+        if run_mode is not None:
             cmd = cmd + " --run-mode %s" % (run_mode)
         if self.TraceOn():
             print(cmd)
diff --git a/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py b/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
index 58205553154bf..f68eb4196c125 100644
--- a/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
+++ b/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
@@ -99,7 +99,7 @@ def do_test(self, bkpt_modifier=None):
             backstop_bkpt_2.GetNumLocations(), 0, "Set our third breakpoint"
         )
 
-        if bkpt_modifier == None:
+        if bkpt_modifier is None:
             process.Continue()
             self.assertState(
                 process.GetState(), lldb.eStateStopped, "We didn't stop for the load"
diff --git a/lldb/test/API/lua_api/TestLuaAPI.py b/lldb/test/API/lua_api/TestLuaAPI.py
index 4c9a5d9672c4c..065de61ad6577 100644
--- a/lldb/test/API/lua_api/TestLuaAPI.py
+++ b/lldb/test/API/lua_api/TestLuaAPI.py
@@ -115,7 +115,7 @@ def killProcess():
         out, err = p.communicate(input=input)
         exitCode = p.wait()
     finally:
-        if timerObject != None:
+        if timerObject is not None:
             timerObject.cancel()
 
     # Ensure the resulting output is always of string type.
diff --git a/lldb/test/API/macosx/thread_suspend/TestInternalThreadSuspension.py b/lldb/test/API/macosx/thread_suspend/TestInternalThreadSuspension.py
index 1b33494cc5206..b41c2ae0976a2 100644
--- a/lldb/test/API/macosx/thread_suspend/TestInternalThreadSuspension.py
+++ b/lldb/test/API/macosx/thread_suspend/TestInternalThreadSuspension.py
@@ -92,7 +92,7 @@ def suspended_thread_test(self):
         thread = lldb.SBThread()
         for thread in process.threads:
             th_name = thread.GetName()
-            if th_name == None:
+            if th_name is None:
                 continue
             if "Look for me" in th_name:
                 break
diff --git a/lldb/test/API/python_api/event/TestEvents.py b/lldb/test/API/python_api/event/TestEvents.py
index a15f4357f4f5f..d8d3dd2d2b01b 100644
--- a/lldb/test/API/python_api/event/TestEvents.py
+++ b/lldb/test/API/python_api/event/TestEvents.py
@@ -335,7 +335,7 @@ def wait_for_next_event(self, expected_state, test_shadow=False):
         if state == lldb.eStateStopped:
             restart = lldb.SBProcess.GetRestartedFromEvent(event)
 
-        if expected_state != None:
+        if expected_state is not None:
             self.assertEqual(
                 state, expected_state, "Primary thread got the correct event"
             )
diff --git a/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py b/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py
index f664a18ebfa3d..108487b08bb00 100644
--- a/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py
+++ b/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py
@@ -61,4 +61,4 @@ def test_read_memory_c_string(self):
             invalid_memory_str_addr, 2048, err
         )
         self.assertTrue(err.Fail())
-        self.assertTrue(invalid_memory_string == "" or invalid_memory_string == None)
+        self.assertTrue(invalid_memory_string == "" or invalid_memory_string is None)
diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py
index b028929eea442..bc4d00c17c555 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -132,7 +132,7 @@ def test(self):
                         "my_type_is_named has a named type",
                     )
                     self.assertTrue(field.type.IsAggregateType())
-                elif field.name == None:
+                elif field.name is None:
                     self.assertTrue(
                         field.type.IsAnonymousType(), "Nameless type is not anonymous"
                     )
diff --git a/lldb/test/API/python_api/was_interrupted/interruptible.py b/lldb/test/API/python_api/was_interrupted/interruptible.py
index 4e7437d768d26..37999979e1a7f 100644
--- a/lldb/test/API/python_api/was_interrupted/interruptible.py
+++ b/lldb/test/API/python_api/was_interrupted/interruptible.py
@@ -45,7 +45,7 @@ def __call__(self, debugger, args, exe_ctx, result):
         For the "check" case, it doesn't wait, but just returns whether there was
         an interrupt in force or not."""
 
-        if local_data == None:
+        if local_data is None:
             result.SetError("local data was not set.")
             result.SetStatus(lldb.eReturnStatusFailed)
             return
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index e24f3fbb4d931..d764cfa20ea83 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -145,7 +145,7 @@ def calculate_arch_features(arch_string):
 if config.lldb_enable_lzma:
     config.available_features.add("lzma")
 
-if shutil.which("xz") != None:
+if shutil.which("xz") is not None:
     config.available_features.add("xz")
 
 if config.lldb_system_debugserver:
diff --git a/llvm/utils/indirect_calls.py b/llvm/utils/indirect_calls.py
index 2bdabc8c4d74f..34d9e8f9422b0 100755
--- a/llvm/utils/indirect_calls.py
+++ b/llvm/utils/indirect_calls.py
@@ -34,7 +34,7 @@ def look_for_indirect(file):
         if line.startswith(" ") == False:
             function = line
         result = re.search("(call|jmp).*\*", line)
-        if result != None:
+        if result is not None:
             # TODO: Perhaps use cxxfilt to demangle functions?
             print(function)
             print(line)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index da7fa86fd3917..a6f1a46f09c86 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -197,7 +197,7 @@ def executeShCmd(cmd, shenv, results, timeout=0):
     timeout
     """
     # Use the helper even when no timeout is required to make
-    # other code simpler (i.e. avoid bunch of ``!= None`` checks)
+    # other code simpler (i.e. avoid bunch of ``is not None`` checks)
     timeoutHelper = TimeoutHelper(timeout)
     if timeout > 0:
         timeoutHelper.startTimer()
diff --git a/llvm/utils/lit/lit/util.py b/llvm/utils/lit/lit/util.py
index 232ddc9171ad3..a2452f5566b77 100644
--- a/llvm/utils/lit/lit/util.py
+++ b/llvm/utils/lit/lit/util.py
@@ -408,7 +408,7 @@ def killProcess():
         out, err = p.communicate(input=input)
         exitCode = p.wait()
     finally:
-        if timerObject != None:
+        if timerObject is not None:
             timerObject.cancel()
 
     # Ensure the resulting output is always of string type.
diff --git a/llvm/utils/schedcover.py b/llvm/utils/schedcover.py
index 41d0359462d19..caa73b6d6a747 100755
--- a/llvm/utils/schedcover.py
+++ b/llvm/utils/schedcover.py
@@ -25,7 +25,7 @@ def add(instr, model, resource=None):
 def filter_model(m):
     global filt
     if m and filt:
-        return filt.search(m) != None
+        return filt.search(m) is not None
     else:
         return True
 
diff --git a/llvm/utils/shuffle_select_fuzz_tester.py b/llvm/utils/shuffle_select_fuzz_tester.py
index 73bac3c18db14..f51945b530d3f 100755
--- a/llvm/utils/shuffle_select_fuzz_tester.py
+++ b/llvm/utils/shuffle_select_fuzz_tester.py
@@ -157,7 +157,7 @@ def dump(self):
         )
 
     def calc_value(self):
-        if self.value != None:
+        if self.value is not None:
             print("Trying to calculate the value of a shuffle instruction twice")
             exit(1)
 
@@ -199,7 +199,7 @@ def dump(self):
         )
 
     def calc_value(self):
-        if self.value != None:
+        if self.value is not None:
             print("Trying to calculate the value of a select instruction twice")
             exit(1)
 
@@ -237,7 +237,7 @@ def gen_inputs(ty, num):
 # In case one of the dimensions (scalar type/number of elements) is provided,
 # fill the blank dimension and return appropriate Type object.
 def get_random_type(ty, num_elts):
-    if ty != None:
+    if ty is not None:
         if ty == "i8":
             is_float = False
             width = 8
@@ -260,10 +260,10 @@ def get_random_type(ty, num_elts):
     int_elt_widths = [8, 16, 32, 64]
     float_elt_widths = [32, 64]
 
-    if num_elts == None:
+    if num_elts is None:
         num_elts = random.choice(range(2, 65))
 
-    if ty == None:
+    if ty is None:
         # 1 for integer type, 0 for floating-point
         if random.randint(0, 1):
             is_float = False
@@ -388,7 +388,7 @@ def main():
     ), "Minimum value greater than maximum."
     assert args.type in [None, "i8", "i16", "i32", "i64", "f32", "f64"], "Illegal type."
     assert (
-        args.num_elts == None or args.num_elts > 0
+        args.num_elts is None or args.num_elts > 0
     ), "num_elts must be a positive integer."
 
     random.seed(args.seed)
diff --git a/mlir/test/python/ir/affine_expr.py b/mlir/test/python/ir/affine_expr.py
index 63564303e8315..c7861c1acfe12 100644
--- a/mlir/test/python/ir/affine_expr.py
+++ b/mlir/test/python/ir/affine_expr.py
@@ -42,7 +42,7 @@ def testAffineExprEq():
         # CHECK: False
         print(a1 == a3)
         # CHECK: False
-        print(a1 == None)
+        print(a1 is None)
         # CHECK: False
         print(a1 == "foo")
 
diff --git a/mlir/test/python/ir/attributes.py b/mlir/test/python/ir/attributes.py
index dbd6bad05e01d..0f2c8e7b7252a 100644
--- a/mlir/test/python/ir/attributes.py
+++ b/mlir/test/python/ir/attributes.py
@@ -56,8 +56,8 @@ def testAttrEq():
         print("a1 == a2:", a1 == a2)
         # CHECK: a1 == a3: True
         print("a1 == a3:", a1 == a3)
-        # CHECK: a1 == None: False
-        print("a1 == None:", a1 == None)
+        # CHECK: a1 is None: False
+        print("a1 is None:", a1 is None)
 
 
 # CHECK-LABEL: TEST: testAttrHash
@@ -109,9 +109,9 @@ def testAttrEqDoesNotRaise():
         # CHECK: False
         print(a1 == not_an_attr)
         # CHECK: False
-        print(a1 == None)
+        print(a1 is None)
         # CHECK: True
-        print(a1 != None)
+        print(a1 is not None)
 
 
 # CHECK-LABEL: TEST: testAttrCapsule
diff --git a/mlir/test/python/ir/builtin_types.py b/mlir/test/python/ir/builtin_types.py
index 4eea1a9c372ef..cfe377c703717 100644
--- a/mlir/test/python/ir/builtin_types.py
+++ b/mlir/test/python/ir/builtin_types.py
@@ -57,8 +57,8 @@ def testTypeEq():
     print("t1 == t2:", t1 == t2)
     # CHECK: t1 == t3: True
     print("t1 == t3:", t1 == t3)
-    # CHECK: t1 == None: False
-    print("t1 == None:", t1 == None)
+    # CHECK: t1 is None: False
+    print("t1 is None:", t1 is None)
 
 
 # CHECK-LABEL: TEST: testTypeHash
@@ -143,9 +143,9 @@ def testTypeEqDoesNotRaise():
     # CHECK: False
     print(t1 == not_a_type)
     # CHECK: False
-    print(t1 == None)
+    print(t1 is None)
     # CHECK: True
-    print(t1 != None)
+    print(t1 is not None)
 
 
 # CHECK-LABEL: TEST: testTypeCapsule
diff --git a/openmp/libompd/gdb-plugin/ompd/ompd_callbacks.py b/openmp/libompd/gdb-plugin/ompd/ompd_callbacks.py
index ada09d75579f0..40eb3305f2e24 100644
--- a/openmp/libompd/gdb-plugin/ompd/ompd_callbacks.py
+++ b/openmp/libompd/gdb-plugin/ompd/ompd_callbacks.py
@@ -84,7 +84,7 @@ def _thread_context(*args):
             m = re.search(r"(0x[a-fA-F0-9]+)", line)
         elif lwp:
             m = re.search(r"\([^)]*?(\d+)[^)]*?\)", line)
-        if m == None:
+        if m is None:
             continue
         pid = int(m.group(1), 0)
         if pid == thread_id:
diff --git a/polly/lib/External/isl/libisl-gdb.py b/polly/lib/External/isl/libisl-gdb.py
index bf01bc583d15d..bdd3949cf89c0 100644
--- a/polly/lib/External/isl/libisl-gdb.py
+++ b/polly/lib/External/isl/libisl-gdb.py
@@ -70,7 +70,7 @@ def invoke(self, arg, from_tty):
         arg = gdb.parse_and_eval(arg)
         printer = str_lookup_function(arg)
 
-        if printer == None:
+        if printer is None:
             print("No isl printer for this type")
             return
 
@@ -90,7 +90,7 @@ def str_lookup_function(val):
     lookup_tag = val.type.target()
     regex = re.compile("^isl_(.*)$")
 
-    if lookup_tag == None:
+    if lookup_tag is None:
         return None
 
     m = regex.match(str(lookup_tag))
diff --git a/polly/lib/External/isl/python/isl.py.top b/polly/lib/External/isl/python/isl.py.top
index d041315d4e11d..9dc47a1a83251 100644
--- a/polly/lib/External/isl/python/isl.py.top
+++ b/polly/lib/External/isl/python/isl.py.top
@@ -3,7 +3,7 @@ from ctypes import *
 from ctypes.util import find_library
 
 isl_dyld_library_path = os.environ.get('ISL_DYLD_LIBRARY_PATH')
-if isl_dyld_library_path != None:
+if isl_dyld_library_path is not None:
     os.environ['DYLD_LIBRARY_PATH'] =  isl_dyld_library_path
 try:
     isl = cdll.LoadLibrary(isl_dlname)
@@ -29,7 +29,7 @@ class Context:
 
     @staticmethod
     def getDefaultInstance():
-        if Context.defaultInstance == None:
+        if Context.defaultInstance is None:
             Context.defaultInstance = Context()
         return Context.defaultInstance
 
diff --git a/polly/utils/pyscop/isl.py b/polly/utils/pyscop/isl.py
index 5eaf7798e20b9..c06b7bca28042 100644
--- a/polly/utils/pyscop/isl.py
+++ b/polly/utils/pyscop/isl.py
@@ -24,7 +24,7 @@ def from_ptr(ptr):
 
     @staticmethod
     def getDefaultInstance():
-        if Context.defaultInstance == None:
+        if Context.defaultInstance is None:
             Context.defaultInstance = Context()
 
         return Context.defaultInstance
@@ -33,12 +33,12 @@ def getDefaultInstance():
 class IslObject:
     def __init__(self, string="", ctx=None, ptr=None):
         self.initialize_isl_methods()
-        if ptr != None:
+        if ptr is not None:
             self.ptr = ptr
             self.ctx = self.get_isl_method("get_ctx")(self)
             return
 
-        if ctx == None:
+        if ctx is None:
             ctx = Context.getDefaultInstance()
 
         self.ctx = ctx
@@ -236,7 +236,7 @@ class Printer:
     FORMAT_EXT_POLYLIB = 6
 
     def __init__(self, ctx=None):
-        if ctx == None:
+        if ctx is None:
             ctx = Context.getDefaultInstance()
 
         self.ctx = ctx



More information about the Mlir-commits mailing list