-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang] Add and use mangleVendorType helper. NFC. #108970
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-clang Author: Jay Foad (jayfoad) ChangesFull diff: https://github.com/llvm/llvm-project/pull/108970.diff 1 Files Affected:
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index b6e1da0c3192da..ef8e91b7cbdf9f 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -468,6 +468,7 @@ class CXXNameMangler {
void mangleLambdaSig(const CXXRecordDecl *Lambda);
void mangleModuleNamePrefix(StringRef Name, bool IsPartition = false);
void mangleVendorQualifier(StringRef Name);
+ void mangleVendorType(StringRef Name);
private:
@@ -2871,6 +2872,10 @@ void CXXNameMangler::mangleVendorQualifier(StringRef name) {
Out << 'U' << name.size() << name;
}
+void CXXNameMangler::mangleVendorType(StringRef name) {
+ Out << 'u' << name.size() << name;
+}
+
void CXXNameMangler::mangleRefQualifier(RefQualifierKind RefQualifier) {
// <ref-qualifier> ::= R # lvalue reference
// ::= O # rvalue-reference
@@ -3389,8 +3394,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
if (T->getKind() == BuiltinType::SveBFloat16 && \
isCompatibleWith(LangOptions::ClangABI::Ver17)) { \
/* Prior to Clang 18.0 we used this incorrect mangled name */ \
- type_name = "__SVBFloat16_t"; \
- Out << "u" << type_name.size() << type_name; \
+ mangleVendorType("__SVBFloat16_t"); \
} else { \
type_name = MangledName; \
Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
@@ -3407,35 +3411,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
break;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_VECTOR_TYPE(Name, Id, Size) \
- case BuiltinType::Id: \
- type_name = #Name; \
- Out << 'u' << type_name.size() << type_name; \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
+ case BuiltinType::Id: \
+ mangleVendorType(#Name); \
break;
#include "clang/Basic/PPCTypes.def"
// TODO: Check the mangling scheme for RISC-V V.
#define RVV_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id: \
- type_name = Name; \
- Out << 'u' << type_name.size() << type_name; \
+ mangleVendorType(Name); \
break;
#include "clang/Basic/RISCVVTypes.def"
#define WASM_REF_TYPE(InternalName, MangledName, Id, SingletonId, AS) \
case BuiltinType::Id: \
- type_name = MangledName; \
- Out << 'u' << type_name.size() << type_name; \
+ mangleVendorType(MangledName); \
break;
#include "clang/Basic/WebAssemblyReferenceTypes.def"
#define AMDGPU_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id: \
- type_name = Name; \
- Out << 'u' << type_name.size() << type_name; \
+ mangleVendorType(Name); \
break;
#include "clang/Basic/AMDGPUTypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id: \
- type_name = #Name; \
- Out << 'u' << type_name.size() << type_name; \
+ mangleVendorType(#Name); \
break;
#include "clang/Basic/HLSLIntangibleTypes.def"
}
@@ -4006,8 +4005,9 @@ void CXXNameMangler::mangleAArch64FixedSveVectorType(const VectorType *T) {
if (T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
VecSizeInBits *= 8;
- Out << "9__SVE_VLSI" << 'u' << TypeName.size() << TypeName << "Lj"
- << VecSizeInBits << "EE";
+ Out << "9__SVE_VLSI";
+ mangleVendorType(TypeName);
+ Out << "Lj" << VecSizeInBits << "EE";
}
void CXXNameMangler::mangleAArch64FixedSveVectorType(
@@ -4107,8 +4107,9 @@ void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) {
}
TypeNameOS << "_t";
- Out << "9__RVV_VLSI" << 'u' << TypeNameStr.size() << TypeNameStr << "Lj"
- << VecSizeInBits << "EE";
+ Out << "9__RVV_VLSI";
+ mangleVendorType(TypeNameStr);
+ Out << "Lj" << VecSizeInBits << "EE";
}
void CXXNameMangler::mangleRISCVFixedRVVVectorType(
@@ -4207,8 +4208,7 @@ void CXXNameMangler::mangleType(const ConstantMatrixType *T) {
// Mangle matrix types as a vendor extended type:
// u<Len>matrix_typeI<Rows><Columns><element type>E
- StringRef VendorQualifier = "matrix_type";
- Out << "u" << VendorQualifier.size() << VendorQualifier;
+ mangleVendorType("matrix_type");
Out << "I";
auto &ASTCtx = getASTContext();
@@ -4226,8 +4226,7 @@ void CXXNameMangler::mangleType(const ConstantMatrixType *T) {
void CXXNameMangler::mangleType(const DependentSizedMatrixType *T) {
// Mangle matrix types as a vendor extended type:
// u<Len>matrix_typeI<row expr><column expr><element type>E
- StringRef VendorQualifier = "matrix_type";
- Out << "u" << VendorQualifier.size() << VendorQualifier;
+ mangleVendorType("matrix_type");
Out << "I";
mangleTemplateArgExpr(T->getRowExpr());
@@ -4273,7 +4272,7 @@ void CXXNameMangler::mangleType(const ObjCObjectType *T) {
StringRef name = I->getName();
QualOS << name.size() << name;
}
- Out << 'U' << QualStr.size() << QualStr;
+ mangleVendorQualifier(QualStr);
}
mangleType(T->getBaseType());
@@ -4407,8 +4406,6 @@ void CXXNameMangler::mangleType(const UnaryTransformType *T) {
// If this is dependent, we need to record that. If not, we simply
// mangle it as the underlying type since they are equivalent.
if (T->isDependentType()) {
- Out << "u";
-
StringRef BuiltinName;
switch (T->getUTTKind()) {
#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
@@ -4417,7 +4414,7 @@ void CXXNameMangler::mangleType(const UnaryTransformType *T) {
break;
#include "clang/Basic/TransformTypeTraits.def"
}
- Out << BuiltinName.size() << BuiltinName;
+ mangleVendorType(BuiltinName);
}
Out << "I";
@@ -5250,9 +5247,8 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity,
// <expression> ::= u <source-name> <template-arg>* E # vendor extension
const TypeTraitExpr *TTE = cast<TypeTraitExpr>(E);
NotPrimaryExpr();
- Out << 'u';
llvm::StringRef Spelling = getTraitSpelling(TTE->getTrait());
- Out << Spelling.size() << Spelling;
+ mangleVendorType(Spelling);
for (TypeSourceInfo *TSI : TTE->getArgs()) {
mangleType(TSI->getType());
}
|
rjmccall
approved these changes
Oct 30, 2024
Contributor
rjmccall
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
NoumanAmir657
pushed a commit
to NoumanAmir657/llvm-project
that referenced
this pull request
Nov 4, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.