Skip to content

Commit 43b7124

Browse files
[AST] Migrate away from PointerUnion::dyn_cast (NFC) (#125379)
Note that PointerUnion::dyn_cast has been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> This patch migrates the use of PointerUnion::dyn_cast to dyn_cast_if_present because the non-const variant of getInitializedFieldInUnion is known to encounter null in ArrayFillerOrUnionFieldInit. See: commit 563c7c5 Author: Kazu Hirata <[email protected]> Date: Sat Jan 25 14:05:01 2025 -0800 FWIW, I am not aware of any test case in check-clang that triggers null here.
1 parent 2f98ae5 commit 43b7124

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/include/clang/AST/ExprCXX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5040,7 +5040,7 @@ class CXXParenListInitExpr final
50405040
}
50415041

50425042
const FieldDecl *getInitializedFieldInUnion() const {
5043-
return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5043+
return dyn_cast_if_present<FieldDecl *>(ArrayFillerOrUnionFieldInit);
50445044
}
50455045

50465046
child_range children() {

0 commit comments

Comments
 (0)