https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/131764
Just removing some code duplication. Extracted from #131515 >From 6b62d1028d338d4ec0b67f9ee6ecfb7d29dbc67e Mon Sep 17 00:00:00 2001 From: Corentin Jabot <corentinja...@gmail.com> Date: Tue, 18 Mar 2025 09:56:43 +0100 Subject: [PATCH] [Clang][NFC] Cleanup UnaryExprOrTypeTraitExpr itanium mangling code Just removing some code duplication. Extracted from #131515 --- clang/lib/AST/ItaniumMangle.cpp | 62 +++++++++++---------------------- 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index b6ba36784f38a..c79f3e2999583 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -5327,7 +5327,19 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, } }; - switch(SAE->getKind()) { + auto MangleExtensionBuiltin = [&](const UnaryExprOrTypeTraitExpr *E, + StringRef Name = {}) { + if (Name.empty()) + Name = getTraitSpelling(E->getKind()); + mangleVendorType(Name); + if (SAE->isArgumentType()) + mangleType(SAE->getArgumentType()); + else + mangleTemplateArgExpr(SAE->getArgumentExpr()); + Out << 'E'; + }; + + switch (SAE->getKind()) { case UETT_SizeOf: Out << 's'; MangleAlignofSizeofArg(); @@ -5337,12 +5349,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, // have acted differently since Clang 8, but were previously mangled the // same.) if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) { - Out << "u11__alignof__"; - if (SAE->isArgumentType()) - mangleType(SAE->getArgumentType()); - else - mangleTemplateArgExpr(SAE->getArgumentExpr()); - Out << 'E'; + MangleExtensionBuiltin(SAE, "__alignof__"); break; } [[fallthrough]]; @@ -5350,43 +5357,16 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, Out << 'a'; MangleAlignofSizeofArg(); break; + + case UETT_VectorElements: + case UETT_OpenMPRequiredSimdAlign: + case UETT_VecStep: + case UETT_PtrAuthTypeDiscriminator: case UETT_DataSizeOf: { - DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = - Diags.getCustomDiagID(DiagnosticsEngine::Error, - "cannot yet mangle __datasizeof expression"); - Diags.Report(DiagID); - return; - } - case UETT_PtrAuthTypeDiscriminator: { - DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "cannot yet mangle __builtin_ptrauth_type_discriminator expression"); - Diags.Report(E->getExprLoc(), DiagID); - return; - } - case UETT_VecStep: { - DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, - "cannot yet mangle vec_step expression"); - Diags.Report(DiagID); - return; - } - case UETT_OpenMPRequiredSimdAlign: { - DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "cannot yet mangle __builtin_omp_required_simd_align expression"); - Diags.Report(DiagID); - return; - } - case UETT_VectorElements: { DiagnosticsEngine &Diags = Context.getDiags(); unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "cannot yet mangle __builtin_vectorelements expression"); - Diags.Report(DiagID); + DiagnosticsEngine::Error, "cannot yet mangle %0 expression"); + Diags.Report(E->getExprLoc(), DiagID) << getTraitSpelling(SAE->getKind()); return; } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits