[clang] 8e4c5cb - [Serialization] Migrate away from PointerUnion::dyn_cast (NFC) (#124884)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 29 07:48:51 PST 2025


Author: Kazu Hirata
Date: 2025-01-29T07:48:48-08:00
New Revision: 8e4c5cb0063e1c73a3f93073f5f85c8ec598613f

URL: https://github.com/llvm/llvm-project/commit/8e4c5cb0063e1c73a3f93073f5f85c8ec598613f
DIFF: https://github.com/llvm/llvm-project/commit/8e4c5cb0063e1c73a3f93073f5f85c8ec598613f.diff

LOG: [Serialization] Migrate away from PointerUnion::dyn_cast (NFC) (#124884)

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>

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect DetailRecord to be nonnull.

Added: 
    

Modified: 
    clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 651553244812f2..2daf8393b1819a 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -475,7 +475,7 @@ addConstraintSatisfaction(ASTRecordWriter &Record,
   if (!Satisfaction.IsSatisfied) {
     Record.push_back(Satisfaction.NumRecords);
     for (const auto &DetailRecord : Satisfaction) {
-      auto *E = DetailRecord.dyn_cast<Expr *>();
+      auto *E = dyn_cast<Expr *>(DetailRecord);
       Record.push_back(/* IsDiagnostic */ E == nullptr);
       if (E)
         Record.AddStmt(E);


        


More information about the cfe-commits mailing list