[all-commits] [llvm/llvm-project] a19fa7: [clang-doc] Avoid deref of invalid std::optional

Paul Kirth via All-commits all-commits at lists.llvm.org
Wed Mar 19 16:16:23 PDT 2025


  Branch: refs/heads/users/ilovepi/clang-doc-fix-optional
  Home:   https://github.com/llvm/llvm-project
  Commit: a19fa7568d92b7d0c980fa1313d0bcb177be4987
      https://github.com/llvm/llvm-project/commit/a19fa7568d92b7d0c980fa1313d0bcb177be4987
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2025-03-19 (Wed, 19 Mar 2025)

  Changed paths:
    M clang-tools-extra/clang-doc/HTMLGenerator.cpp
    A clang-tools-extra/test/clang-doc/DR-131697.cpp

  Log Message:
  -----------
  [clang-doc] Avoid deref of invalid std::optional

Since our existing guard is insufficient to prevent accessing the
std::optional when in an invalid state, guard the access with
`.value_or()`. This maintains the desired behavior, without running into
UB.

The new test should prevent regressions.

Fixes #131697



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