[clang] [clang][ASTImporter] Remove type from ImportedTypes cache on Decl import failure (PR #214008)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 13 04:46:58 PDT 2026
================
@@ -10038,6 +10038,13 @@ Expected<Decl *> ASTImporter::Import(Decl *FromD) {
auto *ToD = CreatedToD;
ImportedDecls.erase(Pos);
+ // Also scrub the imported type mapping, if applicable. Import(Type*) can
+ // cache a type mapping to a declaration that ultimately fails.
+ if (const auto *FromTD = dyn_cast<TagDecl>(FromD))
----------------
guillem-bartrina-sonarsource wrote:
And the comment
```
// Low-level accessor. If you just want the type defined by this node,
// check out ASTContext::getTypeDeclType or one of
// ASTContext::getTypedefType, ASTContext::getTagType, etc. if you
// already know the specific kind of node this is.
```
forwards us to using `ASTContext::getTagType`
https://github.com/llvm/llvm-project/pull/214008
More information about the cfe-commits
mailing list