zequanwu created this revision. zequanwu added reviewers: CaseyCarter, rnk. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Bug filed here: https://bugs.llvm.org/show_bug.cgi?id=45213 To resolve it, we could mangle the `LambdaContextDecl` if it is top level decl. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D80153 Files: clang/lib/AST/MicrosoftMangle.cpp Index: clang/lib/AST/MicrosoftMangle.cpp =================================================================== --- clang/lib/AST/MicrosoftMangle.cpp +++ clang/lib/AST/MicrosoftMangle.cpp @@ -948,11 +948,13 @@ mangleSourceName(Name); // If the context of a closure type is an initializer for a class - // member (static or nonstatic), it is encoded in a qualified name. + // member (static or nonstatic) or is a top level decl, it is encoded + // in a qualified name. if (LambdaManglingNumber && LambdaContextDecl) { if ((isa<VarDecl>(LambdaContextDecl) || isa<FieldDecl>(LambdaContextDecl)) && - LambdaContextDecl->getDeclContext()->isRecord()) { + (LambdaContextDecl->getDeclContext()->isRecord() || + LambdaContextDecl->getDeclContext()->isTranslationUnit())) { mangleUnqualifiedName(cast<NamedDecl>(LambdaContextDecl)); } }
Index: clang/lib/AST/MicrosoftMangle.cpp =================================================================== --- clang/lib/AST/MicrosoftMangle.cpp +++ clang/lib/AST/MicrosoftMangle.cpp @@ -948,11 +948,13 @@ mangleSourceName(Name); // If the context of a closure type is an initializer for a class - // member (static or nonstatic), it is encoded in a qualified name. + // member (static or nonstatic) or is a top level decl, it is encoded + // in a qualified name. if (LambdaManglingNumber && LambdaContextDecl) { if ((isa<VarDecl>(LambdaContextDecl) || isa<FieldDecl>(LambdaContextDecl)) && - LambdaContextDecl->getDeclContext()->isRecord()) { + (LambdaContextDecl->getDeclContext()->isRecord() || + LambdaContextDecl->getDeclContext()->isTranslationUnit())) { mangleUnqualifiedName(cast<NamedDecl>(LambdaContextDecl)); } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits