Skip to content

[libclang/python] Add typing annotations for the Type class #140378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2025

Conversation

DeinAlptraum
Copy link
Contributor

This fully annotates the Type class, resolving 75 strict typing errors as the next step towards #76664

@DeinAlptraum DeinAlptraum requested a review from Endilll May 17, 2025 14:06
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:as-a-library libclang and C++ API labels May 17, 2025
@llvmbot
Copy link
Member

llvmbot commented May 17, 2025

@llvm/pr-subscribers-clang

Author: Jannick Kremer (DeinAlptraum)

Changes

This fully annotates the Type class, resolving 75 strict typing errors as the next step towards #76664


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

1 Files Affected:

  • (modified) clang/bindings/python/clang/cindex.py (+61-66)
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index a49441e815004..f65bcad780a70 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -91,6 +91,7 @@
     cast as Tcast,
     Generic,
     Iterator,
+    Literal,
     Optional,
     Sequence,
     Type as TType,
@@ -1982,7 +1983,7 @@ def type(self) -> Type:
         Retrieve the Type (if any) of the entity pointed at by the cursor.
         """
         if not hasattr(self, "_type"):
-            self._type = Type.from_result(conf.lib.clang_getCursorType(self), (self,))
+            self._type = Type.from_result(conf.lib.clang_getCursorType(self), self)
 
         return self._type
 
@@ -2009,7 +2010,7 @@ def result_type(self) -> Type:
         """Retrieve the Type of the result for this Cursor."""
         if not hasattr(self, "_result_type"):
             self._result_type = Type.from_result(
-                conf.lib.clang_getCursorResultType(self), (self,)
+                conf.lib.clang_getCursorResultType(self), self
             )
 
         return self._result_type
@@ -2040,7 +2041,7 @@ def underlying_typedef_type(self) -> Type:
         if not hasattr(self, "_underlying_type"):
             assert self.kind.is_declaration()
             self._underlying_type = Type.from_result(
-                conf.lib.clang_getTypedefDeclUnderlyingType(self), (self,)
+                conf.lib.clang_getTypedefDeclUnderlyingType(self), self
             )
 
         return self._underlying_type
@@ -2056,7 +2057,7 @@ def enum_type(self) -> Type:
         if not hasattr(self, "_enum_type"):
             assert self.kind == CursorKind.ENUM_DECL
             self._enum_type = Type.from_result(
-                conf.lib.clang_getEnumDeclIntegerType(self), (self,)
+                conf.lib.clang_getEnumDeclIntegerType(self), self
             )
 
         return self._enum_type
@@ -2197,7 +2198,7 @@ def get_template_argument_kind(self, num: int) -> TemplateArgumentKind:
     def get_template_argument_type(self, num: int) -> Type:
         """Returns the CXType for the indicated template argument."""
         return Type.from_result(
-            conf.lib.clang_Cursor_getTemplateArgumentType(self, num), (self, num)
+            conf.lib.clang_Cursor_getTemplateArgumentType(self, num), self
         )
 
     @cursor_null_guard
@@ -2597,8 +2598,10 @@ class Type(Structure):
 
     _fields_ = [("_kind_id", c_int), ("data", c_void_p * 2)]
 
+    _tu: TranslationUnit
+
     @property
-    def kind(self):
+    def kind(self) -> TypeKind:
         """Return the kind of this type."""
         return TypeKind.from_id(self._kind_id)
 
@@ -2635,7 +2638,7 @@ def __getitem__(self, key: int) -> Type:
                     )
 
                 result = Type.from_result(
-                    conf.lib.clang_getArgType(self.parent, key), (self.parent, key)
+                    conf.lib.clang_getArgType(self.parent, key), self.parent
                 )
                 if result.kind == TypeKind.INVALID:
                     raise IndexError("Argument could not be retrieved.")
@@ -2646,63 +2649,56 @@ def __getitem__(self, key: int) -> Type:
         return ArgumentsIterator(self)
 
     @property
-    def element_type(self):
+    def element_type(self) -> Type:
         """Retrieve the Type of elements within this Type.
 
         If accessed on a type that is not an array, complex, or vector type, an
         exception will be raised.
         """
-        result = Type.from_result(conf.lib.clang_getElementType(self), (self,))
+        result = Type.from_result(conf.lib.clang_getElementType(self), self)
         if result.kind == TypeKind.INVALID:
             raise Exception("Element type not available on this type.")
 
         return result
 
     @property
-    def element_count(self):
+    def element_count(self) -> int:
         """Retrieve the number of elements in this type.
 
         Returns an int.
 
         If the Type is not an array or vector, this raises.
         """
-        result = conf.lib.clang_getNumElements(self)
+        result: int = conf.lib.clang_getNumElements(self)
         if result < 0:
             raise Exception("Type does not have elements.")
 
         return result
 
     @property
-    def translation_unit(self):
+    def translation_unit(self) -> TranslationUnit:
         """The TranslationUnit to which this Type is associated."""
         # If this triggers an AttributeError, the instance was not properly
         # instantiated.
         return self._tu
 
     @staticmethod
-    def from_result(res, args):
+    def from_result(res: Type, arg: Cursor | Type) -> Type:
         assert isinstance(res, Type)
-
-        tu = None
-        for arg in args:
-            if hasattr(arg, "translation_unit"):
-                tu = arg.translation_unit
-                break
-
-        assert tu is not None
-        res._tu = tu
+        assert arg.translation_unit is not None
+        res._tu = arg.translation_unit
 
         return res
 
-    def get_num_template_arguments(self):
+    def get_num_template_arguments(self) -> int:
         return conf.lib.clang_Type_getNumTemplateArguments(self)  # type: ignore [no-any-return]
 
-    def get_template_argument_type(self, num):
+    def get_template_argument_type(self, num: int) -> Type:
         return Type.from_result(
-            conf.lib.clang_Type_getTemplateArgumentAsType(self, num), (self, num)
+            conf.lib.clang_Type_getTemplateArgumentAsType(self, num), self
         )
 
-    def get_canonical(self):
+    def get_canonical(self) -> Type:
         """
         Return the canonical type for a Type.
 
@@ -2712,9 +2708,11 @@ def get_canonical(self):
         example, if 'T' is a typedef for 'int', the canonical type for
         'T' would be 'int'.
         """
-        return Type.from_result(conf.lib.clang_getCanonicalType(self), (self,))
+        return Type.from_result(conf.lib.clang_getCanonicalType(self), self)
 
-    def get_fully_qualified_name(self, policy, with_global_ns_prefix=False):
+    def get_fully_qualified_name(
+        self, policy: PrintingPolicy, with_global_ns_prefix: bool = False
+    ) -> str:
         """
         Get the fully qualified name for a type.
 
@@ -2727,7 +2725,7 @@ def get_fully_qualified_name(self, policy, with_global_ns_prefix=False):
             conf.lib.clang_getFullyQualifiedName(self, policy, with_global_ns_prefix)
         )
 
-    def is_const_qualified(self):
+    def is_const_qualified(self) -> bool:
         """Determine whether a Type has the "const" qualifier set.
 
         This does not look through typedefs that may have added "const"
@@ -2735,7 +2733,7 @@ def is_const_qualified(self):
         """
         return conf.lib.clang_isConstQualifiedType(self)  # type: ignore [no-any-return]
 
-    def is_volatile_qualified(self):
+    def is_volatile_qualified(self) -> bool:
         """Determine whether a Type has the "volatile" qualifier set.
 
         This does not look through typedefs that may have added "volatile"
@@ -2743,7 +2741,7 @@ def is_volatile_qualified(self):
         """
         return conf.lib.clang_isVolatileQualifiedType(self)  # type: ignore [no-any-return]
 
-    def is_restrict_qualified(self):
+    def is_restrict_qualified(self) -> bool:
         """Determine whether a Type has the "restrict" qualifier set.
 
         This does not look through typedefs that may have added "restrict" at
@@ -2751,29 +2749,29 @@ def is_restrict_qualified(self):
         """
         return conf.lib.clang_isRestrictQualifiedType(self)  # type: ignore [no-any-return]
 
-    def is_function_variadic(self):
+    def is_function_variadic(self) -> bool:
         """Determine whether this function Type is a variadic function type."""
         assert self.kind == TypeKind.FUNCTIONPROTO
 
         return conf.lib.clang_isFunctionTypeVariadic(self)  # type: ignore [no-any-return]
 
-    def get_address_space(self):
+    def get_address_space(self) -> int:
         return conf.lib.clang_getAddressSpace(self)  # type: ignore [no-any-return]
 
-    def get_typedef_name(self):
+    def get_typedef_name(self) -> str:
         return _CXString.from_result(conf.lib.clang_getTypedefName(self))
 
-    def is_pod(self):
+    def is_pod(self) -> bool:
         """Determine whether this Type represents plain old data (POD)."""
         return conf.lib.clang_isPODType(self)  # type: ignore [no-any-return]
 
-    def get_pointee(self):
+    def get_pointee(self) -> Type:
         """
         For pointer types, returns the type of the pointee.
         """
-        return Type.from_result(conf.lib.clang_getPointeeType(self), (self,))
+        return Type.from_result(conf.lib.clang_getPointeeType(self), self)
 
-    def get_declaration(self):
+    def get_declaration(self) -> Cursor:
         """
         Return the cursor for the declaration of the given type.
         """
@@ -2781,64 +2779,64 @@ def get_declaration(self):
             conf.lib.clang_getTypeDeclaration(self), self
         )
 
-    def get_result(self):
+    def get_result(self) -> Type:
         """
         Retrieve the result type associated with a function type.
         """
-        return Type.from_result(conf.lib.clang_getResultType(self), (self,))
+        return Type.from_result(conf.lib.clang_getResultType(self), self)
 
-    def get_array_element_type(self):
+    def get_array_element_type(self) -> Type:
         """
         Retrieve the type of the elements of the array type.
         """
-        return Type.from_result(conf.lib.clang_getArrayElementType(self), (self,))
+        return Type.from_result(conf.lib.clang_getArrayElementType(self), self)
 
-    def get_array_size(self):
+    def get_array_size(self) -> int:
         """
         Retrieve the size of the constant array.
         """
         return conf.lib.clang_getArraySize(self)  # type: ignore [no-any-return]
 
-    def get_class_type(self):
+    def get_class_type(self) -> Type:
         """
         Retrieve the class type of the member pointer type.
         """
-        return Type.from_result(conf.lib.clang_Type_getClassType(self), (self,))
+        return Type.from_result(conf.lib.clang_Type_getClassType(self), self)
 
-    def get_named_type(self):
+    def get_named_type(self) -> Type:
         """
         Retrieve the type named by the qualified-id.
         """
-        return Type.from_result(conf.lib.clang_Type_getNamedType(self), (self,))
+        return Type.from_result(conf.lib.clang_Type_getNamedType(self), self)
 
-    def get_align(self):
+    def get_align(self) -> int:
         """
         Retrieve the alignment of the record.
         """
         return conf.lib.clang_Type_getAlignOf(self)  # type: ignore [no-any-return]
 
-    def get_size(self):
+    def get_size(self) -> int:
         """
         Retrieve the size of the record.
         """
         return conf.lib.clang_Type_getSizeOf(self)  # type: ignore [no-any-return]
 
-    def get_offset(self, fieldname):
+    def get_offset(self, fieldname: str) -> int:
         """
         Retrieve the offset of a field in the record.
         """
         return conf.lib.clang_Type_getOffsetOf(self, fieldname)  # type: ignore [no-any-return]
 
-    def get_ref_qualifier(self):
+    def get_ref_qualifier(self) -> RefQualifierKind:
         """
         Retrieve the ref-qualifier of the type.
         """
         return RefQualifierKind.from_id(conf.lib.clang_Type_getCXXRefQualifier(self))
 
-    def get_fields(self):
+    def get_fields(self) -> Iterator[Cursor]:
         """Return an iterator for accessing the fields of this type."""
 
-        def visitor(field, children):
+        def visitor(field: Cursor, _: Any) -> Literal[1]:
             assert not field.is_null()
 
             # Create reference to TU so it isn't GC'd before Cursor.
@@ -2850,10 +2848,10 @@ def visitor(field, children):
         conf.lib.clang_Type_visitFields(self, fields_visit_callback(visitor), fields)
         return iter(fields)
 
-    def get_bases(self):
+    def get_bases(self) -> Iterator[Cursor]:
         """Return an iterator for accessing the base classes of this type."""
 
-        def visitor(base, children):
+        def visitor(base: Cursor, _: Any) -> Literal[1]:
             assert not base.is_null()
 
             # Create reference to TU so it isn't GC'd before Cursor.
@@ -2865,10 +2863,10 @@ def visitor(base, children):
         conf.lib.clang_visitCXXBaseClasses(self, fields_visit_callback(visitor), bases)
         return iter(bases)
 
-    def get_methods(self):
+    def get_methods(self) -> Iterator[Cursor]:
         """Return an iterator for accessing the methods of this type."""
 
-        def visitor(method, children):
+        def visitor(method: Cursor, _: Any) -> Literal[1]:
             assert not method.is_null()
 
             # Create reference to TU so it isn't GC'd before Cursor.
@@ -2880,7 +2878,7 @@ def visitor(method, children):
         conf.lib.clang_visitCXXMethods(self, fields_visit_callback(visitor), methods)
         return iter(methods)
 
-    def get_exception_specification_kind(self):
+    def get_exception_specification_kind(self) -> ExceptionSpecificationKind:
         """
         Return the kind of the exception specification; a value from
         the ExceptionSpecificationKind enumeration.
@@ -2890,21 +2888,18 @@ def get_exception_specification_kind(self):
         )
 
     @property
-    def spelling(self):
+    def spelling(self) -> str:
         """Retrieve the spelling of this Type."""
         return _CXString.from_result(conf.lib.clang_getTypeSpelling(self))
 
-    def pretty_printed(self, policy):
+    def pretty_printed(self, policy: PrintingPolicy) -> str:
         """Pretty-prints this Type with the given PrintingPolicy"""
         return _CXString.from_result(conf.lib.clang_getTypePrettyPrinted(self, policy))
 
-    def __eq__(self, other):
-        if not isinstance(other, Type):
-            return False
-
-        return conf.lib.clang_equalTypes(self, other)  # type: ignore [no-any-return]
+    def __eq__(self, other: object) -> bool:
+        return isinstance(other, Type) and conf.lib.clang_equalTypes(self, other)
 
-    def __ne__(self, other):
+    def __ne__(self, other: object) -> bool:
         return not self.__eq__(other)
 
 

Copy link
Contributor

@Endilll Endilll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our error handling story is bad and inconsistent, but that's out of scope of this PR

@DeinAlptraum DeinAlptraum merged commit 3ccb15d into llvm:main May 18, 2025
16 checks passed
@DeinAlptraum DeinAlptraum deleted the annotate branch May 18, 2025 07:43
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 18, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux-bootstrap-msan running on sanitizer-buildbot9 while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/94/builds/7226

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 87316 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: lld :: ELF/x86-property-relocatable.s (86795 of 87316)
******************** TEST 'lld :: ELF/x86-property-relocatable.s' FAILED ********************
Exit Code: 134

Command Output (stderr):
--
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -filetype=obj -triple=x86_64-unknown-linux /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/x86-property-relocatable.s -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o # RUN: at line 2
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -filetype=obj -triple=x86_64-unknown-linux /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/x86-property-relocatable.s -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld -r /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp2.o # RUN: at line 3
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld -r /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp2.o
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x0000ac5b8e0179f4 ___interceptor_backtrace /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/../sanitizer_common/sanitizer_common_interceptors.inc:4517:13
 #1 0x0000ac5b8e2074a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:808:7
 #2 0x0000ac5b8e201ea4 llvm::sys::RunSignalHandlers() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #3 0x0000ac5b8e208658 SignalHandler(int, siginfo_t*, void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
 #4 0x0000ac5b8e049b20 IsInInterceptorScope /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:77:10
 #5 0x0000ac5b8e049b20 SignalAction(int, void*, void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1137:3
 #6 0x0000f000116dd8f8 (linux-vdso.so.1+0x8f8)
 #7 0x0000f000110e2f5c (/lib/aarch64-linux-gnu/libc.so.6+0xa2f5c)
 #8 0x0000ac5b8e05742c __msan::SetShadow(void const*, unsigned long, unsigned char) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_poisoning.cpp:217:12
 #9 0x0000ac5b8e056680 __msan::MsanThread::ClearShadowForThreadStackAndTLS() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:31:7
#10 0x0000ac5b8e0567e8 malloc_storage /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.h:45:59
#11 0x0000ac5b8e0567e8 __msan::MsanThread::Init() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:45:3
#12 0x0000ac5b8dffc524 MsanThreadStartFunc(void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1156:22
#13 0x0000f000110c595c (/lib/aarch64-linux-gnu/libc.so.6+0x8595c)
#14 0x0000f0001112ba4c (/lib/aarch64-linux-gnu/libc.so.6+0xeba4c)
MemorySanitizer:DEADLYSIGNAL
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build0/bin/llvm-symbolizer: error: 'linux-vdso.so.1': No such file or directory
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.script: line 3: 1892740 Aborted                 /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld -r /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp2.o

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--------------------------------------------------------------------------
124.53s: Clang :: Driver/fsanitize.c
97.17s: Clang :: Preprocessor/riscv-target-features.c
79.48s: Clang :: OpenMP/target_defaultmap_codegen_01.cpp
Step 11 (stage2/msan check) failure: stage2/msan check (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 87316 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: lld :: ELF/x86-property-relocatable.s (86795 of 87316)
******************** TEST 'lld :: ELF/x86-property-relocatable.s' FAILED ********************
Exit Code: 134

Command Output (stderr):
--
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -filetype=obj -triple=x86_64-unknown-linux /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/x86-property-relocatable.s -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o # RUN: at line 2
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -filetype=obj -triple=x86_64-unknown-linux /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/x86-property-relocatable.s -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld -r /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp2.o # RUN: at line 3
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld -r /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp2.o
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x0000ac5b8e0179f4 ___interceptor_backtrace /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/../sanitizer_common/sanitizer_common_interceptors.inc:4517:13
 #1 0x0000ac5b8e2074a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:808:7
 #2 0x0000ac5b8e201ea4 llvm::sys::RunSignalHandlers() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #3 0x0000ac5b8e208658 SignalHandler(int, siginfo_t*, void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
 #4 0x0000ac5b8e049b20 IsInInterceptorScope /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:77:10
 #5 0x0000ac5b8e049b20 SignalAction(int, void*, void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1137:3
 #6 0x0000f000116dd8f8 (linux-vdso.so.1+0x8f8)
 #7 0x0000f000110e2f5c (/lib/aarch64-linux-gnu/libc.so.6+0xa2f5c)
 #8 0x0000ac5b8e05742c __msan::SetShadow(void const*, unsigned long, unsigned char) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_poisoning.cpp:217:12
 #9 0x0000ac5b8e056680 __msan::MsanThread::ClearShadowForThreadStackAndTLS() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:31:7
#10 0x0000ac5b8e0567e8 malloc_storage /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.h:45:59
#11 0x0000ac5b8e0567e8 __msan::MsanThread::Init() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:45:3
#12 0x0000ac5b8dffc524 MsanThreadStartFunc(void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1156:22
#13 0x0000f000110c595c (/lib/aarch64-linux-gnu/libc.so.6+0x8595c)
#14 0x0000f0001112ba4c (/lib/aarch64-linux-gnu/libc.so.6+0xeba4c)
MemorySanitizer:DEADLYSIGNAL
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build0/bin/llvm-symbolizer: error: 'linux-vdso.so.1': No such file or directory
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.script: line 3: 1892740 Aborted                 /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld -r /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/x86-property-relocatable.s.tmp2.o

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--------------------------------------------------------------------------
124.53s: Clang :: Driver/fsanitize.c
97.17s: Clang :: Preprocessor/riscv-target-features.c
79.48s: Clang :: OpenMP/target_defaultmap_codegen_01.cpp

@llvm-ci
Copy link
Collaborator

llvm-ci commented May 18, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-windows running on premerge-windows-1 while building clang at step 5 "clean-build-dir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/35/builds/10177

Here is the relevant piece of the build log for the reference
Step 5 (clean-build-dir) failure: Delete failed. (failure)
Step 8 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'lit :: timeout-hang.py' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 13
not env -u FILECHECK_OPTS "C:\Python39\python.exe" C:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\utils\lit\lit.py -j1 --order=lexical Inputs/timeout-hang/run-nonexistent.txt  --timeout=1 --param external=0 | "C:\Python39\python.exe" C:\ws\buildbot\premerge-monolithic-windows\build\utils\lit\tests\timeout-hang.py 1
# executed command: not env -u FILECHECK_OPTS 'C:\Python39\python.exe' 'C:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\utils\lit\lit.py' -j1 --order=lexical Inputs/timeout-hang/run-nonexistent.txt --timeout=1 --param external=0
# .---command stderr------------
# | lit.py: C:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\utils\lit\lit\main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 1 seconds was requested on the command line. Forcing timeout to be 1 seconds.
# `-----------------------------
# executed command: 'C:\Python39\python.exe' 'C:\ws\buildbot\premerge-monolithic-windows\build\utils\lit\tests\timeout-hang.py' 1
# .---command stdout------------
# | Testing took as long or longer than timeout
# `-----------------------------
# error: command failed with exit status: 1

--

********************


@DeinAlptraum
Copy link
Contributor Author

@Endilll

Our error handling story is bad and inconsistent, but that's out of scope of this PR

What sort of improvements would you like to see?

Also possibly related, reminder that #102410 is still open

@llvm-ci
Copy link
Collaborator

llvm-ci commented May 18, 2025

LLVM Buildbot has detected a new failure on builder clang-s390x-linux-lnt running on systemz-1 while building clang at step 13 "setup lit".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/136/builds/3945

Here is the relevant piece of the build log for the reference
Step 13 (setup lit) failure: '/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/bin/python /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/lnt/setup.py ...' (failure)
running develop
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/lib/python3.10/site-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running egg_info
writing LNT.egg-info/PKG-INFO
writing dependency_links to LNT.egg-info/dependency_links.txt
writing entry points to LNT.egg-info/entry_points.txt
writing requirements to LNT.egg-info/requires.txt
writing top-level names to LNT.egg-info/top_level.txt
reading manifest file 'LNT.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'tests/*/Output'
no previously-included directories found matching 'tests/*/*/Output'
adding license file 'LICENSE.TXT'
writing manifest file 'LNT.egg-info/SOURCES.txt'
running build_ext
copying build/lib.linux-s390x-3.10/lnt/testing/profile/cPerf.cpython-310-s390x-linux-gnu.so -> lnt/testing/profile
Creating /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/lib/python3.10/site-packages/LNT.egg-link (link to .)
Adding LNT 0.4.2.dev0 to easy-install.pth file
Installing lnt script to /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/bin

Installed /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/lnt
Processing dependencies for LNT==0.4.2.dev0
Searching for typing
Reading https://pypi.org/simple/typing/
Download error on https://pypi.org/simple/typing/: [Errno -3] Temporary failure in name resolution -- Some packages may not be found!
Couldn't find index page for 'typing' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
No local packages or working download links found for typing
error: Could not find suitable distribution for Requirement.parse('typing')

@Endilll
Copy link
Contributor

Endilll commented May 18, 2025

LLVM Buildbot has detected a new failure on builder clang-s390x-linux-lnt running on systemz-1 while building clang at step 13 "setup lit".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/136/builds/3945
Here is the relevant piece of the build log for the reference

We should be more consistent about mapping invalid types and invalid cursor to exceptions:

if result.kind == TypeKind.INVALID:
raise Exception("Element type not available on this type.")

We also need an exception hierarchy that can hold various invalid kinds of cursors.

@Endilll
Copy link
Contributor

Endilll commented May 18, 2025

LLVM Buildbot has detected a new failure on builder clang-s390x-linux-lnt running on systemz-1 while building clang at step 13 "setup lit".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/136/builds/3945
Here is the relevant piece of the build log for the reference

@uweigand it seems that it's a rather common (yet intermittent) failure with this particular bot. Can you look into it?

@uweigand
Copy link
Member

@Endilll thanks for the heads-up! Looks like there has been some issue with network connectivity in our test lab over the weekend. This is supposed to be resolved now; I'll keep observing the status for a bit.

ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 6, 2025
)

This fully annotates the Type class, resolving 75 strict typing errors
as the next step towards llvm#76664
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:as-a-library libclang and C++ API clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants