[cfe-dev] Why is the MangleContext not owned by ASTContext?

Haidl, Michael via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 7 23:53:36 PST 2018


Hi list, 

I was trying to extend Clang with a new PredefinedExpr that basically does the same as __FUNCDNAME__ and was getting unexpected results for mangling function names with lambdas as parameters. It was unexpected for me, because every lambda gets ID 0 in its mangles name and I tracked it down to the way the MangleContext is handled. In PredefinedExpr::ComputeName createMangleContext from the ASTContext is called and after the mangling is done the context is thrown away which is why I just got 0s. Anyway, I would like to know why the MC is not owned by the ASTContext? Are there use cases where more than one MC is necessary? Can something break if the MC is alive for the entire compilation from AST creation to CG?

Cheers, 
Michael Haidl



More information about the cfe-dev mailing list