[clang] [Clang][ASTImporter] Fix cycle in importing template specialization on auto type with typename (PR #162514)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 24 03:16:12 PDT 2025


================
@@ -1287,6 +1287,44 @@ bool ASTNodeImporter::hasSameVisibilityContextAndLinkage(TypedefNameDecl *Found,
 
 using namespace clang;
 
+class ASTImporter::FunctionReturnTypeDeclCycleDetector {
+public:
+  class DeclCycleMapInserter {
----------------
ojhunt wrote:

I'm sorry, just the other day I finally found that we do have an existing mechanism for scoped cleanup: `llvm::make_scope_exit`

It _might_ be cleaner to mostly restore your original cleanup code, but use

```cpp
llvm::make_scope_exit([&]() { ...erase(..); }
```

to handle the cleanup (sorry, I literally only found out about this function a couple of days ago)

@shafik do you have an opinion on which path is better?

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


More information about the cfe-commits mailing list