[PATCH] D147742: [python] Enable bindings tests on Windows

2023-04-07 Thread Artur Ryt via Phabricator via cfe-commits
R2RT added a comment.

According to CI logs, these tests are still not run on Windows builder.
Line below, present in Debian's log, is missing.

  [9746/10613] cd 
/var/lib/buildkite-agent/builds/llvm-project/clang/bindings/python && 
/usr/bin/cmake -E env CLANG_NO_DEFAULT_CONFIG=1 
CLANG_LIBRARY_PATH=/var/lib/buildkite-agent/builds/llvm-project/build/lib 
/usr/bin/python3.9 -m unittest discover

Further investigation is needed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147742/new/

https://reviews.llvm.org/D147742

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147742: [python] Enable bindings tests on Windows

2023-04-06 Thread Artur Ryt via Phabricator via cfe-commits
R2RT created this revision.
R2RT added a project: clang.
Herald added a project: All.
R2RT requested review of this revision.
Herald added a subscriber: cfe-commits.

Unlike stated by removed comment, they do simply pass in my local enviroment.

In order to find necessary fixes (if any), CI has to run these tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147742

Files:
  clang/bindings/python/tests/CMakeLists.txt


Index: clang/bindings/python/tests/CMakeLists.txt
===
--- clang/bindings/python/tests/CMakeLists.txt
+++ clang/bindings/python/tests/CMakeLists.txt
@@ -28,12 +28,6 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
-# Tests fail on Windows, and need someone knowledgeable to fix.
-# It's not clear whether it's a test or a valid binding problem.
-if(WIN32)
-  set(RUN_PYTHON_TESTS FALSE)
-endif()
-
 # The Python FFI interface is broken on AIX: 
https://bugs.python.org/issue38628.
 if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
   set(RUN_PYTHON_TESTS FALSE)


Index: clang/bindings/python/tests/CMakeLists.txt
===
--- clang/bindings/python/tests/CMakeLists.txt
+++ clang/bindings/python/tests/CMakeLists.txt
@@ -28,12 +28,6 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
-# Tests fail on Windows, and need someone knowledgeable to fix.
-# It's not clear whether it's a test or a valid binding problem.
-if(WIN32)
-  set(RUN_PYTHON_TESTS FALSE)
-endif()
-
 # The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
 if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
   set(RUN_PYTHON_TESTS FALSE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147414: [python] Expose clang_Location_isInSystemHeader

2023-04-03 Thread Artur Ryt via Phabricator via cfe-commits
R2RT added a comment.

In D147414#4240343 , @aaron.ballman 
wrote:

> LGTM! Do you need someone to land this on your behalf? If so, please let me 
> know what name and email address you would like for patch attribution.
>
> In D147414#4239453 , @R2RT wrote:
>
>> I thought about adding it into release notes, but recently Python section 
>> has got removed from ReleaseNotes.rst, so I am not sure what to do now: 
>> https://reviews.llvm.org/D142578
>
> The section was removed mostly because the python bindings weren't getting a 
> lot of updates. I think this deserves a release note, so let's add the python 
> bindings section back in and put a note under it for this.

I've brought back Python section with relevant note.

I have no idea how to land it, it is my first contribution here, so maybe it 
will be easier this way.
Please attribute it to Artur Ryt , thanks :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147414/new/

https://reviews.llvm.org/D147414

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147414: [python] Expose clang_Location_isInSystemHeader

2023-04-03 Thread Artur Ryt via Phabricator via cfe-commits
R2RT updated this revision to Diff 510542.
R2RT added a comment.

Bring back Python section in release notes and document new 
`is_in_system_header` property.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147414/new/

https://reviews.llvm.org/D147414

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_location.py
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -436,6 +436,13 @@
 Sanitizers
 --
 
+Python Binding Changes
+--
+
+The following methods have been added:
+
+- `clang_Location_isInSystemHeader` exposed via `is_in_system_header` property
+  of `Location` class.
 
 Additional Information
 ==
Index: clang/bindings/python/tests/cindex/test_location.py
===
--- clang/bindings/python/tests/cindex/test_location.py
+++ clang/bindings/python/tests/cindex/test_location.py
@@ -7,6 +7,7 @@
 from clang.cindex import File
 from clang.cindex import SourceLocation
 from clang.cindex import SourceRange
+from clang.cindex import TranslationUnit
 from .util import get_cursor
 from .util import get_tu
 
@@ -103,3 +104,17 @@
 location3 = SourceLocation.from_position(tu, file, 1, 6)
 range3 = SourceRange.from_locations(location1, location3)
 self.assertNotEqual(range1, range3)
+
+def test_is_system_location(self):
+header = os.path.normpath('./fake/fake.h')
+tu = TranslationUnit.from_source('fake.c', 
[f'-isystem{os.path.dirname(header)}'], unsaved_files = [
+('fake.c', """
+#include 
+int one;
+"""),
+(header, "int two();")
+])
+one = get_cursor(tu, 'one')
+two = get_cursor(tu, 'two')
+self.assertFalse(one.location.is_in_system_header)
+self.assertTrue(two.location.is_in_system_header)
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -286,6 +286,11 @@
 """Get the file offset represented by this source location."""
 return self._get_instantiation()[3]
 
+@property
+def is_in_system_header(self):
+"""Returns true if the given source location is in a system header."""
+return conf.lib.clang_Location_isInSystemHeader(self)
+
 def __eq__(self, other):
 return conf.lib.clang_equalLocations(self, other)
 
@@ -4131,6 +4136,10 @@
[Cursor],
c_longlong),
 
+  ("clang_Location_isInSystemHeader",
+   [SourceLocation],
+   bool),
+
   ("clang_Type_getAlignOf",
[Type],
c_longlong),


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -436,6 +436,13 @@
 Sanitizers
 --
 
+Python Binding Changes
+--
+
+The following methods have been added:
+
+- `clang_Location_isInSystemHeader` exposed via `is_in_system_header` property
+  of `Location` class.
 
 Additional Information
 ==
Index: clang/bindings/python/tests/cindex/test_location.py
===
--- clang/bindings/python/tests/cindex/test_location.py
+++ clang/bindings/python/tests/cindex/test_location.py
@@ -7,6 +7,7 @@
 from clang.cindex import File
 from clang.cindex import SourceLocation
 from clang.cindex import SourceRange
+from clang.cindex import TranslationUnit
 from .util import get_cursor
 from .util import get_tu
 
@@ -103,3 +104,17 @@
 location3 = SourceLocation.from_position(tu, file, 1, 6)
 range3 = SourceRange.from_locations(location1, location3)
 self.assertNotEqual(range1, range3)
+
+def test_is_system_location(self):
+header = os.path.normpath('./fake/fake.h')
+tu = TranslationUnit.from_source('fake.c', [f'-isystem{os.path.dirname(header)}'], unsaved_files = [
+('fake.c', """
+#include 
+int one;
+"""),
+(header, "int two();")
+])
+one = get_cursor(tu, 'one')
+two = get_cursor(tu, 'two')
+self.assertFalse(one.location.is_in_system_header)
+self.assertTrue(two.location.is_in_system_header)
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -286,6 +286,11 @@
 """Get the file offset represented by this source location."""
 return self._get_instantiation()[3]
 
+@property
+def is_in_system_header(self):
+"""Returns true if the given source location is in a system header."""
+return 

[PATCH] D147414: [python] Expose clang_Location_isInSystemHeader

2023-04-02 Thread Artur Ryt via Phabricator via cfe-commits
R2RT added a comment.

I thought about adding it into release notes, but recently Python section has 
got removed from ReleaseNotes.rst, so I am not sure what to do now: 
https://reviews.llvm.org/D142578


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147414/new/

https://reviews.llvm.org/D147414

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147414: [python] Expose clang_Location_isInSystemHeader

2023-04-02 Thread Artur Ryt via Phabricator via cfe-commits
R2RT created this revision.
R2RT added a reviewer: aaron.ballman.
R2RT added a project: clang.
Herald added a subscriber: arphaman.
Herald added a project: All.
R2RT requested review of this revision.
Herald added a subscriber: cfe-commits.

Add `is_in_system_header` property for `Location` class.

Corresponding unit test was also added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147414

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_location.py


Index: clang/bindings/python/tests/cindex/test_location.py
===
--- clang/bindings/python/tests/cindex/test_location.py
+++ clang/bindings/python/tests/cindex/test_location.py
@@ -7,6 +7,7 @@
 from clang.cindex import File
 from clang.cindex import SourceLocation
 from clang.cindex import SourceRange
+from clang.cindex import TranslationUnit
 from .util import get_cursor
 from .util import get_tu
 
@@ -103,3 +104,17 @@
 location3 = SourceLocation.from_position(tu, file, 1, 6)
 range3 = SourceRange.from_locations(location1, location3)
 self.assertNotEqual(range1, range3)
+
+def test_is_system_location(self):
+header = os.path.normpath('./fake/fake.h')
+tu = TranslationUnit.from_source('fake.c', 
[f'-isystem{os.path.dirname(header)}'], unsaved_files = [
+('fake.c', """
+#include 
+int one;
+"""),
+(header, "int two();")
+])
+one = get_cursor(tu, 'one')
+two = get_cursor(tu, 'two')
+self.assertFalse(one.location.is_in_system_header)
+self.assertTrue(two.location.is_in_system_header)
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -286,6 +286,11 @@
 """Get the file offset represented by this source location."""
 return self._get_instantiation()[3]
 
+@property
+def is_in_system_header(self):
+"""Returns true if the given source location is in a system header."""
+return conf.lib.clang_Location_isInSystemHeader(self)
+
 def __eq__(self, other):
 return conf.lib.clang_equalLocations(self, other)
 
@@ -4131,6 +4136,10 @@
[Cursor],
c_longlong),
 
+  ("clang_Location_isInSystemHeader",
+   [SourceLocation],
+   bool),
+
   ("clang_Type_getAlignOf",
[Type],
c_longlong),


Index: clang/bindings/python/tests/cindex/test_location.py
===
--- clang/bindings/python/tests/cindex/test_location.py
+++ clang/bindings/python/tests/cindex/test_location.py
@@ -7,6 +7,7 @@
 from clang.cindex import File
 from clang.cindex import SourceLocation
 from clang.cindex import SourceRange
+from clang.cindex import TranslationUnit
 from .util import get_cursor
 from .util import get_tu
 
@@ -103,3 +104,17 @@
 location3 = SourceLocation.from_position(tu, file, 1, 6)
 range3 = SourceRange.from_locations(location1, location3)
 self.assertNotEqual(range1, range3)
+
+def test_is_system_location(self):
+header = os.path.normpath('./fake/fake.h')
+tu = TranslationUnit.from_source('fake.c', [f'-isystem{os.path.dirname(header)}'], unsaved_files = [
+('fake.c', """
+#include 
+int one;
+"""),
+(header, "int two();")
+])
+one = get_cursor(tu, 'one')
+two = get_cursor(tu, 'two')
+self.assertFalse(one.location.is_in_system_header)
+self.assertTrue(two.location.is_in_system_header)
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -286,6 +286,11 @@
 """Get the file offset represented by this source location."""
 return self._get_instantiation()[3]
 
+@property
+def is_in_system_header(self):
+"""Returns true if the given source location is in a system header."""
+return conf.lib.clang_Location_isInSystemHeader(self)
+
 def __eq__(self, other):
 return conf.lib.clang_equalLocations(self, other)
 
@@ -4131,6 +4136,10 @@
[Cursor],
c_longlong),
 
+  ("clang_Location_isInSystemHeader",
+   [SourceLocation],
+   bool),
+
   ("clang_Type_getAlignOf",
[Type],
c_longlong),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-16 Thread Artur Ryt via Phabricator via cfe-commits
R2RT reopened this revision.
R2RT added a comment.
This revision is now accepted and ready to land.

Hey, all, as for me it seems that this commit introduced a few problems with 
Python3 (at least 3.7)

  sys.stdout.write(' '.join(invocation) + '\n' + output + '\n')
  TypeError: can only concatenate str (not "bytes") to str

Then

  if err > 0:
  TypeError: '>' not supported between instances of 'bytes' and 'int'

Then

  sys.stderr.write(err + '\n')
  TypeError: can't concat str to bytes

Given the code:

After fixes:

  with lock:
sys.stdout.write(' '.join(invocation) + '\n' + str(output) + '\n')
if err:
  sys.stderr.write(str(err) + '\n')
  queue.task_done()

But I propose to use


Repository:
  rL LLVM

https://reviews.llvm.org/D49851



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits