[all-commits] [llvm/llvm-project] 42179b: [clang-tidy] Add check for possibly incomplete swi...

shivam-amd via All-commits all-commits at lists.llvm.org
Sun Jul 16 22:11:35 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 42179bbf6bcc9f90256b443c30f5e99f862bc2f6
      https://github.com/llvm/llvm-project/commit/42179bbf6bcc9f90256b443c30f5e99f862bc2f6
  Author: Shivam Gupta <Shivam.Gupta2 at amd.com>
  Date:   2023-07-17 (Mon, 17 Jul 2023)

  Changed paths:
    M clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
    M clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
    A clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
    A clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.h
    M clang-tools-extra/docs/ReleaseNotes.rst
    A clang-tools-extra/docs/clang-tidy/checks/bugprone/switch-missing-default-case.rst
    M clang-tools-extra/docs/clang-tidy/checks/list.rst
    A clang-tools-extra/test/clang-tidy/checkers/bugprone/switch-missing-default-case.cpp

  Log Message:
  -----------
  [clang-tidy] Add check for possibly incomplete switch statements

While clang warns about a possibly incomplete switch statement when switching over an enum variable and failing to cover all enum values (either explicitly or with a default case), no such warning is emitted if a plain integer variable is used as switch variable.

Add a clang-tidy check to diagnose these scenarios.

No fixit hint is provided since there are multiple possible solutions.

Differential Revision: https://reviews.llvm.org/D4784




More information about the All-commits mailing list