Skip to content

[Clang][NFC] Cleanup UnaryExprOrTypeTraitExpr itanium mangling code #131764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 21 additions & 41 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -5337,56 +5349,24 @@ 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]];
case UETT_AlignOf:
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;
}
}
Expand Down
Loading