"""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)
[Cursor],
c_longlong),
+ ("clang_Location_isInSystemHeader",
+ [SourceLocation],
+ bool),
+
("clang_Type_getAlignOf",
[Type],
c_longlong),
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
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 <fake.h>
+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)
Sanitizers
----------
+Python Binding Changes
+----------------------
+The following methods have been added:
+
+- ``clang_Location_isInSystemHeader`` exposed via the ``is_in_system_header``
+ property of the `Location` class.
Additional Information
======================