Skip to content

Commit 2767f4b

Browse files
[Lex] Migrate away from PointerUnion::dyn_cast (NFC) (#125380)
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 State is not guaranteed to be nonnull elsewhere in this class. 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 43b7124 commit 2767f4b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/include/clang/Lex/Preprocessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ class Preprocessor {
933933
}
934934

935935
ArrayRef<ModuleMacro*> getOverriddenMacros() const {
936-
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
936+
if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
937937
return Info->OverriddenMacros;
938938
return {};
939939
}

0 commit comments

Comments
 (0)