[clang] 9268494 - [TableGen] Migrate away from PointerUnion::dyn_cast (NFC) (#125158)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 31 07:50:22 PST 2025


Author: Kazu Hirata
Date: 2025-01-31T07:50:18-08:00
New Revision: 9268494f03cb940de0ae4b747b447ffc07b10ea7

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

LOG: [TableGen] Migrate away from PointerUnion::dyn_cast (NFC) (#125158)

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 DiagsInPedantic and GroupsInPedantic to be nonnull.

Added: 
    

Modified: 
    clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 50dbe4d5a8cab7..8f846a4744bbf0 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -359,7 +359,7 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
 
     // The diagnostic is not included in a group that is (transitively) in
     // -Wpedantic.  Include it in -Wpedantic directly.
-    if (auto *V = DiagsInPedantic.dyn_cast<RecordVec *>())
+    if (auto *V = dyn_cast<RecordVec *>(DiagsInPedantic))
       V->push_back(R);
     else
       cast<RecordSet *>(DiagsInPedantic)->insert(R);
@@ -386,7 +386,7 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
     if (Parents.size() > 0 && AllParentsInPedantic)
       continue;
 
-    if (auto *V = GroupsInPedantic.dyn_cast<RecordVec *>())
+    if (auto *V = dyn_cast<RecordVec *>(GroupsInPedantic))
       V->push_back(Group);
     else
       cast<RecordSet *>(GroupsInPedantic)->insert(Group);


        


More information about the cfe-commits mailing list