Author: Ingo Müller Date: 2026-05-23T17:08:33+02:00 New Revision: 9d533e977eea1e1c0ee94515bc5dd0bd70d15d95
URL: https://github.com/llvm/llvm-project/commit/9d533e977eea1e1c0ee94515bc5dd0bd70d15d95 DIFF: https://github.com/llvm/llvm-project/commit/9d533e977eea1e1c0ee94515bc5dd0bd70d15d95.diff LOG: [clang] Fix crash in getCursorRawComments. (#199328) Fix a regression introduced in PR #198452 where querying raw comments on invalid cursors caused a segmentation fault due to unconditional ASTContext lookup. Adding an early exit for unsupported cursor kinds at the top of getCursorRawComment safely avoids resolving the context on invalid cursors with null translation units. Added: Modified: clang/tools/libclang/CIndex.cpp Removed: ################################################################################ diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index c07c4cd84bbce..85760968cdbde 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -9327,6 +9327,8 @@ CXString clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op) { } static const RawComment *getCursorRawComment(CXCursor C) { + if (!clang_isDeclaration(C.kind) && C.kind != CXCursor_MacroDefinition) + return nullptr; ASTContext &Context = getCursorContext(C); if (clang_isDeclaration(C.kind)) return Context.getRawCommentForAnyRedecl(getCursorDecl(C)); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
