[all-commits] [llvm/llvm-project] 2188e6: [clang-doc] populateParentNamespaces - use cast<> ...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Sat Feb 12 03:31:49 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2188e61691ad89e27583fd3a4197322be830df59
      https://github.com/llvm/llvm-project/commit/2188e61691ad89e27583fd3a4197322be830df59
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2022-02-12 (Sat, 12 Feb 2022)

  Changed paths:
    M clang-tools-extra/clang-doc/Serialize.cpp

  Log Message:
  -----------
  [clang-doc] populateParentNamespaces - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

It's only later iterations of the loop where the getParent() call might return nullptr


  Commit: 7ad94bd74bb5e2c984f541bc1921a9eda73ed973
      https://github.com/llvm/llvm-project/commit/7ad94bd74bb5e2c984f541bc1921a9eda73ed973
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2022-02-12 (Sat, 12 Feb 2022)

  Changed paths:
    M clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp

  Log Message:
  -----------
  [clang-tidy] ContainerSizeEmptyCheck::check - simplify isa<> and dyn_cast<> repeated calls

Just use dyn_cast<> to determine literal + container values from the binop


Compare: https://github.com/llvm/llvm-project/compare/fbe0ca576d2b...7ad94bd74bb5


More information about the All-commits mailing list