scan-build-py: fix multiprocessing error
Recent versions of python3's multiprocessing module will blow up with
a Runtime error from this code, saying:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase
This is becuae the wrappers in bin/ are not using the `__name__ == "__main__"` idiom correctly.
Reviewed By: ldionne
Differential Revision: https://reviews.llvm.org/D87051
diff --git a/clang/tools/scan-build-py/bin/analyze-build b/clang/tools/scan-build-py/bin/analyze-build
index 6c28587..0884ef2 100755
--- a/clang/tools/scan-build-py/bin/analyze-build
+++ b/clang/tools/scan-build-py/bin/analyze-build
@@ -5,12 +5,13 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
import multiprocessing
-multiprocessing.freeze_support()
-
import sys
import os.path
this_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.dirname(this_dir))
from libscanbuild.analyze import analyze_build
-sys.exit(analyze_build())
+
+if __name__ == '__main__':
+ multiprocessing.freeze_support()
+ sys.exit(analyze_build())