================
@@ -5120,6 +5121,10 @@ bool Sema::addInstantiatedParametersToScope(
       // Simple case: not a parameter pack.
       assert(FParamIdx < Function->getNumParams());
       ParmVarDecl *FunctionParam = Function->getParamDecl(FParamIdx);
+      DeclarationName name = FunctionParam->getDeclName();
+      auto _ = llvm::make_scope_exit([&]() {
+        FunctionParam->setDeclName(name);
----------------
mark-de-wever-sonarsource wrote:

This approach is based on what Richard suggested in 
https://github.com/llvm/llvm-project/issues/54279#issuecomment-2623325977 " for 
example, we need to set the name back when we're done with it.".

The crash is caused due to another scope-exit. In that scope a `FETokenInfo` 
"attached" to the name of the function argument. This function is unaware of 
that scope so the "rename" is unknown to that scope and at that scope's 
scope-exit the information "attached" to the current name (_not_ the original 
name) is removed. This is where an assertion triggers.

So this change basically restores the original name so the other scope-exit 
will "detach" the `FETokenInfo` using the original name and the crash is 
resolved.

https://github.com/llvm/llvm-project/pull/142338
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to