[all-commits] [llvm/llvm-project] 813325: [Clang][NFC] Change uses of getAs() to castAs() wh...

Tom Honermann via All-commits all-commits at lists.llvm.org
Thu Mar 6 15:12:43 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 813325e5d44c01f50aaca035629fcba8157fd5c0
      https://github.com/llvm/llvm-project/commit/813325e5d44c01f50aaca035629fcba8157fd5c0
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2025-03-06 (Thu, 06 Mar 2025)

  Changed paths:
    M clang/lib/CodeGen/Targets/AArch64.cpp
    M clang/lib/Sema/SemaTemplateVariadic.cpp

  Log Message:
  -----------
  [Clang][NFC] Change uses of getAs() to castAs() where the target type is assured. (#130188)

Static analysis identified two uses of `getAs()` for which the result
pointer was unconditionally dereferenced. Source code inspection
confirmed that the target type is assured by prior checks. This change
replaces these uses of `getAs()` with `castAs()`.

The first case, in `clang/lib/CodeGen/Targets/AArch64.cpp`, performs a
cast to `BuiltinType` following a check for `isBuiltinType()`.

The second case, in `clang/lib/Sema/SemaTemplateVariadic.cpp`, performs
a cast to `PackExpansionType` on the result of a call to `getAsType()`
on an object of type `TemplateArgument` following confirmation that
`isPackExpansion()` returned true and that `getKind()` returned
`TemplateArgument::Type`. Inspection of `isPackExpansion()` revealed
that it only returns true when the template argument kind is
`TemplateArgument::Type` if `isa<PackExpansionType>(getAsType())` is
true.



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