[all-commits] [llvm/llvm-project] 338615: [clang][ExtractAPI] fix a couple crashes when used...

QuietMisdreavus via All-commits all-commits at lists.llvm.org
Wed Mar 26 16:46:42 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3386156b1e8418083e99833d3d22420cf439c039
      https://github.com/llvm/llvm-project/commit/3386156b1e8418083e99833d3d22420cf439c039
  Author: QuietMisdreavus <QuietMisdreavus at users.noreply.github.com>
  Date:   2025-03-26 (Wed, 26 Mar 2025)

  Changed paths:
    M clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
    M clang/lib/ExtractAPI/DeclarationFragments.cpp
    A clang/test/Index/extract-api-cursor-cpp.cpp

  Log Message:
  -----------
  [clang][ExtractAPI] fix a couple crashes when used via libclang (#132297)

This PR fixes two crashes in ExtractAPI that occur when decls are
requested via libclang:

- A null-dereference would sometimes happen in
`DeclarationFragmentsBuilder::getFragmentsForClassTemplateSpecialization`
when the template being processed was loaded indirectly via a typedef,
with parameters filled in. The first commit loads the template parameter
locations ahead of time to perform a null check before dereferencing.
- An assertion (or another null-dereference) was happening in
`CXXRecordDecl::bases` when processing a forward-declaration (i.e. a
record without a definition). The second commit guards the use of
`bases` in `ExtractAPIVisitorBase::getBases` by first checking that the
decl in question has a complete definition.

The added test `extract-api-cursor-cpp` adds tests for these two
scenarios to protect against the crash in the future.

Fixes rdar://140592475, fixes rdar://123430367



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list