[clang-tools-extra] b68a952 - [clang-doc] Migrate away from PointerUnion::{is,get} (NFC) (#120872)

via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 22 01:30:12 PST 2024


Author: Kazu Hirata
Date: 2024-12-22T01:30:08-08:00
New Revision: b68a952ae1c06b78790eab758574d992159e33b8

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

LOG: [clang-doc] Migrate away from PointerUnion::{is,get} (NFC) (#120872)

Note that PointerUnion::{is,get} have 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>

Added: 
    

Modified: 
    clang-tools-extra/clang-doc/Serialize.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp
index 93efdd44f45898..f737fc75135a19 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -696,13 +696,11 @@ emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
 
     // What this is a specialization of.
     auto SpecOf = CTSD->getSpecializedTemplateOrPartial();
-    if (SpecOf.is<ClassTemplateDecl *>()) {
-      Specialization.SpecializationOf =
-          getUSRForDecl(SpecOf.get<ClassTemplateDecl *>());
-    } else if (SpecOf.is<ClassTemplatePartialSpecializationDecl *>()) {
-      Specialization.SpecializationOf =
-          getUSRForDecl(SpecOf.get<ClassTemplatePartialSpecializationDecl *>());
-    }
+    if (auto *CTD = dyn_cast<ClassTemplateDecl *>(SpecOf))
+      Specialization.SpecializationOf = getUSRForDecl(CTD);
+    else if (auto *CTPSD =
+                 dyn_cast<ClassTemplatePartialSpecializationDecl *>(SpecOf))
+      Specialization.SpecializationOf = getUSRForDecl(CTPSD);
 
     // Parameters to the specilization. For partial specializations, get the
     // parameters "as written" from the ClassTemplatePartialSpecializationDecl


        


More information about the cfe-commits mailing list