https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/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 563c7c5539f05e7f8cbb42565c1f24466019f38b
  Author: Kazu Hirata <k...@google.com>
  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.


>From 236ab9e6ddf0cb24e50f7a6d2b62eb984986079c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <k...@google.com>
Date: Sat, 1 Feb 2025 12:54:02 -0800
Subject: [PATCH] [Lex] Migrate away from PointerUnion::dyn_cast (NFC)

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 563c7c5539f05e7f8cbb42565c1f24466019f38b
  Author: Kazu Hirata <k...@google.com>
  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.
---
 clang/include/clang/Lex/Preprocessor.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 416f403c298410c..2bf4d1a16699430 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -933,7 +933,7 @@ class Preprocessor {
     }
 
     ArrayRef<ModuleMacro*> getOverriddenMacros() const {
-      if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
+      if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
         return Info->OverriddenMacros;
       return {};
     }

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to