llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Eugene Lozovoy (UzixLS)

<details>
<summary>Changes</summary>

It fails on windows 10 otherwise with:
```
Traceback (most recent call last):
 ...
  File "C:\Dev\LLVM\lib\libscanbuild\analyze.py", line 567, in
report_failure
    handle.write(" ".join(os.uname()) + os.linesep)
                          ^^^^^^^^
AttributeError: module 'os' has no attribute 'uname'. Did you mean:
'name'?
```

There was also a problem identifying the actual compiler on Windows because the 
program name have an ".exe" suffix.

---
Full diff: https://github.com/llvm/llvm-project/pull/169976.diff


2 Files Affected:

- (modified) clang/tools/scan-build-py/lib/libscanbuild/analyze.py (+2-1) 
- (modified) clang/tools/scan-build-py/lib/libscanbuild/compilation.py (+1-1) 


``````````diff
diff --git a/clang/tools/scan-build-py/lib/libscanbuild/analyze.py 
b/clang/tools/scan-build-py/lib/libscanbuild/analyze.py
index 72aac8f545240..91d3089154a9d 100644
--- a/clang/tools/scan-build-py/lib/libscanbuild/analyze.py
+++ b/clang/tools/scan-build-py/lib/libscanbuild/analyze.py
@@ -23,6 +23,7 @@
 import datetime
 import shutil
 import glob
+import platform
 from collections import defaultdict
 
 from libscanbuild import (
@@ -563,7 +564,7 @@ def destination():
         handle.write(opts["file"] + os.linesep)
         handle.write(error.title().replace("_", " ") + os.linesep)
         handle.write(" ".join(cmd) + os.linesep)
-        handle.write(" ".join(os.uname()) + os.linesep)
+        handle.write(" ".join(platform.uname()) + os.linesep)
         handle.write(get_version(opts["clang"]))
         handle.close()
     # write the captured output too
diff --git a/clang/tools/scan-build-py/lib/libscanbuild/compilation.py 
b/clang/tools/scan-build-py/lib/libscanbuild/compilation.py
index 6b9e3cabae309..e1226b338ff35 100644
--- a/clang/tools/scan-build-py/lib/libscanbuild/compilation.py
+++ b/clang/tools/scan-build-py/lib/libscanbuild/compilation.py
@@ -135,7 +135,7 @@ def compiler_language(command):
     cplusplus = re.compile(r"^(.+)(\+\+)(-.+|)$")
 
     if command:
-        executable = os.path.basename(command[0])
+        executable = os.path.basename(command[0]).removesuffix('.exe')
         if any(pattern.match(executable) for pattern in COMPILER_PATTERNS):
             return "c++" if cplusplus.match(executable) else "c"
     return None

``````````

</details>


https://github.com/llvm/llvm-project/pull/169976
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to