llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Dave Bartolomeo (dbartol) <details> <summary>Changes</summary> This change converts all existing uses of `getCustomDiagID()` within the `clang/AST` library into regular diagnostics defined in `DiagnosticASTKinds.td`. This is mostly just cleanup, but it will also help with future changes to the diagnostic system by letting us focus on the custom diagnostic scenarios that _don't_ fit into the usual pre-declared diagnostic scenario. --- Full diff: https://github.com/llvm/llvm-project/pull/172532.diff 6 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticASTKinds.td (+34) - (modified) clang/lib/AST/ASTContext.cpp (+3-3) - (modified) clang/lib/AST/ItaniumMangle.cpp (+23-42) - (modified) clang/lib/AST/MicrosoftCXXABI.cpp (+2-3) - (modified) clang/lib/AST/MicrosoftMangle.cpp (+5-9) - (modified) clang/lib/AST/VTableBuilder.cpp (+2-4) ``````````diff diff --git a/clang/include/clang/Basic/DiagnosticASTKinds.td b/clang/include/clang/Basic/DiagnosticASTKinds.td index e90ee9d376e07..11f1f1e56bf72 100644 --- a/clang/include/clang/Basic/DiagnosticASTKinds.td +++ b/clang/include/clang/Basic/DiagnosticASTKinds.td @@ -606,6 +606,8 @@ def warn_odr_objc_synthesize_ivar_inconsistent : Warning< InGroup<ODR>; def note_odr_objc_synthesize_ivar_here : Note< "property is synthesized to ivar %0 here">; +def err_unsupported_objc_primitive_encoding + : Error<"cannot yet @encode type %0">; // Importing C++ ASTs def note_odr_friend : Note<"friend declared here">; @@ -1043,6 +1045,38 @@ def warn_npot_ms_struct : Warning< def err_itanium_layout_unimplemented : Error< "Itanium-compatible layout for the Microsoft C++ ABI is not yet supported">; +// Unsupported features in name mangling +def err_itanium_mangle_fixed_point_literal + : Error<"cannot mangle fixed point literals yet">; +def err_itanium_mangle_dependent_neon_vector + : Error<"cannot mangle this dependent neon vector type yet">; +def err_itanium_mangle_dependent_fixed_length_sve_vector + : Error<"cannot mangle this dependent fixed-length SVE vector type yet">; +def err_itanium_mangle_dependent_fixed_length_rvv_vector + : Error<"cannot mangle this dependent fixed-length RVV vector type yet">; +def err_itanium_mangle_requires_expr_with_substitution_failure + : Error<"cannot mangle this requires-expression containing a substitution " + "failure">; +def err_itanium_mangle_unsupported_expr_type + : Error<"cannot yet mangle expression type %0">; +def err_itanium_mangle_ternary_omitted_operand + : Error<"?: operator with omitted middle operand cannot be mangled">; +def err_itanium_mangle_unsupported_expr + : Error<"cannot yet mangle %0 expression">; +def err_itanium_mangle_openacc_asterisk_size_expr + : Error<"cannot yet mangle OpenACC Asterisk Size expression">; +def err_itanium_mangle_unnamed_union_nttp + : Error<"cannot mangle this unnamed union NTTP yet">; + +def err_ms_mangle_number_overflow + : Error<"mangling number exceeds limit (65535)">; +def err_ms_mangle_unsupported_with_detail + : Error<"cannot mangle this %0 %1 yet">; +def err_ms_mangle_unsupported : Error<"cannot mangle this %0 yet">; + +def err_unexpected_vftable_component + : Error<"unexpected vftable component type %0 for component number %1">; + // -Wpadded-bitfield def warn_padded_struct_bitfield : Warning< "padding %select{struct|interface|class}0 %1 with %2 " diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index f52470a4d7458..85f8b02b92f70 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -50,6 +50,7 @@ #include "clang/Basic/AddressSpaces.h" #include "clang/Basic/Builtins.h" #include "clang/Basic/CommentOptions.h" +#include "clang/Basic/DiagnosticAST.h" #include "clang/Basic/ExceptionSpecificationType.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" @@ -9107,9 +9108,8 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C, #include "clang/Basic/AMDGPUTypes.def" { DiagnosticsEngine &Diags = C->getDiagnostics(); - unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, - "cannot yet @encode type %0"); - Diags.Report(DiagID) << BT->getName(C->getPrintingPolicy()); + Diags.Report(diag::err_unsupported_objc_primitive_encoding) + << BT->getName(C->getPrintingPolicy()); return ' '; } diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index fe12a506643c9..f8be6ce786a7d 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -28,6 +28,7 @@ #include "clang/AST/Mangle.h" #include "clang/AST/TypeLoc.h" #include "clang/Basic/ABI.h" +#include "clang/Basic/DiagnosticAST.h" #include "clang/Basic/Module.h" #include "clang/Basic/TargetInfo.h" #include "clang/Basic/Thunk.h" @@ -1249,9 +1250,7 @@ void CXXNameMangler::mangleFloatLiteral(QualType T, const llvm::APFloat &V) { void CXXNameMangler::mangleFixedPointLiteral() { DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, "cannot mangle fixed point literals yet"); - Diags.Report(DiagID); + Diags.Report(diag::err_itanium_mangle_fixed_point_literal); } void CXXNameMangler::mangleNullPointer(QualType T) { @@ -3969,10 +3968,8 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) { void CXXNameMangler::mangleNeonVectorType(const DependentVectorType *T) { DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "cannot mangle this dependent neon vector type yet"); - Diags.Report(T->getAttributeLoc(), DiagID); + Diags.Report(T->getAttributeLoc(), + diag::err_itanium_mangle_dependent_neon_vector); } static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) { @@ -4048,10 +4045,8 @@ void CXXNameMangler::mangleAArch64NeonVectorType(const VectorType *T) { } void CXXNameMangler::mangleAArch64NeonVectorType(const DependentVectorType *T) { DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "cannot mangle this dependent neon vector type yet"); - Diags.Report(T->getAttributeLoc(), DiagID); + Diags.Report(T->getAttributeLoc(), + diag::err_itanium_mangle_dependent_neon_vector); } // The AArch64 ACLE specifies that fixed-length SVE vector and predicate types @@ -4146,10 +4141,8 @@ void CXXNameMangler::mangleAArch64FixedSveVectorType(const VectorType *T) { void CXXNameMangler::mangleAArch64FixedSveVectorType( const DependentVectorType *T) { DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "cannot mangle this dependent fixed-length SVE vector type yet"); - Diags.Report(T->getAttributeLoc(), DiagID); + Diags.Report(T->getAttributeLoc(), + diag::err_itanium_mangle_dependent_fixed_length_sve_vector); } void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) { @@ -4252,10 +4245,8 @@ void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) { void CXXNameMangler::mangleRISCVFixedRVVVectorType( const DependentVectorType *T) { DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "cannot mangle this dependent fixed-length RVV vector type yet"); - Diags.Report(T->getAttributeLoc(), DiagID); + Diags.Report(T->getAttributeLoc(), + diag::err_itanium_mangle_dependent_fixed_length_rvv_vector); } // GNU extension: vector types @@ -4784,10 +4775,9 @@ void CXXNameMangler::mangleRequirement(SourceLocation RequiresExprLoc, auto HandleSubstitutionFailure = [&](SourceLocation Loc) { DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, "cannot mangle this requires-expression " - "containing a substitution failure"); - Diags.Report(Loc, DiagID); + Diags.Report( + Loc, + diag::err_itanium_mangle_requires_expr_with_substitution_failure); Out << 'F'; }; @@ -4988,10 +4978,9 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, if (!NullOut) { // As bad as this diagnostic is, it's better than crashing. DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, - "cannot yet mangle expression type %0"); - Diags.Report(E->getExprLoc(), DiagID) - << E->getStmtClassName() << E->getSourceRange(); + Diags.Report(E->getExprLoc(), + diag::err_itanium_mangle_unsupported_expr_type) + << E->getStmtClassName() << E->getSourceRange(); return; } break; @@ -5027,11 +5016,9 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, case Expr::BinaryConditionalOperatorClass: { NotPrimaryExpr(); DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = - Diags.getCustomDiagID(DiagnosticsEngine::Error, - "?: operator with omitted middle operand cannot be mangled"); - Diags.Report(E->getExprLoc(), DiagID) - << E->getStmtClassName() << E->getSourceRange(); + Diags.Report(E->getExprLoc(), + diag::err_itanium_mangle_ternary_omitted_operand) + << E->getStmtClassName() << E->getSourceRange(); return; } @@ -5402,9 +5389,8 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, case UETT_PtrAuthTypeDiscriminator: case UETT_DataSizeOf: { DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, "cannot yet mangle %0 expression"); - Diags.Report(E->getExprLoc(), DiagID) << getTraitSpelling(SAE->getKind()); + Diags.Report(E->getExprLoc(), diag::err_itanium_mangle_unsupported_expr) + << getTraitSpelling(SAE->getKind()); return; } } @@ -5906,10 +5892,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, case Expr::OpenACCAsteriskSizeExprClass: { // We shouldn't ever be able to get here, but diagnose anyway. DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "cannot yet mangle OpenACC Asterisk Size expression"); - Diags.Report(DiagID); + Diags.Report(diag::err_itanium_mangle_openacc_asterisk_size_expr); return; } } @@ -6527,9 +6510,7 @@ static IdentifierInfo *getUnionInitName(SourceLocation UnionLoc, // of the data members in the union are unnamed), then there is no way for a // program to refer to the anonymous union, and there is therefore no need to // mangle its name. However, we should diagnose this anyway. - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, "cannot mangle this unnamed union NTTP yet"); - Diags.Report(UnionLoc, DiagID); + Diags.Report(UnionLoc, diag::err_itanium_mangle_unnamed_union_nttp); return nullptr; } diff --git a/clang/lib/AST/MicrosoftCXXABI.cpp b/clang/lib/AST/MicrosoftCXXABI.cpp index 1c020c3ad4ad5..438feac9ca9b2 100644 --- a/clang/lib/AST/MicrosoftCXXABI.cpp +++ b/clang/lib/AST/MicrosoftCXXABI.cpp @@ -20,6 +20,7 @@ #include "clang/AST/MangleNumberingContext.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/Type.h" +#include "clang/Basic/DiagnosticAST.h" #include "clang/Basic/TargetInfo.h" using namespace clang; @@ -83,9 +84,7 @@ class MSHIPNumberingContext : public MicrosoftNumberingContext { MicrosoftNumberingContext::getManglingNumber(TD, MSLocalManglingNumber); if (DeviceN > 0xFFFF || HostN > 0xFFFF) { DiagnosticsEngine &Diags = TD->getASTContext().getDiagnostics(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, "Mangling number exceeds limit (65535)"); - Diags.Report(TD->getLocation(), DiagID); + Diags.Report(TD->getLocation(), diag::err_ms_mangle_number_overflow); } return (DeviceN << 16) | HostN; } diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 551aa7bf3321c..388094096d294 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -25,6 +25,7 @@ #include "clang/AST/Mangle.h" #include "clang/AST/VTableBuilder.h" #include "clang/Basic/ABI.h" +#include "clang/Basic/DiagnosticAST.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" @@ -578,25 +579,20 @@ DiagnosticBuilder MicrosoftCXXNameMangler::Error(SourceLocation loc, StringRef thing1, StringRef thing2) { DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, - "cannot mangle this %0 %1 yet"); - return Diags.Report(loc, DiagID) << thing1 << thing2; + return Diags.Report(loc, diag::err_ms_mangle_unsupported_with_detail) + << thing1 << thing2; } DiagnosticBuilder MicrosoftCXXNameMangler::Error(SourceLocation loc, StringRef thingy) { DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, - "cannot mangle this %0 yet"); - return Diags.Report(loc, DiagID) << thingy; + return Diags.Report(loc, diag::err_ms_mangle_unsupported) << thingy; } DiagnosticBuilder MicrosoftCXXNameMangler::Error(StringRef thingy) { DiagnosticsEngine &Diags = Context.getDiags(); // extra placeholders are ignored quietly when not used - unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, - "cannot mangle this %0 yet"); - return Diags.Report(DiagID) << thingy; + return Diags.Report(diag::err_ms_mangle_unsupported) << thingy; } void MicrosoftCXXNameMangler::mangle(GlobalDecl GD, StringRef Prefix) { diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp index d97f10cb9d1a1..5987b18e6cd6c 100644 --- a/clang/lib/AST/VTableBuilder.cpp +++ b/clang/lib/AST/VTableBuilder.cpp @@ -3315,10 +3315,8 @@ void VFTableBuilder::dumpLayout(raw_ostream &Out) { default: DiagnosticsEngine &Diags = Context.getDiagnostics(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "Unexpected vftable component type %0 for component number %1"); - Diags.Report(MostDerivedClass->getLocation(), DiagID) + Diags.Report(MostDerivedClass->getLocation(), + diag::err_unexpected_vftable_component) << I << Component.getKind(); } `````````` </details> https://github.com/llvm/llvm-project/pull/172532 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
