[clang] [clang] Migrate away from PointerUnion::dyn_cast (NFC) (PR #232179)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 14 22:13:10 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

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.
Note that loadAPINotes() returns false only after storing a nonnull
APINotesReader * in Readers[*Dir].

Assisted-by: Antigravity


---
Full diff: https://github.com/llvm/llvm-project/pull/232179.diff


1 Files Affected:

- (modified) clang/lib/APINotes/APINotesManager.cpp (+1-1) 


``````````diff
diff --git a/clang/lib/APINotes/APINotesManager.cpp b/clang/lib/APINotes/APINotesManager.cpp
index 2cc801d5415b84..5c1bb41d804e99 100644
--- a/clang/lib/APINotes/APINotesManager.cpp
+++ b/clang/lib/APINotes/APINotesManager.cpp
@@ -444,7 +444,7 @@ APINotesManager::findAPINotes(SourceLocation Loc) {
       if (auto APINotesFile = FileMgr.getOptionalFileRef(APINotesPath)) {
         if (!loadAPINotes(*Dir, *APINotesFile)) {
           ++NumHeaderAPINotes;
-          if (auto Reader = Readers[*Dir].dyn_cast<APINotesReader *>())
+          if (auto Reader = dyn_cast<APINotesReader *>(Readers[*Dir]))
             Results.push_back(Reader);
           break;
         }

``````````

</details>


https://github.com/llvm/llvm-project/pull/232179


More information about the cfe-commits mailing list