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

via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 30 17:58:40 PST 2025


Author: Kazu Hirata
Date: 2025-01-30T17:58:37-08:00
New Revision: fc433089e3535de3ae31c1c91194f654996529be

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

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

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 Subject to be nonnull.

Added: 
    

Modified: 
    clang/lib/Serialization/ASTWriter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index e81a441d753b5d..ef8ee5bc94d0ec 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -5359,7 +5359,7 @@ ASTWriter::WriteAST(llvm::PointerUnion<Sema *, Preprocessor *> Subject,
   llvm::TimeTraceScope scope("WriteAST", OutputFile);
   WritingAST = true;
 
-  Sema *SemaPtr = Subject.dyn_cast<Sema *>();
+  Sema *SemaPtr = dyn_cast<Sema *>(Subject);
   Preprocessor &PPRef =
       SemaPtr ? SemaPtr->getPreprocessor() : *cast<Preprocessor *>(Subject);
 


        


More information about the cfe-commits mailing list