Skip to content

[clang-tidy] bugprone-unchecked-optional-access does not seem "aware of common macros" as docs state. #62600

Open
@ablatner

Description

@ablatner

These docs suggest it will recognize macros like D/CHECK and ASSERT_THAT.
https://clang.llvm.org/extra/clang-tidy/checks/bugprone/unchecked-optional-access.html#ensure-that-a-value-exists-using-common-macros

But I don't believe it actually recognizes the macro names. It only seems to work if the checker is able to expand the macro to a return statement or stdlib assertion.

See this example: https://godbolt.org/z/xPKvqT9qv

  1. Pass: CHECK_ASSERT, calling assert from assert.h
  2. Pass: CHECK_RETURN, directly returning before value access
  3. Fail: CHECK, calling an extern handler
    • I'm interested in this case, with different handlers for embedded and for unit tests.

For some more supporting evidence, there are no examples of this in the checker's unit tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-tidyclang:dataflowClang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.htmlenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions