use crate::clang::diagnostics::{
ClangSourceLocation, DiagSeverity, FixItHint, SourceRange, StructuredDiagnostic,
};
use std::collections::{BTreeMap, HashMap, HashSet};
use std::fmt;
use std::io::{self, Write};
use std::path::Path;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum X86FullDiagID {
LexIllegalChar,
LexInvalidToken,
LexUnterminatedString,
LexUnterminatedChar,
LexInvalidEscapeSequence,
LexInvalidUniversalCharName,
LexInvalidRawStringDelim,
LexInvalidRawStringPrefix,
LexNumericLiteralTooLarge,
LexInvalidSuffix,
LexTrigraphWarning,
LexTrigraphIgnored,
LexDigraph,
LexHeaderName,
LexNullCharInFile,
LexUnicodeSurrogate,
LexUTF8InvalidByte,
LexMultibyteChar,
LexWhitespaceRequired,
LexHexEscapeOutOfRange,
LexOctalEscapeOutOfRange,
LexInlineASM,
LexHashInNonDirective,
LexUnknownPragma,
LexUnterminatedBlockComment,
LexNestedBlockComment,
LexNullDirective,
LexEmptySourceFile,
LexBOMDetected,
LexEncodingWarning,
LexCRLFInRawString,
LexEmbeddedDirective,
LexLongUTF8Sequence,
LexNonASCIIIdentifier,
LexReservedIdentifier,
LexDollarInIdentifier,
LexUnderscoreReserved,
LexAlternativeToken,
LexOperatorSpelling,
LexHexFloatLiteral,
LexBinaryLiteral,
LexComplexLiteral,
LexImaginaryLiteral,
LexUserDefinedLiteralRaw,
LexUserDefinedLiteralCooked,
LexCharLiteralMultiChar,
LexCharLiteralWide,
LexCharLiteralUTF8,
LexCharLiteralUTF16,
LexCharLiteralUTF32,
LexStringLiteralWide,
LexStringLiteralUTF8,
LexStringLiteralUTF16,
LexStringLiteralUTF32,
LexStringLiteralConcat,
LexTooManyContinuations,
LexMissingNewlineAtEOF,
LexExtraNewlineAtEOF,
LexOffsetExceedsFile,
PPMacroRedefined,
PPMacroNotDefined,
PPInvalidMacroName,
PPUnterminatedMacro,
PPExtraTokensAtEndOfDirective,
PPMissingEndif,
PPElifWithoutIf,
PPElseWithoutIf,
PPEndifWithoutIf,
PPInvalidDirective,
PPWrongNumberOfMacroArgs,
PPTooFewMacroArgs,
PPTooManyMacroArgs,
PPBuiltinMacroRedefined,
PPPragmaOnceInMainFile,
PPPragmaMessage,
PPPragmaSystemHeader,
PPPragmaDiagnosticPush,
PPPragmaDiagnosticPop,
PPAttributePushPopMismatch,
PPIncludeNestedTooDeeply,
PPHeaderNotFound,
PPHeaderCannotOpen,
PPInvalidIncludeDirective,
PPIncludeNextInPrimaryFile,
PPWarningDirective,
PPErrorDirective,
PPImportInMacro,
PPIncludeMacroUsage,
PPUndefOfBuiltin,
PPMacroAsArgument,
PPNullArgInVariadic,
PPEmptyVariadicMacro,
PPGNUVariadicMacro,
PPC99VariadicMacro,
PPMSVariadicMacro,
PPMissingWhitespaceAfterMacro,
PPPragmaUnused,
PPMacroExpansionTooDeep,
PPStringifyEmpty,
PPHashHashSingleHash,
PPLineDirective,
PPFileDirective,
PPBadPaste,
PPBadStringify,
PPEmptyTranslationUnit,
PPPragmaGCCSystemHeader,
PPPragmaGCCDependency,
PPPragmaGCCPoison,
PPPragmaGCCVisibility,
PPPragmaClangAttribute,
PPPragmaClangDiagnostic,
PPPragmaClangModule,
PPMacroUsedBeforeDefined,
PPMacroRedefinedDifferent,
PPMacroArgUnused,
PPMacroArgNameConflict,
PPMacroArgReserved,
PPDefinedOperatorInMacro,
PPPragmaAlign,
PPPragmaPack,
PPPragmaPackShow,
PPPragmaComment,
PPHeaderGuardMismatch,
PPPragmaOnceWarning,
PPFileNotUTF8,
PPImplicitDefine,
PPImplicitInclude,
PPDateMacro,
PPTimeMacro,
PPFileMacro,
PPLineMacro,
PPCounterMacro,
PPFunctionMacro,
PPBaseFileMacro,
PPIncludeDepthExceeded,
PPPragmaRegion,
PPPragmaEndRegion,
PPUnterminatedConditional,
PPBadTokenPaste,
ParseExpectedToken,
ParseUnexpectedToken,
ParseExpectedExpression,
ParseExpectedType,
ParseExpectedIdentifier,
ParseExpectedFunctionBody,
ParseMissingSemicolon,
ParseMissingClosingBrace,
ParseMissingClosingParen,
ParseMissingClosingBracket,
ParseDuplicateDeclaration,
ParseConflictingTypes,
ParseRedefinition,
ParseTypedefRedefinition,
ParseEnumRedefinition,
ParseLabelRedefinition,
ParseUndeclaredIdentifier,
ParseImplicitDeclaration,
ParseTypeMismatch,
ParseIncompatibleTypes,
ParseInvalidCast,
ParseVoidExpression,
ParseVoidParameter,
ParseVoidReturn,
ParseEmptyDeclaration,
ParseStorageClassSpecifier,
ParseDuplicateSpecifier,
ParseInvalidStorageClass,
ParseMultipleStorageClasses,
ParseThreadNotStatic,
ParseUnexpectedTypedef,
ParseExpectedComma,
ParseExpectedColon,
ParseExpectedRBrace,
ParseExpectedRParen,
ParseExpectedRBracket,
ParseExpectedSemiAfterExpr,
ParseExpectedSemiAfterDecl,
ParseExpectedStatement,
ParseExpectedDeclaration,
ParseExpectedParameter,
ParseExpectedLoopBody,
ParseExpectedSwitchBody,
ParseExpectedCaseOrDefault,
ParseExpectedStructUnion,
ParseExpectedEnumBody,
ParseExpectedEqual,
ParseExpectedAngleBracket,
ParseExpectedTypeSpecifier,
ParseExpectedDeclarator,
ParseExpectedQualifiedName,
ParseExpectedCompoundStmt,
ParseExpectedInitializer,
ParseExpectedArrow,
ParseExpectedDot,
ParseExpectedOperatorName,
ParseExpectedProperty,
ParseExtraneousToken,
ParseEOFExpected,
ParseUnrecognizedDeclaration,
ParseDanglingElse,
ParseAmbiguousElse,
ParseExpectedAsm,
ParseInvalidAsm,
ParseExpectedAttribute,
ParseVexingParse,
ParseMostVexingParse,
ParseFunctionDefNoPrototype,
ParseKandRParameters,
ParseOldStyleDefinition,
ParseNestedFunction,
ParseGNUStatementExpression,
ParseGNULocalLabel,
ParseGNUConditionalOmittedOperand,
ParseGNUDesignator,
ParseGNUAttribute,
ParseDeclspecAttribute,
ParseAlignasInvalid,
ParseAlignasOnParam,
ParseAlignasOnBitField,
ParseAtomicQualified,
ParseNoreturnOnNonFunction,
ParseInlineOnMain,
ParseDeprecatedMessage,
ParseUnavailableMessage,
ParseUnexpectedTemplateKeyword,
ParseExpectedTemplateArgList,
ParseExpectedBaseClause,
ParseExpectedCtorInitializer,
ParseInvalidPureSpecifier,
ParseUnexpectedFriend,
ParseFriendOnLocalClass,
ParseUnexpectedVirtual,
ParseVirtualInUnion,
ParsePureInNonVirtual,
ParseFinalInWrongContext,
ParseOverrideOutsideClass,
ParseExpectedLambdaBody,
ParseInvalidLambdaCapture,
ParseDefaultInLambda,
ParseMutableOnNonLambda,
ParseInitCaptureBeforeCXX14,
ParseGenericLambdaBeforeCXX14,
ParseReturnTypeAfterLambda,
ParseTemplateParamTooDeep,
ParseTemplateDefaultArg,
ParseExpectedTemplateParam,
ParseConceptDefinition,
ParseRequiresClause,
ParseRequiresExpression,
ParseCoroutineKeyword,
ParseCoAwaitOutsideCoroutine,
ParseCoYieldOutsideCoroutine,
ParseCoReturnOutsideCoroutine,
ParseModuleDeclaration,
ParseModuleImport,
ParseModuleExport,
ParseExpectedModuleName,
SemaTypeCheckingError,
SemaConversionError,
SemaOverflow,
SemaDivisionByZero,
SemaIncompatiblePointerTypes,
SemaAssignmentIncompatible,
SemaPassingArgumentIncompatible,
SemaReturnIncompatible,
SemaVoidFuncReturningValue,
SemaNonVoidMissingReturn,
SemaUnreachableCode,
SemaUnusedVariable,
SemaUnusedParameter,
SemaUnusedFunction,
SemaUninitializedVariable,
SemaPotentiallyUninitialized,
SemaVLANegativeSize,
SemaVLANonPositiveSize,
SemaArraySizeTooLarge,
SemaNegativeArraySize,
SemaZeroSizeArray,
SemaFlexibleArrayMember,
SemaFlexibleArrayInUnion,
SemaFlexibleArrayNotAtEnd,
SemaFieldTypeIncomplete,
SemaBitFieldWidth,
SemaBitFieldWidthNegative,
SemaBitFieldWidthZero,
SemaEnumValueOverflow,
SemaEnumForwardDeclaration,
SemaEnumScopedFixed,
SemaDuplicateMember,
SemaDuplicateEnumValue,
SemaDuplicateCase,
SemaDuplicateDefault,
SemaMultipleDefault,
SemaCaseValueNotConst,
SemaCaseOutOfRange,
SemaSwitchCondition,
SemaBreakNotInLoop,
SemaContinueNotInLoop,
SemaLRValueMismatch,
SemaConstQualified,
SemaVolatileQualified,
SemaRestrictQualified,
SemaAtomicMismatch,
SemaSizeofIncomplete,
SemaAlignofIncomplete,
SemaSizeofFunction,
SemaSizeofVoid,
SemaSizeofBitField,
SemaAlignofBitField,
SemaInvalidOperands,
SemaInvalidUnaryOp,
SemaInvalidBinaryOp,
SemaInvalidTernaryOp,
SemaInvalidCastType,
SemaConstCast,
SemaStaticCast,
SemaReinterpretCast,
SemaDynamicCast,
SemaBadConstCast,
SemaBadStaticCast,
SemaBadReinterpretCast,
SemaBadDynamicCast,
SemaInvalidLValue,
SemaNotModifiableLValue,
SemaAddressOfRegister,
SemaAddressOfBitField,
SemaAddressOfTemporary,
SemaAddressOfLabel,
SemaIndirectionOnNonPointer,
SemaSubscriptNonArray,
SemaSubscriptNonInteger,
SemaMemberAccessNonStruct,
SemaCallNonFunction,
SemaCallNonCallable,
SemaTooManyArgs,
SemaTooFewArgs,
SemaVoidArgInNonPrototype,
SemaDefaultArgMismatch,
SemaDefaultArgRedefined,
SemaDefaultArgOnParamPack,
SemaLocalDeclNoLinkage,
SemaStaticInInline,
SemaExternInitializer,
SemaRedefinitionOfTypedef,
SemaRedefinitionOfLabel,
SemaConflictingFunctionTypes,
SemaIncompatibleFunctionDecl,
SemaDuplicateAttribute,
SemaAttributeIgnored,
SemaUnknownAttribute,
SemaGNUAttributeIgnored,
SemaGCCExtension,
SemaMSVCCompatibility,
SemaReturnStackAddress,
SemaReturnLocalAddress,
SemaDanglingReference,
SemaDanglingPointer,
SemaDeallocMismatch,
SemaDoubleFree,
SemaUseAfterFree,
SemaStackBufferOverflow,
SemaHeapBufferOverflow,
SemaSignedOverflow,
SemaUnsignedOverflow,
SemaFloatOverflow,
SemaFloatToIntOverflow,
SemaIntToFloatPrecisionLoss,
SemaDivisionByZeroRuntime,
SemaModuloByZero,
SemaShiftByNegative,
SemaShiftExceedsWidth,
SemaNullDereference,
SemaNonNullParamNull,
SemaNullPassedToNonNull,
SemaAlignmentMismatch,
SemaCastAlignDown,
SemaCastAlignUp,
SemaStrictAliasingViolation,
SemaTypePunningViaUnion,
SemaTypePunningViaCast,
SemaUninitializedRead,
SemaStackProtectorFailure,
SemaInvalidBuiltin,
SemaDeprecatedDecl,
SemaUnavailableDecl,
SemaDeprecatedAttribute,
SemaUnavailableAttribute,
SemaDeprecatedWithMessage,
SemaUnavailableWithMessage,
SemaDeprecatedEnumerator,
SemaDeprecatedTypedef,
SemaRemovedFeature,
CXXAccessControlPrivate,
CXXAccessControlProtected,
CXXAccessControlPublic,
CXXAccessControlInaccessible,
CXXAccessControlInaccessibleBase,
CXXVirtualOverrideMismatch,
CXXMissingOverride,
CXXOverrideMismatch,
CXXFinalOverride,
CXXFinalClassOverride,
CXXPureVirtualCall,
CXXPureVirtualInCtorDtor,
CXXAbstractClass,
CXXAbstractClassDeclaration,
CXXAbstractReturnType,
CXXAbstractParameterType,
CXXDeletedFunction,
CXXDeletedDefault,
CXXDeletedCopy,
CXXDeletedMove,
CXXDeletedDestructor,
CXXExplicitConversion,
CXXExplicitConstructor,
CXXExplicitBoolConversion,
CXXConstexprNonConst,
CXXConstexprNoReturn,
CXXConstexprNeverConstant,
CXXConstexprVirtual,
CXXConstexprTryCatch,
CXXConstexprAllocation,
CXXConstexprDeallocation,
CXXConstexprDynamicCast,
CXXConstexprReinterpretCast,
CXXConstexprUnionActiveMember,
CXXNoexceptMismatch,
CXXNoexceptFunctionType,
CXXNoexceptFalse,
CXXNoexceptOverrideNarrower,
CXXNoexceptOverrideWider,
CXXTemplateArgDeductionFailed,
CXXTemplateAmbiguous,
CXXTemplateRecursion,
CXXTemplateExplicitInstantiation,
CXXTemplateExplicitSpecialization,
CXXTemplatePartialSpecialization,
CXXTemplateDefaultArgInvalid,
CXXTemplateNonTypeParamInvalid,
CXXTemplateTypeParamInvalid,
CXXTemplateTemplateParamInvalid,
CXXTemplateVariadicParam,
CXXTemplateParameterPack,
CXXTemplateArgPackExpansion,
CXXDependentNameMissingTypename,
CXXDependentNameInvalidTypename,
CXXTwoPhaseLookup,
CXXTwoPhaseLookupDependent,
CXXTwoPhaseLookupTwoLevel,
CXXSFINAEContext,
CXXSFINAEDeductionFailed,
CXXOverloadAmbiguity,
CXXOverloadAmbiguousConversion,
CXXOverloadAmbiguousConstructor,
CXXOverloadNoViable,
CXXOverloadNoViableConversion,
CXXOverloadDeletedFunction,
CXXOverloadInaccessibleFunction,
CXXOverloadTemplateDeduction,
CXXOverloadCandidateNotViable,
CXXDestructorProtected,
CXXDestructorPrivate,
CXXDestructorDeleted,
CXXDestructorVirtualBase,
CXXDestructorAbstractBase,
CXXCopyCtorDeleted,
CXXCopyCtorImplicitlyDeleted,
CXXCopyCtorNonTrivial,
CXXCopyCtorTrivialABI,
CXXMoveCtorDeleted,
CXXMoveCtorNotUsed,
CXXMoveCtorElision,
CXXCopyAssignmentDeleted,
CXXMoveAssignmentDeleted,
CXXDefaultedDeleted,
CXXDefaultedSpecialMember,
CXXExplicitlyDefaulted,
CXXExplicitlyDeleted,
CXXFriendNotFirst,
CXXFriendRedefinition,
CXXFriendInLocalClass,
CXXNamespaceAlias,
CXXUsingDeclaration,
CXXUsingDirective,
CXXUsingShadow,
CXXUsingAmbiguous,
CXXAnonymousStruct,
CXXAnonymousUnionMember,
CXXLambdaCaptureDefault,
CXXLambdaCaptureExplicit,
CXXLambdaCaptureThis,
CXXLambdaCaptureByReference,
CXXLambdaCaptureByValue,
CXXLambdaCaptureInit,
CXXLambdaGeneric,
CXXLambdaConstexpr,
CXXLambdaMutable,
CXXLambdaDefaultArg,
CXXLambdaTemplate,
CXXLambdaInUnevaluated,
CXXLambdaStaticInvoker,
CXXCoroutineReturnType,
CXXCoroutinePromiseType,
CXXCoroutineAwaitable,
CXXCoroutineSymmetricTransfer,
CXXCoroutineFrameAllocation,
CXXCoroutineNoElision,
CXXCoroutineHeapAlloc,
CXXCoroutineHeapDealloc,
CXXConceptDefinition,
CXXConceptConstraint,
CXXConceptSatisfaction,
CXXConceptAtomic,
CXXConceptRequires,
CXXConceptNestedRequirement,
CXXConceptTypeRequirement,
CXXConceptCompoundRequirement,
CXXConceptExpressionRequirement,
CXXConceptPartialOrdering,
CXXConceptSubsumption,
CXXConceptDefaultConstraint,
CXXModuleInterface,
CXXModuleImplementation,
CXXModulePartition,
CXXModuleImport,
CXXModuleExport,
CXXModuleOwnership,
CXXModuleLinkage,
CXXModuleVisibility,
CXXModuleReachability,
CXXModuleAttainment,
CXXModuleGlobalFragment,
CXXModulePrivateFragment,
CXXModuleHeaderUnit,
CXXModuleBMI,
CXXThreeWayComparison,
CXXSpaceshipAuto,
CXXSpaceshipReturnType,
CXXDefaultedComparison,
CXXWeakEquality,
CXXStrongEquality,
CXXWeakOrdering,
CXXPartialOrdering,
CXXStrongOrdering,
CXXDesignatedInit,
CXXDesignatedInitMixed,
CXXDesignatedInitOutOfOrder,
CXXDesignatedInitNested,
CXXDesignatedInitOverride,
CXXDesignatedInitArray,
CXXRangeBasedFor,
CXXRangeBasedForBeginEnd,
CXXRangeBasedForADL,
CXXStructuredBinding,
CXXStructuredBindingTuple,
CXXStructuredBindingArray,
CXXStructuredBindingMember,
CXXInitStatement,
CXXIfInit,
CXXSwitchInit,
CXXRangeForInit,
CXXCTAD,
CXXCTADGuide,
CXXCTADAggregate,
CXXCTADExplicit,
CXXCTADDeductionFailed,
CXXAggregateInit,
CXXAggregateParenInit,
CXXTrivialABI,
CXXTrivialDestructor,
CXXTrivialCopy,
CXXNoUniqueAddress,
CXXLikely,
CXXUnlikely,
CXXAssume,
CXXDefaultMemberInit,
CXXDefaultMemberInitBitField,
CXXNSDMI,
CXXInheritingConstructor,
CXXInheritingConstructorConflict,
CXXVariadicUsing,
CXXPackExpansion,
CXXFoldExpression,
CXXFoldUnaryLeft,
CXXFoldUnaryRight,
CXXFoldBinaryLeft,
CXXFoldBinaryRight,
CXXEmptyFold,
X86FeatureSSE,
X86FeatureSSE2,
X86FeatureSSE3,
X86FeatureSSSE3,
X86FeatureSSE41,
X86FeatureSSE42,
X86FeatureAVX,
X86FeatureAVX2,
X86FeatureAVX512F,
X86FeatureAVX512BW,
X86FeatureAVX512DQ,
X86FeatureAVX512VL,
X86FeatureAVX512CD,
X86FeatureAVX512ER,
X86FeatureAVX512PF,
X86FeatureAVX512BF16,
X86FeatureAVX512FP16,
X86FeatureAVX512VBMI,
X86FeatureAVX512VBMI2,
X86FeatureAVX512VNNI,
X86FeatureAVX512BITALG,
X86FeatureAVX512VPOPCNTDQ,
X86FeatureAVX5124FMAPS,
X86FeatureAVX5124VNNIW,
X86FeatureAVX512VP2INTERSECT,
X86FeatureAVX512IFMA,
X86FeatureAVX10_1_256,
X86FeatureAVX10_1_512,
X86FeatureAVX10_2,
X86FeatureFMA,
X86FeatureFMA4,
X86FeatureF16C,
X86FeatureMMX,
X86FeatureSSE4a,
X86FeatureXOP,
X86Feature3DNOW,
X86Feature3DNOWA,
X86FeatureBMI,
X86FeatureBMI2,
X86FeatureLZCNT,
X86FeaturePOPCNT,
X86FeatureTBM,
X86FeatureAES,
X86FeaturePCLMUL,
X86FeatureSHA,
X86FeatureSHA512,
X86FeatureSM3,
X86FeatureSM4,
X86FeatureGFNI,
X86FeatureVAES,
X86FeatureVPCLMULQDQ,
X86FeatureRDRAND,
X86FeatureRDSEED,
X86FeatureADX,
X86FeatureRTM,
X86FeatureHLE,
X86FeatureSGX,
X86FeatureCET,
X86FeatureCETSS,
X86FeatureXSAVE,
X86FeatureXSAVEOPT,
X86FeatureXSAVEC,
X86FeatureXSAVES,
X86FeatureFSGSBASE,
X86FeatureMOVBE,
X86FeatureMOVDIRI,
X86FeatureMOVDIR64B,
X86FeatureENQCMD,
X86FeatureSERIALIZE,
X86FeatureTSXLDTRK,
X86FeatureWAITPKG,
X86FeatureCLDEMOTE,
X86FeatureCLFLUSHOPT,
X86FeatureCLWB,
X86FeatureCLZERO,
X86FeaturePKU,
X86FeatureAMX_BF16,
X86FeatureAMX_INT8,
X86FeatureAMX_TILE,
X86FeatureAMX_FP16,
X86FeatureAMX_COMPLEX,
X86FeatureX87,
X86FeatureCMOV,
X86CallingConventionMismatch,
X86ABIViolation,
X86StructReturnTooLarge,
X86VectorTypeNotSupported,
X86IntrinsicNotAvailable,
X86CPUFeatureNotAvailable,
X86TargetAttributeConflict,
X86OptionArchMismatch,
X86ABIStructTooLarge,
X86ABIHiddenPointerReturn,
X86ABIRedZoneViolation,
X86ABIStackAlignmentViolation,
X86ABIVectorcallAlignment,
X86ABIFastcallTooManyArgs,
X86ABIThiscallNonMember,
X86ABIStdCallVarArgs,
X86ABIRegCallNotEnoughRegs,
X86ABISysVClassificationFailed,
X86ABIMicrosoftClassificationFailed,
X86ABIRegCallClassificationFailed,
X86ABIEmptyStructPass,
X86ABIPackedStructPass,
X86ABIBitfieldStraddle,
X86ABIComplexReturn,
X86ABIX87Return,
X86InlineASMInvalidInstruction,
X86InlineASMInvalidConstraint,
X86InlineASMClobberConflict,
X86InlineASMTooManyOperands,
X86InlineASMGlobalRegister,
X86VectorWidthMismatch,
X86VectorShuffleInvalid,
X86VectorGatherAlign,
X86VectorMaskMissing,
X86AlignmentNone,
X86AlignmentUnaligned,
X86RedZoneViolation,
X86StackSize,
X86NopPadding,
OptInlineRemark,
OptInlineFailure,
OptInlineCostTooHigh,
OptInlineNoDefinition,
OptInlineRecursive,
OptInlineNoInlineAttr,
OptInlineAlwaysInline,
OptInlineNoOptimize,
OptInlineOptNone,
OptVectorizationRemark,
OptVectorizationFailure,
OptVectorizationUnsafeDep,
OptVectorizationNoAlias,
OptVectorizationUnaligned,
OptVectorizationNoReduction,
OptVectorizationSmallTrip,
OptVectorizationNonLinear,
OptVectorizationIneffective,
OptLoopUnrollRemark,
OptLoopUnrollFailure,
OptLoopUnrollTooLarge,
OptLoopUnrollNonConstant,
OptLoopUnrollPartial,
OptLoopUnrollComplete,
OptLoopFusion,
OptLoopFusionFailure,
OptLoopDistribution,
OptLoopDistributionFailure,
OptLoopInterchange,
OptLoopInterchangeFailure,
OptLoopUnswitch,
OptLoopUnswitchFailure,
OptDevirtualizeRemark,
OptDevirtualizeFailure,
OptDevirtualizeNoVtable,
OptDevirtualizeMultiInheritance,
OptDevirtualizeUnknown,
OptInlineRemarkCost,
OptInlineRemarkCallSite,
OptGVNLoadElim,
OptMemCpyOpt,
OptSLPVectorized,
OptSLPVectorizeFailure,
OptConstantHoisting,
OptReassociation,
OptLICMHoist,
OptLICMSink,
OptDeadStoreElim,
OptDeadCodeElim,
OptInstructionSimplify,
OptTailCallElim,
OptTailCallFailure,
OptSROA,
OptSROAFailure,
OptMergeFunctions,
OptGlobalOpt,
OptIPSCCP,
OptAttributeOptimize,
OptProfileDataMissing,
OptSampleProfile,
SecFormatString,
SecFormatStringOverflow,
SecFormatStringNoArgs,
SecFormatStringExtraArgs,
SecFormatStringMismatch,
SecFormatStringSecurity,
SecFormatStringNonLiteral,
SecFormatStringPositional,
SecBufferOverflow,
SecBufferOverflowStack,
SecBufferOverflowHeap,
SecBufferOverflowGlobal,
SecBufferOverflowDynamic,
SecBufferUnderflow,
SecUseAfterFree,
SecDoubleFree,
SecUseAfterScope,
SecReturnStackBuffer,
SecNullDereference,
SecNullDereferenceUnlikely,
SecDivisionByZero,
SecIntegerOverflow,
SecShiftCountNegative,
SecShiftCountOverflow,
SecShiftNegative,
SecAlignmentViolation,
SecCastAlign,
SecCastAlignDown,
SecStrictAliasing,
SecTypePunning,
SecUninitializedRead,
SecUninitializedStack,
SecUninitializedHeap,
SecStackProtector,
SecStackProtectorStrong,
SecStackClash,
SecStackExhausted,
SecAllocaTooLarge,
SecVLAInKernel,
SecVLATooLarge,
SecFORTIFYSource,
SecBoundsCheck,
SecImplicitConversion,
SecSignedToUnsigned,
SecTruncation,
SecSignExtension,
SecDeprecatedAPI,
SecUnsafeFunction,
SecUntrustedInput,
SecFormatTruncation,
FatalNoInputFiles,
FatalCannotOpenFile,
FatalCannotWriteFile,
FatalCannotExecuteBinary,
FatalOutOfMemory,
FatalStackExhausted,
FatalIncludeTooDeep,
FatalMacroExpansionTooDeep,
FatalTemplateInstantiationTooDeep,
FatalRecursiveTemplateInstantiation,
FatalTooManyErrors,
FatalInvalidTarget,
FatalUnsupportedTarget,
FatalInvalidArch,
FatalInvalidCPU,
FatalInvalidFeature,
FatalInvalidOption,
FatalConflictingOptions,
FatalMissingArg,
FatalUnknownArg,
FatalInvalidValue,
FatalModuleBuildFailed,
FatalModuleFileOutOfDate,
FatalModuleFileInvalid,
FatalCyclicModuleDependency,
FatalPCHOutOfDate,
FatalPCHInvalid,
FatalPCHCXXMismatch,
FatalPCHTargetMismatch,
FatalPCHLanguageMismatch,
FatalPCHVersionMismatch,
FatalCannotFindHeaders,
FatalCannotFindSDK,
FatalSDKTooOld,
FatalBrokenInstallation,
FatalInternalError,
FatalUnimplemented,
FatalLTOError,
FatalBackendError,
FatalCodeGenError,
}
pub struct X86DiagnosticCatalog;
impl X86DiagnosticCatalog {
pub fn default_severity(id: X86FullDiagID) -> DiagSeverity {
match id {
X86FullDiagID::LexTrigraphWarning
| X86FullDiagID::LexTrigraphIgnored
| X86FullDiagID::LexDigraph
| X86FullDiagID::LexNullCharInFile
| X86FullDiagID::LexUnicodeSurrogate
| X86FullDiagID::LexWhitespaceRequired
| X86FullDiagID::LexNestedBlockComment
| X86FullDiagID::LexNullDirective
| X86FullDiagID::LexEmptySourceFile
| X86FullDiagID::LexBOMDetected
| X86FullDiagID::LexEncodingWarning
| X86FullDiagID::LexCRLFInRawString
| X86FullDiagID::LexNonASCIIIdentifier
| X86FullDiagID::LexReservedIdentifier
| X86FullDiagID::LexDollarInIdentifier
| X86FullDiagID::LexUnderscoreReserved
| X86FullDiagID::LexUserDefinedLiteralRaw
| X86FullDiagID::LexUserDefinedLiteralCooked
| X86FullDiagID::LexTooManyContinuations
| X86FullDiagID::LexMissingNewlineAtEOF
| X86FullDiagID::LexExtraNewlineAtEOF
| X86FullDiagID::LexHexFloatLiteral
| X86FullDiagID::LexComplexLiteral
| X86FullDiagID::LexImaginaryLiteral
| X86FullDiagID::LexCharLiteralMultiChar
| X86FullDiagID::LexStringLiteralConcat
| X86FullDiagID::LexOffsetExceedsFile
| X86FullDiagID::LexAlternativeToken
| X86FullDiagID::LexOperatorSpelling => DiagSeverity::Warning,
X86FullDiagID::LexIllegalChar
| X86FullDiagID::LexInvalidToken
| X86FullDiagID::LexUnterminatedString
| X86FullDiagID::LexUnterminatedChar
| X86FullDiagID::LexInvalidEscapeSequence
| X86FullDiagID::LexInvalidUniversalCharName
| X86FullDiagID::LexInvalidRawStringDelim
| X86FullDiagID::LexInvalidRawStringPrefix
| X86FullDiagID::LexNumericLiteralTooLarge
| X86FullDiagID::LexInvalidSuffix
| X86FullDiagID::LexHeaderName
| X86FullDiagID::LexUTF8InvalidByte
| X86FullDiagID::LexHexEscapeOutOfRange
| X86FullDiagID::LexOctalEscapeOutOfRange
| X86FullDiagID::LexUnterminatedBlockComment
| X86FullDiagID::LexInlineASM
| X86FullDiagID::LexHashInNonDirective
| X86FullDiagID::LexUnknownPragma
| X86FullDiagID::LexEmbeddedDirective
| X86FullDiagID::LexLongUTF8Sequence
| X86FullDiagID::LexMultibyteChar
| X86FullDiagID::LexBinaryLiteral
| X86FullDiagID::LexCharLiteralWide
| X86FullDiagID::LexCharLiteralUTF8
| X86FullDiagID::LexCharLiteralUTF16
| X86FullDiagID::LexCharLiteralUTF32
| X86FullDiagID::LexStringLiteralWide
| X86FullDiagID::LexStringLiteralUTF8
| X86FullDiagID::LexStringLiteralUTF16
| X86FullDiagID::LexStringLiteralUTF32 => DiagSeverity::Error,
X86FullDiagID::PPMacroRedefined
| X86FullDiagID::PPExtraTokensAtEndOfDirective
| X86FullDiagID::PPWrongNumberOfMacroArgs
| X86FullDiagID::PPTooFewMacroArgs
| X86FullDiagID::PPTooManyMacroArgs
| X86FullDiagID::PPBuiltinMacroRedefined
| X86FullDiagID::PPPragmaOnceInMainFile
| X86FullDiagID::PPIncludeNestedTooDeeply
| X86FullDiagID::PPIncludeNextInPrimaryFile
| X86FullDiagID::PPImportInMacro
| X86FullDiagID::PPIncludeMacroUsage
| X86FullDiagID::PPUndefOfBuiltin
| X86FullDiagID::PPMacroAsArgument
| X86FullDiagID::PPNullArgInVariadic
| X86FullDiagID::PPEmptyVariadicMacro
| X86FullDiagID::PPGNUVariadicMacro
| X86FullDiagID::PPC99VariadicMacro
| X86FullDiagID::PPMSVariadicMacro
| X86FullDiagID::PPMissingWhitespaceAfterMacro
| X86FullDiagID::PPPragmaUnused
| X86FullDiagID::PPStringifyEmpty
| X86FullDiagID::PPHashHashSingleHash
| X86FullDiagID::PPEmptyTranslationUnit
| X86FullDiagID::PPMacroUsedBeforeDefined
| X86FullDiagID::PPMacroRedefinedDifferent
| X86FullDiagID::PPMacroArgUnused
| X86FullDiagID::PPMacroArgNameConflict
| X86FullDiagID::PPMacroArgReserved
| X86FullDiagID::PPDefinedOperatorInMacro
| X86FullDiagID::PPHeaderGuardMismatch
| X86FullDiagID::PPPragmaOnceWarning
| X86FullDiagID::PPFileNotUTF8
| X86FullDiagID::PPImplicitDefine
| X86FullDiagID::PPImplicitInclude
| X86FullDiagID::PPIncludeDepthExceeded
| X86FullDiagID::PPUnterminatedConditional
| X86FullDiagID::PPBadTokenPaste
| X86FullDiagID::PPAttributePushPopMismatch => DiagSeverity::Warning,
X86FullDiagID::PPMacroNotDefined
| X86FullDiagID::PPInvalidMacroName
| X86FullDiagID::PPUnterminatedMacro
| X86FullDiagID::PPMissingEndif
| X86FullDiagID::PPElifWithoutIf
| X86FullDiagID::PPElseWithoutIf
| X86FullDiagID::PPEndifWithoutIf
| X86FullDiagID::PPInvalidDirective
| X86FullDiagID::PPHeaderNotFound
| X86FullDiagID::PPHeaderCannotOpen
| X86FullDiagID::PPInvalidIncludeDirective
| X86FullDiagID::PPErrorDirective
| X86FullDiagID::PPMacroExpansionTooDeep
| X86FullDiagID::PPBadPaste
| X86FullDiagID::PPBadStringify
| X86FullDiagID::PPWarningDirective
| X86FullDiagID::PPLineDirective
| X86FullDiagID::PPFileDirective
| X86FullDiagID::PPPragmaGCCPoison
| X86FullDiagID::PPBaseFileMacro => DiagSeverity::Error,
X86FullDiagID::PPPragmaMessage
| X86FullDiagID::PPPragmaSystemHeader
| X86FullDiagID::PPPragmaGCCSystemHeader
| X86FullDiagID::PPPragmaGCCDependency
| X86FullDiagID::PPPragmaDiagnosticPush
| X86FullDiagID::PPPragmaDiagnosticPop
| X86FullDiagID::PPPragmaClangAttribute
| X86FullDiagID::PPPragmaClangDiagnostic
| X86FullDiagID::PPPragmaClangModule
| X86FullDiagID::PPPragmaAlign
| X86FullDiagID::PPPragmaPack
| X86FullDiagID::PPPragmaPackShow
| X86FullDiagID::PPPragmaComment
| X86FullDiagID::PPPragmaGCCVisibility
| X86FullDiagID::PPDateMacro
| X86FullDiagID::PPTimeMacro
| X86FullDiagID::PPFileMacro
| X86FullDiagID::PPLineMacro
| X86FullDiagID::PPCounterMacro
| X86FullDiagID::PPFunctionMacro
| X86FullDiagID::PPPragmaRegion
| X86FullDiagID::PPPragmaEndRegion => DiagSeverity::Remark,
X86FullDiagID::ParseDanglingElse
| X86FullDiagID::ParseAmbiguousElse
| X86FullDiagID::ParseVexingParse
| X86FullDiagID::ParseMostVexingParse
| X86FullDiagID::ParseFunctionDefNoPrototype
| X86FullDiagID::ParseKandRParameters
| X86FullDiagID::ParseOldStyleDefinition
| X86FullDiagID::ParseExtraneousToken
| X86FullDiagID::ParseUnrecognizedDeclaration
| X86FullDiagID::ParseGNUStatementExpression
| X86FullDiagID::ParseGNULocalLabel
| X86FullDiagID::ParseGNUConditionalOmittedOperand
| X86FullDiagID::ParseGNUDesignator
| X86FullDiagID::ParseGNUAttribute
| X86FullDiagID::ParseDeclspecAttribute
| X86FullDiagID::ParseDefaultInLambda
| X86FullDiagID::ParseInitCaptureBeforeCXX14
| X86FullDiagID::ParseGenericLambdaBeforeCXX14 => DiagSeverity::Warning,
X86FullDiagID::ParseExpectedToken
| X86FullDiagID::ParseUnexpectedToken
| X86FullDiagID::ParseExpectedExpression
| X86FullDiagID::ParseExpectedType
| X86FullDiagID::ParseExpectedIdentifier
| X86FullDiagID::ParseExpectedFunctionBody
| X86FullDiagID::ParseMissingSemicolon
| X86FullDiagID::ParseMissingClosingBrace
| X86FullDiagID::ParseMissingClosingParen
| X86FullDiagID::ParseMissingClosingBracket
| X86FullDiagID::ParseDuplicateDeclaration
| X86FullDiagID::ParseConflictingTypes
| X86FullDiagID::ParseRedefinition
| X86FullDiagID::ParseTypedefRedefinition
| X86FullDiagID::ParseEnumRedefinition
| X86FullDiagID::ParseLabelRedefinition
| X86FullDiagID::ParseUndeclaredIdentifier
| X86FullDiagID::ParseImplicitDeclaration
| X86FullDiagID::ParseTypeMismatch
| X86FullDiagID::ParseIncompatibleTypes
| X86FullDiagID::ParseInvalidCast
| X86FullDiagID::ParseVoidExpression
| X86FullDiagID::ParseVoidParameter
| X86FullDiagID::ParseVoidReturn
| X86FullDiagID::ParseEmptyDeclaration
| X86FullDiagID::ParseStorageClassSpecifier
| X86FullDiagID::ParseDuplicateSpecifier
| X86FullDiagID::ParseInvalidStorageClass
| X86FullDiagID::ParseMultipleStorageClasses
| X86FullDiagID::ParseThreadNotStatic
| X86FullDiagID::ParseUnexpectedTypedef
| X86FullDiagID::ParseExpectedComma
| X86FullDiagID::ParseExpectedColon
| X86FullDiagID::ParseExpectedRBrace
| X86FullDiagID::ParseExpectedRParen
| X86FullDiagID::ParseExpectedRBracket
| X86FullDiagID::ParseExpectedSemiAfterExpr
| X86FullDiagID::ParseExpectedSemiAfterDecl
| X86FullDiagID::ParseExpectedStatement
| X86FullDiagID::ParseExpectedDeclaration
| X86FullDiagID::ParseExpectedParameter
| X86FullDiagID::ParseExpectedLoopBody
| X86FullDiagID::ParseExpectedSwitchBody
| X86FullDiagID::ParseExpectedCaseOrDefault
| X86FullDiagID::ParseExpectedStructUnion
| X86FullDiagID::ParseExpectedEnumBody
| X86FullDiagID::ParseExpectedEqual
| X86FullDiagID::ParseExpectedAngleBracket
| X86FullDiagID::ParseExpectedTypeSpecifier
| X86FullDiagID::ParseExpectedDeclarator
| X86FullDiagID::ParseExpectedQualifiedName
| X86FullDiagID::ParseExpectedCompoundStmt
| X86FullDiagID::ParseExpectedInitializer
| X86FullDiagID::ParseExpectedArrow
| X86FullDiagID::ParseExpectedDot
| X86FullDiagID::ParseExpectedOperatorName
| X86FullDiagID::ParseExpectedProperty
| X86FullDiagID::ParseEOFExpected
| X86FullDiagID::ParseExpectedAsm
| X86FullDiagID::ParseInvalidAsm
| X86FullDiagID::ParseExpectedAttribute
| X86FullDiagID::ParseNestedFunction
| X86FullDiagID::ParseAlignasInvalid
| X86FullDiagID::ParseAlignasOnParam
| X86FullDiagID::ParseAlignasOnBitField
| X86FullDiagID::ParseAtomicQualified
| X86FullDiagID::ParseNoreturnOnNonFunction
| X86FullDiagID::ParseInlineOnMain
| X86FullDiagID::ParseDeprecatedMessage
| X86FullDiagID::ParseUnavailableMessage
| X86FullDiagID::ParseUnexpectedTemplateKeyword
| X86FullDiagID::ParseExpectedTemplateArgList
| X86FullDiagID::ParseExpectedBaseClause
| X86FullDiagID::ParseExpectedCtorInitializer
| X86FullDiagID::ParseInvalidPureSpecifier
| X86FullDiagID::ParseUnexpectedFriend
| X86FullDiagID::ParseFriendOnLocalClass
| X86FullDiagID::ParseUnexpectedVirtual
| X86FullDiagID::ParseVirtualInUnion
| X86FullDiagID::ParsePureInNonVirtual
| X86FullDiagID::ParseFinalInWrongContext
| X86FullDiagID::ParseOverrideOutsideClass
| X86FullDiagID::ParseExpectedLambdaBody
| X86FullDiagID::ParseInvalidLambdaCapture
| X86FullDiagID::ParseMutableOnNonLambda
| X86FullDiagID::ParseReturnTypeAfterLambda
| X86FullDiagID::ParseTemplateParamTooDeep
| X86FullDiagID::ParseTemplateDefaultArg
| X86FullDiagID::ParseExpectedTemplateParam
| X86FullDiagID::ParseConceptDefinition
| X86FullDiagID::ParseRequiresClause
| X86FullDiagID::ParseRequiresExpression
| X86FullDiagID::ParseCoroutineKeyword
| X86FullDiagID::ParseCoAwaitOutsideCoroutine
| X86FullDiagID::ParseCoYieldOutsideCoroutine
| X86FullDiagID::ParseCoReturnOutsideCoroutine
| X86FullDiagID::ParseModuleDeclaration
| X86FullDiagID::ParseModuleImport
| X86FullDiagID::ParseModuleExport
| X86FullDiagID::ParseExpectedModuleName => DiagSeverity::Error,
X86FullDiagID::SemaUnreachableCode
| X86FullDiagID::SemaUnusedVariable
| X86FullDiagID::SemaUnusedParameter
| X86FullDiagID::SemaUnusedFunction
| X86FullDiagID::SemaPotentiallyUninitialized
| X86FullDiagID::SemaOverflow
| X86FullDiagID::SemaDuplicateAttribute
| X86FullDiagID::SemaAttributeIgnored
| X86FullDiagID::SemaUnknownAttribute
| X86FullDiagID::SemaGNUAttributeIgnored
| X86FullDiagID::SemaGCCExtension
| X86FullDiagID::SemaMSVCCompatibility
| X86FullDiagID::SemaReturnStackAddress
| X86FullDiagID::SemaReturnLocalAddress
| X86FullDiagID::SemaDanglingReference
| X86FullDiagID::SemaDanglingPointer
| X86FullDiagID::SemaDeallocMismatch
| X86FullDiagID::SemaDoubleFree
| X86FullDiagID::SemaUseAfterFree
| X86FullDiagID::SemaStackBufferOverflow
| X86FullDiagID::SemaHeapBufferOverflow
| X86FullDiagID::SemaSignedOverflow
| X86FullDiagID::SemaUnsignedOverflow
| X86FullDiagID::SemaFloatOverflow
| X86FullDiagID::SemaFloatToIntOverflow
| X86FullDiagID::SemaIntToFloatPrecisionLoss
| X86FullDiagID::SemaDivisionByZeroRuntime
| X86FullDiagID::SemaShiftByNegative
| X86FullDiagID::SemaShiftExceedsWidth
| X86FullDiagID::SemaNullDereference
| X86FullDiagID::SemaNonNullParamNull
| X86FullDiagID::SemaNullPassedToNonNull
| X86FullDiagID::SemaAlignmentMismatch
| X86FullDiagID::SemaCastAlignDown
| X86FullDiagID::SemaCastAlignUp
| X86FullDiagID::SemaStrictAliasingViolation
| X86FullDiagID::SemaTypePunningViaUnion
| X86FullDiagID::SemaTypePunningViaCast
| X86FullDiagID::SemaUninitializedRead
| X86FullDiagID::SemaStackProtectorFailure
| X86FullDiagID::SemaUninitializedVariable
| X86FullDiagID::SemaDeprecatedDecl
| X86FullDiagID::SemaDeprecatedAttribute
| X86FullDiagID::SemaDeprecatedWithMessage
| X86FullDiagID::SemaDeprecatedEnumerator
| X86FullDiagID::SemaDeprecatedTypedef
| X86FullDiagID::SemaRemovedFeature
| X86FullDiagID::SemaVLANegativeSize
| X86FullDiagID::SemaVLANonPositiveSize
| X86FullDiagID::SemaArraySizeTooLarge
| X86FullDiagID::SemaFlexibleArrayNotAtEnd
| X86FullDiagID::SemaEnumValueOverflow
| X86FullDiagID::SemaDuplicateCase
| X86FullDiagID::SemaCaseValueNotConst
| X86FullDiagID::SemaCaseOutOfRange
| X86FullDiagID::SemaLocalDeclNoLinkage
| X86FullDiagID::SemaStaticInInline
| X86FullDiagID::SemaExternInitializer
| X86FullDiagID::SemaDefaultArgRedefined
| X86FullDiagID::SemaDefaultArgOnParamPack => DiagSeverity::Warning,
X86FullDiagID::SemaTypeCheckingError
| X86FullDiagID::SemaConversionError
| X86FullDiagID::SemaDivisionByZero
| X86FullDiagID::SemaIncompatiblePointerTypes
| X86FullDiagID::SemaAssignmentIncompatible
| X86FullDiagID::SemaPassingArgumentIncompatible
| X86FullDiagID::SemaReturnIncompatible
| X86FullDiagID::SemaVoidFuncReturningValue
| X86FullDiagID::SemaNonVoidMissingReturn
| X86FullDiagID::SemaNegativeArraySize
| X86FullDiagID::SemaZeroSizeArray
| X86FullDiagID::SemaFlexibleArrayMember
| X86FullDiagID::SemaFlexibleArrayInUnion
| X86FullDiagID::SemaFieldTypeIncomplete
| X86FullDiagID::SemaBitFieldWidth
| X86FullDiagID::SemaBitFieldWidthNegative
| X86FullDiagID::SemaDuplicateMember
| X86FullDiagID::SemaDuplicateDefault
| X86FullDiagID::SemaMultipleDefault
| X86FullDiagID::SemaBreakNotInLoop
| X86FullDiagID::SemaContinueNotInLoop
| X86FullDiagID::SemaLRValueMismatch
| X86FullDiagID::SemaSizeofIncomplete
| X86FullDiagID::SemaSizeofFunction
| X86FullDiagID::SemaSizeofVoid
| X86FullDiagID::SemaInvalidOperands
| X86FullDiagID::SemaInvalidUnaryOp
| X86FullDiagID::SemaInvalidBinaryOp
| X86FullDiagID::SemaInvalidTernaryOp
| X86FullDiagID::SemaInvalidCastType
| X86FullDiagID::SemaConstCast
| X86FullDiagID::SemaStaticCast
| X86FullDiagID::SemaReinterpretCast
| X86FullDiagID::SemaDynamicCast
| X86FullDiagID::SemaBadConstCast
| X86FullDiagID::SemaBadStaticCast
| X86FullDiagID::SemaBadReinterpretCast
| X86FullDiagID::SemaBadDynamicCast
| X86FullDiagID::SemaInvalidLValue
| X86FullDiagID::SemaNotModifiableLValue
| X86FullDiagID::SemaAddressOfRegister
| X86FullDiagID::SemaAddressOfBitField
| X86FullDiagID::SemaAddressOfTemporary
| X86FullDiagID::SemaAddressOfLabel
| X86FullDiagID::SemaIndirectionOnNonPointer
| X86FullDiagID::SemaSubscriptNonArray
| X86FullDiagID::SemaSubscriptNonInteger
| X86FullDiagID::SemaMemberAccessNonStruct
| X86FullDiagID::SemaCallNonFunction
| X86FullDiagID::SemaCallNonCallable
| X86FullDiagID::SemaTooManyArgs
| X86FullDiagID::SemaTooFewArgs
| X86FullDiagID::SemaVoidArgInNonPrototype
| X86FullDiagID::SemaDefaultArgMismatch
| X86FullDiagID::SemaRedefinitionOfTypedef
| X86FullDiagID::SemaRedefinitionOfLabel
| X86FullDiagID::SemaConflictingFunctionTypes
| X86FullDiagID::SemaIncompatibleFunctionDecl
| X86FullDiagID::SemaModuloByZero
| X86FullDiagID::SemaInvalidBuiltin
| X86FullDiagID::SemaUnavailableDecl
| X86FullDiagID::SemaUnavailableAttribute
| X86FullDiagID::SemaUnavailableWithMessage
| X86FullDiagID::SemaEnumForwardDeclaration
| X86FullDiagID::SemaEnumScopedFixed
| X86FullDiagID::SemaSwitchCondition
| X86FullDiagID::SemaConstQualified
| X86FullDiagID::SemaVolatileQualified
| X86FullDiagID::SemaRestrictQualified
| X86FullDiagID::SemaAtomicMismatch
| X86FullDiagID::SemaAlignofIncomplete
| X86FullDiagID::SemaSizeofBitField
| X86FullDiagID::SemaAlignofBitField
| X86FullDiagID::SemaDuplicateEnumValue
| X86FullDiagID::SemaBitFieldWidthZero => DiagSeverity::Error,
X86FullDiagID::CXXMissingOverride
| X86FullDiagID::CXXOverrideMismatch
| X86FullDiagID::CXXFinalClassOverride
| X86FullDiagID::CXXNoexceptMismatch
| X86FullDiagID::CXXNoexceptOverrideNarrower
| X86FullDiagID::CXXTwoPhaseLookup
| X86FullDiagID::CXXOverloadAmbiguity
| X86FullDiagID::CXXCopyCtorNonTrivial
| X86FullDiagID::CXXMoveCtorNotUsed
| X86FullDiagID::CXXMoveCtorElision
| X86FullDiagID::CXXFriendRedefinition
| X86FullDiagID::CXXFriendInLocalClass
| X86FullDiagID::CXXUsingShadow
| X86FullDiagID::CXXUsingAmbiguous
| X86FullDiagID::CXXLambdaCaptureDefault
| X86FullDiagID::CXXLambdaCaptureThis
| X86FullDiagID::CXXLambdaCaptureByReference
| X86FullDiagID::CXXLambdaCaptureByValue
| X86FullDiagID::CXXLambdaGeneric
| X86FullDiagID::CXXLambdaConstexpr
| X86FullDiagID::CXXLambdaTemplate
| X86FullDiagID::CXXLambdaStaticInvoker
| X86FullDiagID::CXXCoroutineNoElision
| X86FullDiagID::CXXConceptDefaultConstraint
| X86FullDiagID::CXXDesignatedInitOutOfOrder
| X86FullDiagID::CXXDesignatedInitOverride
| X86FullDiagID::CXXCTADExplicit
| X86FullDiagID::CXXAggregateInit
| X86FullDiagID::CXXLikely
| X86FullDiagID::CXXUnlikely
| X86FullDiagID::CXXDefaultMemberInit
| X86FullDiagID::CXXEmptyFold
| X86FullDiagID::CXXInheritingConstructorConflict
| X86FullDiagID::CXXVariadicUsing
| X86FullDiagID::CXXFoldExpression
| X86FullDiagID::CXXSFINAEContext => DiagSeverity::Warning,
X86FullDiagID::CXXAccessControlPrivate
| X86FullDiagID::CXXAccessControlProtected
| X86FullDiagID::CXXAccessControlInaccessible
| X86FullDiagID::CXXAccessControlInaccessibleBase
| X86FullDiagID::CXXVirtualOverrideMismatch
| X86FullDiagID::CXXFinalOverride
| X86FullDiagID::CXXPureVirtualCall
| X86FullDiagID::CXXPureVirtualInCtorDtor
| X86FullDiagID::CXXAbstractClass
| X86FullDiagID::CXXAbstractClassDeclaration
| X86FullDiagID::CXXAbstractReturnType
| X86FullDiagID::CXXAbstractParameterType
| X86FullDiagID::CXXDeletedFunction
| X86FullDiagID::CXXDeletedDefault
| X86FullDiagID::CXXDeletedCopy
| X86FullDiagID::CXXDeletedMove
| X86FullDiagID::CXXDeletedDestructor
| X86FullDiagID::CXXExplicitConversion
| X86FullDiagID::CXXExplicitConstructor
| X86FullDiagID::CXXExplicitBoolConversion
| X86FullDiagID::CXXConstexprNonConst
| X86FullDiagID::CXXConstexprNoReturn
| X86FullDiagID::CXXConstexprNeverConstant
| X86FullDiagID::CXXConstexprVirtual
| X86FullDiagID::CXXConstexprTryCatch
| X86FullDiagID::CXXConstexprAllocation
| X86FullDiagID::CXXConstexprDeallocation
| X86FullDiagID::CXXConstexprDynamicCast
| X86FullDiagID::CXXConstexprReinterpretCast
| X86FullDiagID::CXXConstexprUnionActiveMember
| X86FullDiagID::CXXNoexceptFunctionType
| X86FullDiagID::CXXNoexceptFalse
| X86FullDiagID::CXXNoexceptOverrideWider
| X86FullDiagID::CXXTemplateArgDeductionFailed
| X86FullDiagID::CXXTemplateAmbiguous
| X86FullDiagID::CXXTemplateRecursion
| X86FullDiagID::CXXTemplateExplicitInstantiation
| X86FullDiagID::CXXTemplateExplicitSpecialization
| X86FullDiagID::CXXTemplateNonTypeParamInvalid
| X86FullDiagID::CXXTemplateTypeParamInvalid
| X86FullDiagID::CXXTemplateTemplateParamInvalid
| X86FullDiagID::CXXDependentNameMissingTypename
| X86FullDiagID::CXXDependentNameInvalidTypename
| X86FullDiagID::CXXTwoPhaseLookupDependent
| X86FullDiagID::CXXTwoPhaseLookupTwoLevel
| X86FullDiagID::CXXSFINAEDeductionFailed
| X86FullDiagID::CXXOverloadAmbiguousConversion
| X86FullDiagID::CXXOverloadAmbiguousConstructor
| X86FullDiagID::CXXOverloadNoViable
| X86FullDiagID::CXXOverloadNoViableConversion
| X86FullDiagID::CXXOverloadDeletedFunction
| X86FullDiagID::CXXOverloadInaccessibleFunction
| X86FullDiagID::CXXOverloadTemplateDeduction
| X86FullDiagID::CXXDestructorProtected
| X86FullDiagID::CXXDestructorPrivate
| X86FullDiagID::CXXDestructorDeleted
| X86FullDiagID::CXXDestructorVirtualBase
| X86FullDiagID::CXXDestructorAbstractBase
| X86FullDiagID::CXXCopyCtorDeleted
| X86FullDiagID::CXXCopyCtorImplicitlyDeleted
| X86FullDiagID::CXXCopyCtorTrivialABI
| X86FullDiagID::CXXMoveCtorDeleted
| X86FullDiagID::CXXCopyAssignmentDeleted
| X86FullDiagID::CXXMoveAssignmentDeleted
| X86FullDiagID::CXXDefaultedDeleted
| X86FullDiagID::CXXDefaultedSpecialMember
| X86FullDiagID::CXXExplicitlyDefaulted
| X86FullDiagID::CXXExplicitlyDeleted
| X86FullDiagID::CXXFriendNotFirst
| X86FullDiagID::CXXNamespaceAlias
| X86FullDiagID::CXXLambdaCaptureInit
| X86FullDiagID::CXXLambdaMutable
| X86FullDiagID::CXXLambdaDefaultArg
| X86FullDiagID::CXXLambdaInUnevaluated
| X86FullDiagID::CXXCoroutineReturnType
| X86FullDiagID::CXXCoroutinePromiseType
| X86FullDiagID::CXXCoroutineAwaitable
| X86FullDiagID::CXXCoroutineSymmetricTransfer
| X86FullDiagID::CXXCoroutineFrameAllocation
| X86FullDiagID::CXXCoroutineHeapAlloc
| X86FullDiagID::CXXCoroutineHeapDealloc
| X86FullDiagID::CXXConceptDefinition
| X86FullDiagID::CXXConceptConstraint
| X86FullDiagID::CXXConceptSatisfaction
| X86FullDiagID::CXXConceptAtomic
| X86FullDiagID::CXXConceptRequires
| X86FullDiagID::CXXConceptNestedRequirement
| X86FullDiagID::CXXConceptTypeRequirement
| X86FullDiagID::CXXConceptCompoundRequirement
| X86FullDiagID::CXXConceptExpressionRequirement
| X86FullDiagID::CXXConceptPartialOrdering
| X86FullDiagID::CXXConceptSubsumption
| X86FullDiagID::CXXModuleInterface
| X86FullDiagID::CXXModuleImplementation
| X86FullDiagID::CXXModulePartition
| X86FullDiagID::CXXModuleImport
| X86FullDiagID::CXXModuleExport
| X86FullDiagID::CXXModuleOwnership
| X86FullDiagID::CXXModuleLinkage
| X86FullDiagID::CXXModuleVisibility
| X86FullDiagID::CXXModuleReachability
| X86FullDiagID::CXXModuleAttainment
| X86FullDiagID::CXXModuleGlobalFragment
| X86FullDiagID::CXXModulePrivateFragment
| X86FullDiagID::CXXModuleHeaderUnit
| X86FullDiagID::CXXThreeWayComparison
| X86FullDiagID::CXXSpaceshipAuto
| X86FullDiagID::CXXSpaceshipReturnType
| X86FullDiagID::CXXDefaultedComparison
| X86FullDiagID::CXXWeakEquality
| X86FullDiagID::CXXStrongEquality
| X86FullDiagID::CXXWeakOrdering
| X86FullDiagID::CXXPartialOrdering
| X86FullDiagID::CXXStrongOrdering
| X86FullDiagID::CXXDesignatedInit
| X86FullDiagID::CXXDesignatedInitMixed
| X86FullDiagID::CXXDesignatedInitNested
| X86FullDiagID::CXXDesignatedInitArray
| X86FullDiagID::CXXRangeBasedFor
| X86FullDiagID::CXXRangeBasedForBeginEnd
| X86FullDiagID::CXXRangeBasedForADL
| X86FullDiagID::CXXStructuredBinding
| X86FullDiagID::CXXStructuredBindingTuple
| X86FullDiagID::CXXStructuredBindingArray
| X86FullDiagID::CXXStructuredBindingMember
| X86FullDiagID::CXXInitStatement
| X86FullDiagID::CXXIfInit
| X86FullDiagID::CXXSwitchInit
| X86FullDiagID::CXXRangeForInit
| X86FullDiagID::CXXCTAD
| X86FullDiagID::CXXCTADGuide
| X86FullDiagID::CXXCTADAggregate
| X86FullDiagID::CXXCTADDeductionFailed
| X86FullDiagID::CXXAggregateParenInit
| X86FullDiagID::CXXTrivialABI
| X86FullDiagID::CXXTrivialDestructor
| X86FullDiagID::CXXTrivialCopy
| X86FullDiagID::CXXNoUniqueAddress
| X86FullDiagID::CXXAssume
| X86FullDiagID::CXXDefaultMemberInitBitField
| X86FullDiagID::CXXNSDMI
| X86FullDiagID::CXXInheritingConstructor
| X86FullDiagID::CXXPackExpansion
| X86FullDiagID::CXXFoldUnaryLeft
| X86FullDiagID::CXXFoldUnaryRight
| X86FullDiagID::CXXFoldBinaryLeft
| X86FullDiagID::CXXFoldBinaryRight
| X86FullDiagID::CXXConceptDefaultConstraint
| X86FullDiagID::CXXModuleBMI
| X86FullDiagID::CXXOverloadCandidateNotViable
| X86FullDiagID::CXXTemplatePartialSpecialization
| X86FullDiagID::CXXTemplateDefaultArgInvalid
| X86FullDiagID::CXXTemplateVariadicParam
| X86FullDiagID::CXXTemplateParameterPack
| X86FullDiagID::CXXTemplateArgPackExpansion => DiagSeverity::Error,
X86FullDiagID::CXXAccessControlPublic
| X86FullDiagID::CXXUsingDeclaration
| X86FullDiagID::CXXUsingDirective
| X86FullDiagID::CXXAnonymousStruct
| X86FullDiagID::CXXAnonymousUnionMember
| X86FullDiagID::CXXOverloadCandidateNotViable => DiagSeverity::Note,
X86FullDiagID::X86FeatureSSE
| X86FullDiagID::X86FeatureSSE2
| X86FullDiagID::X86FeatureSSE3
| X86FullDiagID::X86FeatureSSSE3
| X86FullDiagID::X86FeatureSSE41
| X86FullDiagID::X86FeatureSSE42
| X86FullDiagID::X86FeatureAVX
| X86FullDiagID::X86FeatureAVX2
| X86FullDiagID::X86FeatureAVX512F
| X86FullDiagID::X86FeatureAVX512BW
| X86FullDiagID::X86FeatureAVX512DQ
| X86FullDiagID::X86FeatureAVX512VL
| X86FullDiagID::X86FeatureAVX512BF16
| X86FullDiagID::X86FeatureAVX512FP16
| X86FullDiagID::X86FeatureAVX512VBMI
| X86FullDiagID::X86FeatureAVX512VBMI2
| X86FullDiagID::X86FeatureAVX512VNNI
| X86FullDiagID::X86FeatureAVX512BITALG
| X86FullDiagID::X86FeatureAVX512VPOPCNTDQ
| X86FullDiagID::X86FeatureAVX10_1_256
| X86FullDiagID::X86FeatureAVX10_1_512
| X86FullDiagID::X86FeatureAVX10_2
| X86FullDiagID::X86FeatureFMA
| X86FullDiagID::X86FeatureFMA4
| X86FullDiagID::X86FeatureF16C
| X86FullDiagID::X86FeatureMMX
| X86FullDiagID::X86FeatureSSE4a
| X86FullDiagID::X86FeatureXOP
| X86FullDiagID::X86Feature3DNOW
| X86FullDiagID::X86Feature3DNOWA
| X86FullDiagID::X86FeatureBMI
| X86FullDiagID::X86FeatureBMI2
| X86FullDiagID::X86FeatureLZCNT
| X86FullDiagID::X86FeaturePOPCNT
| X86FullDiagID::X86FeatureTBM
| X86FullDiagID::X86FeatureAES
| X86FullDiagID::X86FeaturePCLMUL
| X86FullDiagID::X86FeatureSHA
| X86FullDiagID::X86FeatureSHA512
| X86FullDiagID::X86FeatureSM3
| X86FullDiagID::X86FeatureSM4
| X86FullDiagID::X86FeatureGFNI
| X86FullDiagID::X86FeatureVAES
| X86FullDiagID::X86FeatureVPCLMULQDQ
| X86FullDiagID::X86FeatureRDRAND
| X86FullDiagID::X86FeatureRDSEED
| X86FullDiagID::X86FeatureADX
| X86FullDiagID::X86FeatureRTM
| X86FullDiagID::X86FeatureHLE
| X86FullDiagID::X86FeatureSGX
| X86FullDiagID::X86FeatureCET
| X86FullDiagID::X86FeatureCETSS
| X86FullDiagID::X86FeatureXSAVE
| X86FullDiagID::X86FeatureXSAVEOPT
| X86FullDiagID::X86FeatureXSAVEC
| X86FullDiagID::X86FeatureXSAVES
| X86FullDiagID::X86FeatureFSGSBASE
| X86FullDiagID::X86FeatureMOVBE
| X86FullDiagID::X86FeatureMOVDIRI
| X86FullDiagID::X86FeatureMOVDIR64B
| X86FullDiagID::X86FeatureENQCMD
| X86FullDiagID::X86FeatureSERIALIZE
| X86FullDiagID::X86FeatureTSXLDTRK
| X86FullDiagID::X86FeatureWAITPKG
| X86FullDiagID::X86FeatureCLDEMOTE
| X86FullDiagID::X86FeatureCLFLUSHOPT
| X86FullDiagID::X86FeatureCLWB
| X86FullDiagID::X86FeatureCLZERO
| X86FullDiagID::X86FeaturePKU
| X86FullDiagID::X86FeatureAMX_BF16
| X86FullDiagID::X86FeatureAMX_INT8
| X86FullDiagID::X86FeatureAMX_TILE
| X86FullDiagID::X86FeatureAMX_FP16
| X86FullDiagID::X86FeatureAMX_COMPLEX
| X86FullDiagID::X86FeatureX87
| X86FullDiagID::X86FeatureCMOV
| X86FullDiagID::X86CallingConventionMismatch
| X86FullDiagID::X86ABIViolation
| X86FullDiagID::X86StructReturnTooLarge
| X86FullDiagID::X86VectorTypeNotSupported
| X86FullDiagID::X86IntrinsicNotAvailable
| X86FullDiagID::X86CPUFeatureNotAvailable
| X86FullDiagID::X86TargetAttributeConflict
| X86FullDiagID::X86OptionArchMismatch
| X86FullDiagID::X86ABIStructTooLarge
| X86FullDiagID::X86ABIHiddenPointerReturn
| X86FullDiagID::X86ABIRedZoneViolation
| X86FullDiagID::X86ABIStackAlignmentViolation
| X86FullDiagID::X86ABIVectorcallAlignment
| X86FullDiagID::X86ABIFastcallTooManyArgs
| X86FullDiagID::X86ABIThiscallNonMember
| X86FullDiagID::X86ABIStdCallVarArgs
| X86FullDiagID::X86ABIRegCallNotEnoughRegs
| X86FullDiagID::X86ABISysVClassificationFailed
| X86FullDiagID::X86ABIMicrosoftClassificationFailed
| X86FullDiagID::X86ABIRegCallClassificationFailed
| X86FullDiagID::X86ABIEmptyStructPass
| X86FullDiagID::X86ABIPackedStructPass
| X86FullDiagID::X86ABIBitfieldStraddle
| X86FullDiagID::X86ABIComplexReturn
| X86FullDiagID::X86ABIX87Return
| X86FullDiagID::X86InlineASMInvalidConstraint
| X86FullDiagID::X86InlineASMTooManyOperands
| X86FullDiagID::X86InlineASMGlobalRegister
| X86FullDiagID::X86VectorWidthMismatch
| X86FullDiagID::X86VectorShuffleInvalid
| X86FullDiagID::X86VectorGatherAlign
| X86FullDiagID::X86VectorMaskMissing
| X86FullDiagID::X86AlignmentNone
| X86FullDiagID::X86AlignmentUnaligned
| X86FullDiagID::X86RedZoneViolation
| X86FullDiagID::X86StackSize
| X86FullDiagID::X86NopPadding => DiagSeverity::Warning,
X86FullDiagID::X86InlineASMInvalidInstruction
| X86FullDiagID::X86InlineASMClobberConflict => DiagSeverity::Error,
X86FullDiagID::X86FeatureAVX512CD
| X86FullDiagID::X86FeatureAVX512ER
| X86FullDiagID::X86FeatureAVX512PF
| X86FullDiagID::X86FeatureAVX5124FMAPS
| X86FullDiagID::X86FeatureAVX5124VNNIW
| X86FullDiagID::X86FeatureAVX512VP2INTERSECT
| X86FullDiagID::X86FeatureAVX512IFMA
| X86FullDiagID::X86FeatureAVX512FP16Conv
| X86FullDiagID::X86FeatureSM3
| X86FullDiagID::X86FeatureSM4 => DiagSeverity::Error,
X86FullDiagID::OptInlineRemark
| X86FullDiagID::OptInlineRemarkCost
| X86FullDiagID::OptInlineRemarkCallSite
| X86FullDiagID::OptVectorizationRemark
| X86FullDiagID::OptSLPVectorized
| X86FullDiagID::OptLoopUnrollRemark
| X86FullDiagID::OptLoopUnrollComplete
| X86FullDiagID::OptLoopFusion
| X86FullDiagID::OptLoopDistribution
| X86FullDiagID::OptLoopInterchange
| X86FullDiagID::OptLoopUnswitch
| X86FullDiagID::OptDevirtualizeRemark
| X86FullDiagID::OptGVNLoadElim
| X86FullDiagID::OptMemCpyOpt
| X86FullDiagID::OptConstantHoisting
| X86FullDiagID::OptReassociation
| X86FullDiagID::OptLICMHoist
| X86FullDiagID::OptLICMSink
| X86FullDiagID::OptDeadStoreElim
| X86FullDiagID::OptDeadCodeElim
| X86FullDiagID::OptInstructionSimplify
| X86FullDiagID::OptTailCallElim
| X86FullDiagID::OptSROA
| X86FullDiagID::OptMergeFunctions
| X86FullDiagID::OptGlobalOpt
| X86FullDiagID::OptIPSCCP
| X86FullDiagID::OptAttributeOptimize
| X86FullDiagID::OptLoopUnrollPartial => DiagSeverity::Remark,
X86FullDiagID::OptInlineFailure
| X86FullDiagID::OptInlineCostTooHigh
| X86FullDiagID::OptInlineNoDefinition
| X86FullDiagID::OptInlineRecursive
| X86FullDiagID::OptInlineNoInlineAttr
| X86FullDiagID::OptInlineAlwaysInline
| X86FullDiagID::OptInlineNoOptimize
| X86FullDiagID::OptInlineOptNone
| X86FullDiagID::OptVectorizationFailure
| X86FullDiagID::OptVectorizationUnsafeDep
| X86FullDiagID::OptVectorizationNoAlias
| X86FullDiagID::OptVectorizationUnaligned
| X86FullDiagID::OptVectorizationNoReduction
| X86FullDiagID::OptVectorizationSmallTrip
| X86FullDiagID::OptVectorizationNonLinear
| X86FullDiagID::OptVectorizationIneffective
| X86FullDiagID::OptLoopUnrollFailure
| X86FullDiagID::OptLoopUnrollTooLarge
| X86FullDiagID::OptLoopUnrollNonConstant
| X86FullDiagID::OptLoopFusionFailure
| X86FullDiagID::OptLoopDistributionFailure
| X86FullDiagID::OptLoopInterchangeFailure
| X86FullDiagID::OptLoopUnswitchFailure
| X86FullDiagID::OptDevirtualizeFailure
| X86FullDiagID::OptDevirtualizeNoVtable
| X86FullDiagID::OptDevirtualizeMultiInheritance
| X86FullDiagID::OptDevirtualizeUnknown
| X86FullDiagID::OptSLPVectorizeFailure
| X86FullDiagID::OptTailCallFailure
| X86FullDiagID::OptSROAFailure
| X86FullDiagID::OptProfileDataMissing
| X86FullDiagID::OptSampleProfile => DiagSeverity::Warning,
X86FullDiagID::SecFormatString
| X86FullDiagID::SecFormatStringOverflow
| X86FullDiagID::SecFormatStringNoArgs
| X86FullDiagID::SecFormatStringExtraArgs
| X86FullDiagID::SecFormatStringMismatch
| X86FullDiagID::SecFormatStringSecurity
| X86FullDiagID::SecFormatStringNonLiteral
| X86FullDiagID::SecFormatStringPositional
| X86FullDiagID::SecBufferOverflow
| X86FullDiagID::SecBufferOverflowStack
| X86FullDiagID::SecBufferOverflowHeap
| X86FullDiagID::SecBufferOverflowGlobal
| X86FullDiagID::SecBufferOverflowDynamic
| X86FullDiagID::SecBufferUnderflow
| X86FullDiagID::SecUseAfterFree
| X86FullDiagID::SecDoubleFree
| X86FullDiagID::SecUseAfterScope
| X86FullDiagID::SecReturnStackBuffer
| X86FullDiagID::SecNullDereference
| X86FullDiagID::SecNullDereferenceUnlikely
| X86FullDiagID::SecDivisionByZero
| X86FullDiagID::SecIntegerOverflow
| X86FullDiagID::SecShiftCountNegative
| X86FullDiagID::SecShiftCountOverflow
| X86FullDiagID::SecShiftNegative
| X86FullDiagID::SecAlignmentViolation
| X86FullDiagID::SecCastAlign
| X86FullDiagID::SecCastAlignDown
| X86FullDiagID::SecStrictAliasing
| X86FullDiagID::SecTypePunning
| X86FullDiagID::SecUninitializedRead
| X86FullDiagID::SecUninitializedStack
| X86FullDiagID::SecUninitializedHeap
| X86FullDiagID::SecStackProtector
| X86FullDiagID::SecStackProtectorStrong
| X86FullDiagID::SecStackClash
| X86FullDiagID::SecStackExhausted
| X86FullDiagID::SecAllocaTooLarge
| X86FullDiagID::SecVLAInKernel
| X86FullDiagID::SecVLATooLarge
| X86FullDiagID::SecFORTIFYSource
| X86FullDiagID::SecBoundsCheck
| X86FullDiagID::SecImplicitConversion
| X86FullDiagID::SecSignedToUnsigned
| X86FullDiagID::SecTruncation
| X86FullDiagID::SecSignExtension
| X86FullDiagID::SecDeprecatedAPI
| X86FullDiagID::SecUnsafeFunction
| X86FullDiagID::SecUntrustedInput
| X86FullDiagID::SecFormatTruncation => DiagSeverity::Warning,
_ if X86DiagnosticCatalog::is_fatal_id(id) => DiagSeverity::Fatal,
_ => DiagSeverity::Warning,
}
}
fn is_fatal_id(id: X86FullDiagID) -> bool {
matches!(
id,
X86FullDiagID::FatalNoInputFiles
| X86FullDiagID::FatalCannotOpenFile
| X86FullDiagID::FatalCannotWriteFile
| X86FullDiagID::FatalCannotExecuteBinary
| X86FullDiagID::FatalOutOfMemory
| X86FullDiagID::FatalStackExhausted
| X86FullDiagID::FatalIncludeTooDeep
| X86FullDiagID::FatalMacroExpansionTooDeep
| X86FullDiagID::FatalTemplateInstantiationTooDeep
| X86FullDiagID::FatalRecursiveTemplateInstantiation
| X86FullDiagID::FatalTooManyErrors
| X86FullDiagID::FatalInvalidTarget
| X86FullDiagID::FatalUnsupportedTarget
| X86FullDiagID::FatalInvalidArch
| X86FullDiagID::FatalInvalidCPU
| X86FullDiagID::FatalInvalidFeature
| X86FullDiagID::FatalInvalidOption
| X86FullDiagID::FatalConflictingOptions
| X86FullDiagID::FatalMissingArg
| X86FullDiagID::FatalUnknownArg
| X86FullDiagID::FatalInvalidValue
| X86FullDiagID::FatalModuleBuildFailed
| X86FullDiagID::FatalModuleFileOutOfDate
| X86FullDiagID::FatalModuleFileInvalid
| X86FullDiagID::FatalCyclicModuleDependency
| X86FullDiagID::FatalPCHOutOfDate
| X86FullDiagID::FatalPCHInvalid
| X86FullDiagID::FatalPCHCXXMismatch
| X86FullDiagID::FatalPCHTargetMismatch
| X86FullDiagID::FatalPCHLanguageMismatch
| X86FullDiagID::FatalPCHVersionMismatch
| X86FullDiagID::FatalCannotFindHeaders
| X86FullDiagID::FatalCannotFindSDK
| X86FullDiagID::FatalSDKTooOld
| X86FullDiagID::FatalBrokenInstallation
| X86FullDiagID::FatalInternalError
| X86FullDiagID::FatalUnimplemented
| X86FullDiagID::FatalLTOError
| X86FullDiagID::FatalBackendError
| X86FullDiagID::FatalCodeGenError
)
}
pub fn category(id: X86FullDiagID) -> &'static str {
match id {
X86FullDiagID::LexIllegalChar
| X86FullDiagID::LexInvalidToken
| X86FullDiagID::LexUnterminatedString
| X86FullDiagID::LexUnterminatedChar
| X86FullDiagID::LexInvalidEscapeSequence
| X86FullDiagID::LexInvalidUniversalCharName
| X86FullDiagID::LexInvalidRawStringDelim
| X86FullDiagID::LexInvalidRawStringPrefix
| X86FullDiagID::LexNumericLiteralTooLarge
| X86FullDiagID::LexInvalidSuffix
| X86FullDiagID::LexTrigraphWarning
| X86FullDiagID::LexTrigraphIgnored
| X86FullDiagID::LexDigraph
| X86FullDiagID::LexHeaderName
| X86FullDiagID::LexNullCharInFile
| X86FullDiagID::LexUnicodeSurrogate
| X86FullDiagID::LexUTF8InvalidByte
| X86FullDiagID::LexMultibyteChar
| X86FullDiagID::LexWhitespaceRequired
| X86FullDiagID::LexHexEscapeOutOfRange
| X86FullDiagID::LexOctalEscapeOutOfRange
| X86FullDiagID::LexInlineASM
| X86FullDiagID::LexHashInNonDirective
| X86FullDiagID::LexUnknownPragma
| X86FullDiagID::LexUnterminatedBlockComment
| X86FullDiagID::LexNestedBlockComment
| X86FullDiagID::LexNullDirective
| X86FullDiagID::LexEmptySourceFile
| X86FullDiagID::LexBOMDetected
| X86FullDiagID::LexEncodingWarning
| X86FullDiagID::LexCRLFInRawString
| X86FullDiagID::LexEmbeddedDirective
| X86FullDiagID::LexLongUTF8Sequence
| X86FullDiagID::LexNonASCIIIdentifier
| X86FullDiagID::LexReservedIdentifier
| X86FullDiagID::LexDollarInIdentifier
| X86FullDiagID::LexUnderscoreReserved
| X86FullDiagID::LexAlternativeToken
| X86FullDiagID::LexOperatorSpelling
| X86FullDiagID::LexHexFloatLiteral
| X86FullDiagID::LexBinaryLiteral
| X86FullDiagID::LexComplexLiteral
| X86FullDiagID::LexImaginaryLiteral
| X86FullDiagID::LexUserDefinedLiteralRaw
| X86FullDiagID::LexUserDefinedLiteralCooked
| X86FullDiagID::LexCharLiteralMultiChar
| X86FullDiagID::LexCharLiteralWide
| X86FullDiagID::LexCharLiteralUTF8
| X86FullDiagID::LexCharLiteralUTF16
| X86FullDiagID::LexCharLiteralUTF32
| X86FullDiagID::LexStringLiteralWide
| X86FullDiagID::LexStringLiteralUTF8
| X86FullDiagID::LexStringLiteralUTF16
| X86FullDiagID::LexStringLiteralUTF32
| X86FullDiagID::LexStringLiteralConcat
| X86FullDiagID::LexTooManyContinuations
| X86FullDiagID::LexMissingNewlineAtEOF
| X86FullDiagID::LexExtraNewlineAtEOF
| X86FullDiagID::LexOffsetExceedsFile => "Lexer",
_ if X86DiagnosticCatalog::category_name_starts_with(id, "PP") => "Preprocessor",
_ if X86DiagnosticCatalog::category_name_starts_with(id, "Parse") => "Parser",
_ if X86DiagnosticCatalog::category_name_starts_with(id, "Sema") => "Semantic Analysis",
_ if X86DiagnosticCatalog::category_name_starts_with(id, "CXX") => "C++ Frontend",
_ if X86DiagnosticCatalog::category_name_starts_with(id, "X86") => "X86 Target",
_ if X86DiagnosticCatalog::category_name_starts_with(id, "Opt") => "Optimization",
_ if X86DiagnosticCatalog::category_name_starts_with(id, "Sec") => "Security",
_ if X86DiagnosticCatalog::category_name_starts_with(id, "Fatal") => "Fatal",
_ => "Unknown",
}
}
fn category_name_starts_with(id: X86FullDiagID, prefix: &str) -> bool {
let name = format!("{:?}", id);
name.starts_with(prefix)
}
pub fn flag_name(id: X86FullDiagID) -> &'static str {
match id {
X86FullDiagID::LexIllegalChar => "-Wnull-character",
X86FullDiagID::LexInvalidToken => "",
X86FullDiagID::LexUnterminatedString => "-Wunicode",
X86FullDiagID::LexUnterminatedChar => "-Wunicode",
X86FullDiagID::LexInvalidEscapeSequence => "-Wunknown-escape-sequence",
X86FullDiagID::LexInvalidUniversalCharName => "-Wunicode",
X86FullDiagID::LexInvalidRawStringDelim => "-Wraw-string-delimiter",
X86FullDiagID::LexInvalidRawStringPrefix => "-Wraw-string-delimiter",
X86FullDiagID::LexNumericLiteralTooLarge => "-Wimplicitly-unsigned-literal",
X86FullDiagID::LexInvalidSuffix => "-Wliteral-suffix",
X86FullDiagID::LexTrigraphWarning => "-Wtrigraphs",
X86FullDiagID::LexTrigraphIgnored => "-Wtrigraphs",
X86FullDiagID::LexDigraph => "-Wdigraphs",
X86FullDiagID::LexHeaderName => "",
X86FullDiagID::LexNullCharInFile => "-Wnull-character",
X86FullDiagID::LexUnicodeSurrogate => "-Wunicode",
X86FullDiagID::LexUTF8InvalidByte => "-Winvalid-utf8",
X86FullDiagID::LexMultibyteChar => "-Wmultichar",
X86FullDiagID::LexWhitespaceRequired => "-Wwhitespace",
X86FullDiagID::LexHexEscapeOutOfRange => "-Wunicode",
X86FullDiagID::LexOctalEscapeOutOfRange => "-Wunicode",
X86FullDiagID::LexInlineASM => "",
X86FullDiagID::LexHashInNonDirective => "-Wextra-tokens",
X86FullDiagID::LexUnknownPragma => "-Wunknown-pragmas",
X86FullDiagID::LexUnterminatedBlockComment => "-Wcomment",
X86FullDiagID::LexNestedBlockComment => "-Wcomment",
X86FullDiagID::LexNullDirective => "-Wextra-tokens",
X86FullDiagID::LexEmptySourceFile => "",
X86FullDiagID::LexBOMDetected => "-Wbom",
X86FullDiagID::LexEncodingWarning => "-Wsource-encoding",
X86FullDiagID::LexCRLFInRawString => "-Wraw-string-newline",
X86FullDiagID::LexEmbeddedDirective => "-Wembedded-directive",
X86FullDiagID::LexLongUTF8Sequence => "-Wunicode",
X86FullDiagID::LexNonASCIIIdentifier => "-Wnon-ascii",
X86FullDiagID::LexReservedIdentifier => "-Wreserved-identifier",
X86FullDiagID::LexDollarInIdentifier => "-Wdollar-in-identifier-extension",
X86FullDiagID::LexUnderscoreReserved => "-Wreserved-identifier",
X86FullDiagID::LexAlternativeToken => "-Walternative-tokens",
X86FullDiagID::LexOperatorSpelling => "-Walternative-tokens",
X86FullDiagID::LexHexFloatLiteral => "-Wgnu",
X86FullDiagID::LexBinaryLiteral => "-Wgnu-binary-literal",
X86FullDiagID::LexComplexLiteral => "-Wcomplex-component-init",
X86FullDiagID::LexImaginaryLiteral => "-Wgnu-imaginary-constant",
X86FullDiagID::LexUserDefinedLiteralRaw => "-Wuser-defined-literals",
X86FullDiagID::LexUserDefinedLiteralCooked => "-Wuser-defined-literals",
X86FullDiagID::LexCharLiteralMultiChar => "-Wmultichar",
X86FullDiagID::LexCharLiteralWide => "",
X86FullDiagID::LexCharLiteralUTF8 => "",
X86FullDiagID::LexCharLiteralUTF16 => "",
X86FullDiagID::LexCharLiteralUTF32 => "",
X86FullDiagID::LexStringLiteralWide => "",
X86FullDiagID::LexStringLiteralUTF8 => "",
X86FullDiagID::LexStringLiteralUTF16 => "",
X86FullDiagID::LexStringLiteralUTF32 => "",
X86FullDiagID::LexStringLiteralConcat => "-Wstring-concatenation",
X86FullDiagID::LexTooManyContinuations => "-Woverlength-strings",
X86FullDiagID::LexMissingNewlineAtEOF => "-Wnewline-eof",
X86FullDiagID::LexExtraNewlineAtEOF => "-Wextra-tokens",
X86FullDiagID::LexOffsetExceedsFile => "",
X86FullDiagID::PPMacroRedefined => "-Wmacro-redefined",
X86FullDiagID::PPMacroNotDefined => "-Wundef",
X86FullDiagID::PPInvalidMacroName => "",
X86FullDiagID::PPUnterminatedMacro => "-Wunterminated-macro",
X86FullDiagID::PPExtraTokensAtEndOfDirective => "-Wextra-tokens",
X86FullDiagID::PPMissingEndif => "",
X86FullDiagID::PPElifWithoutIf => "",
X86FullDiagID::PPElseWithoutIf => "",
X86FullDiagID::PPEndifWithoutIf => "",
X86FullDiagID::PPInvalidDirective => "-Winvalid-pp-directive",
X86FullDiagID::PPWrongNumberOfMacroArgs => "-Wmacro-args",
X86FullDiagID::PPTooFewMacroArgs => "-Wmacro-args",
X86FullDiagID::PPTooManyMacroArgs => "-Wmacro-args",
X86FullDiagID::PPBuiltinMacroRedefined => "-Wbuiltin-macro-redefined",
X86FullDiagID::PPPragmaOnceInMainFile => "-Wpragma-once-outside-header",
X86FullDiagID::PPPragmaMessage => "-W#pragma-messages",
X86FullDiagID::PPPragmaSystemHeader => "",
X86FullDiagID::PPPragmaDiagnosticPush => "",
X86FullDiagID::PPPragmaDiagnosticPop => "",
X86FullDiagID::PPIncludeNestedTooDeeply => "",
X86FullDiagID::PPHeaderNotFound => "",
X86FullDiagID::PPHeaderCannotOpen => "",
X86FullDiagID::PPInvalidIncludeDirective => "",
X86FullDiagID::PPIncludeNextInPrimaryFile => "-Winclude-next-outside-header",
X86FullDiagID::PPWarningDirective => "-W#warnings",
X86FullDiagID::PPErrorDirective => "",
X86FullDiagID::PPImportInMacro => "-Wimport-in-macro",
X86FullDiagID::PPIncludeMacroUsage => "-Winclude-macro",
X86FullDiagID::PPUndefOfBuiltin => "-Wbuiltin-macro-redefined",
X86FullDiagID::PPMacroAsArgument => "-Wmacro-args",
X86FullDiagID::PPNullArgInVariadic => "-Wvariadic-macros",
X86FullDiagID::PPEmptyVariadicMacro => "-Wvariadic-macros",
X86FullDiagID::PPGNUVariadicMacro => "-Wgnu-zero-variadic-macro-arguments",
X86FullDiagID::PPC99VariadicMacro => "-Wvariadic-macros",
X86FullDiagID::PPMSVariadicMacro => "-Wmicrosoft-variadic-macro",
X86FullDiagID::PPMissingWhitespaceAfterMacro => "-Wmissing-whitespace-after-macro-name",
X86FullDiagID::PPPragmaUnused => "-Wunknown-pragmas",
X86FullDiagID::PPMacroExpansionTooDeep => "",
X86FullDiagID::PPStringifyEmpty => "-Wextra-tokens",
X86FullDiagID::PPHashHashSingleHash => "",
X86FullDiagID::PPLineDirective => "-Wline-directive",
X86FullDiagID::PPFileDirective => "",
X86FullDiagID::PPBadPaste => "",
X86FullDiagID::PPBadStringify => "",
X86FullDiagID::PPEmptyTranslationUnit => "",
X86FullDiagID::PPPragmaGCCSystemHeader => "",
X86FullDiagID::PPPragmaGCCDependency => "",
X86FullDiagID::PPPragmaGCCPoison => "",
X86FullDiagID::PPPragmaGCCVisibility => "",
X86FullDiagID::PPPragmaClangAttribute => "",
X86FullDiagID::PPPragmaClangDiagnostic => "",
X86FullDiagID::PPPragmaClangModule => "",
X86FullDiagID::PPMacroUsedBeforeDefined => "-Wused-but-marked-unused",
X86FullDiagID::PPMacroRedefinedDifferent => "-Wmacro-redefined",
X86FullDiagID::PPMacroArgUnused => "-Wunused-macros",
X86FullDiagID::PPMacroArgNameConflict => "-Wshadow",
X86FullDiagID::PPMacroArgReserved => "-Wreserved-macro-identifier",
X86FullDiagID::PPDefinedOperatorInMacro => "-Wexpansion-to-defined",
X86FullDiagID::PPPragmaAlign => "",
X86FullDiagID::PPPragmaPack => "",
X86FullDiagID::PPPragmaPackShow => "",
X86FullDiagID::PPPragmaComment => "",
X86FullDiagID::PPHeaderGuardMismatch => "-Wheader-guard",
X86FullDiagID::PPPragmaOnceWarning => "-Wpragma-once-outside-header",
X86FullDiagID::PPFileNotUTF8 => "-Winvalid-utf8",
X86FullDiagID::PPImplicitDefine => "",
X86FullDiagID::PPImplicitInclude => "",
X86FullDiagID::PPDateMacro => "",
X86FullDiagID::PPTimeMacro => "",
X86FullDiagID::PPFileMacro => "",
X86FullDiagID::PPLineMacro => "",
X86FullDiagID::PPCounterMacro => "",
X86FullDiagID::PPFunctionMacro => "",
X86FullDiagID::PPBaseFileMacro => "",
X86FullDiagID::PPIncludeDepthExceeded => "",
X86FullDiagID::PPPragmaRegion => "",
X86FullDiagID::PPPragmaEndRegion => "",
X86FullDiagID::PPUnterminatedConditional => "-Wunterminated-conditional",
X86FullDiagID::PPBadTokenPaste => "",
X86FullDiagID::PPAttributePushPopMismatch => "-Wpragma-pack",
X86FullDiagID::ParseExpectedToken => "",
X86FullDiagID::ParseUnexpectedToken => "",
X86FullDiagID::ParseExpectedExpression => "",
X86FullDiagID::ParseExpectedType => "",
X86FullDiagID::ParseExpectedIdentifier => "",
X86FullDiagID::ParseExpectedFunctionBody => "",
X86FullDiagID::ParseMissingSemicolon => "-Wextra-semi",
X86FullDiagID::ParseMissingClosingBrace => "",
X86FullDiagID::ParseMissingClosingParen => "",
X86FullDiagID::ParseMissingClosingBracket => "",
X86FullDiagID::ParseDuplicateDeclaration => "-Wduplicate-decl-specifier",
X86FullDiagID::ParseConflictingTypes => "",
X86FullDiagID::ParseRedefinition => "",
X86FullDiagID::ParseTypedefRedefinition => "",
X86FullDiagID::ParseEnumRedefinition => "",
X86FullDiagID::ParseLabelRedefinition => "",
X86FullDiagID::ParseUndeclaredIdentifier => "",
X86FullDiagID::ParseImplicitDeclaration => "-Wimplicit-function-declaration",
X86FullDiagID::ParseTypeMismatch => "",
X86FullDiagID::ParseIncompatibleTypes => "",
X86FullDiagID::ParseInvalidCast => "-Wbad-function-cast",
X86FullDiagID::ParseVoidExpression => "",
X86FullDiagID::ParseVoidParameter => "",
X86FullDiagID::ParseVoidReturn => "",
X86FullDiagID::ParseEmptyDeclaration => "-Wempty-declaration",
X86FullDiagID::ParseStorageClassSpecifier => "",
X86FullDiagID::ParseDuplicateSpecifier => "-Wduplicate-decl-specifier",
X86FullDiagID::ParseInvalidStorageClass => "",
X86FullDiagID::ParseMultipleStorageClasses => "-Wduplicate-decl-specifier",
X86FullDiagID::ParseDanglingElse => "-Wdangling-else",
X86FullDiagID::ParseAmbiguousElse => "-Wdangling-else",
X86FullDiagID::ParseEOFExpected => "",
X86FullDiagID::ParseVexingParse => "-Wvexing-parse",
X86FullDiagID::ParseMostVexingParse => "-Wvexing-parse",
X86FullDiagID::ParseFunctionDefNoPrototype => "-Wstrict-prototypes",
X86FullDiagID::ParseKandRParameters => "-Wdeprecated-non-prototype",
X86FullDiagID::ParseOldStyleDefinition => "-Wold-style-definition",
X86FullDiagID::ParseNestedFunction => "-Wnested-function",
X86FullDiagID::ParseGNUStatementExpression => "-Wgnu-statement-expression",
X86FullDiagID::ParseGNULocalLabel => "-Wgnu-local-label",
X86FullDiagID::ParseGNUConditionalOmittedOperand => "-Wgnu-conditional-omitted-operand",
X86FullDiagID::ParseGNUDesignator => "-Wgnu-designator",
X86FullDiagID::ParseGNUAttribute => "-Wgnu-attribute",
X86FullDiagID::ParseDeclspecAttribute => "-Wmicrosoft-declspec",
X86FullDiagID::ParseAlignasInvalid => "",
X86FullDiagID::ParseAlignasOnParam => "",
X86FullDiagID::ParseAlignasOnBitField => "",
X86FullDiagID::ParseAtomicQualified => "",
X86FullDiagID::ParseNoreturnOnNonFunction => "-Wignored-attributes",
X86FullDiagID::ParseInlineOnMain => "-Winline-main",
X86FullDiagID::ParseDeprecatedMessage => "-Wdeprecated",
X86FullDiagID::ParseUnavailableMessage => "-Wdeprecated",
X86FullDiagID::ParseExpectedTemplateArgList => "",
X86FullDiagID::ParseExpectedBaseClause => "",
X86FullDiagID::ParseExpectedCtorInitializer => "",
X86FullDiagID::ParseInvalidPureSpecifier => "",
X86FullDiagID::ParseUnexpectedFriend => "",
X86FullDiagID::ParseFriendOnLocalClass => "-Wfriend-in-local-class",
X86FullDiagID::ParseUnexpectedVirtual => "",
X86FullDiagID::ParseVirtualInUnion => "",
X86FullDiagID::ParsePureInNonVirtual => "",
X86FullDiagID::ParseFinalInWrongContext => "",
X86FullDiagID::ParseOverrideOutsideClass => "",
X86FullDiagID::ParseExpectedLambdaBody => "",
X86FullDiagID::ParseInvalidLambdaCapture => "",
X86FullDiagID::ParseDefaultInLambda => "-Wc++14-extensions",
X86FullDiagID::ParseMutableOnNonLambda => "",
X86FullDiagID::ParseInitCaptureBeforeCXX14 => "-Wc++14-extensions",
X86FullDiagID::ParseGenericLambdaBeforeCXX14 => "-Wc++14-extensions",
X86FullDiagID::ParseReturnTypeAfterLambda => "",
X86FullDiagID::ParseTemplateParamTooDeep => "",
X86FullDiagID::ParseTemplateDefaultArg => "",
X86FullDiagID::ParseExpectedTemplateParam => "",
X86FullDiagID::ParseConceptDefinition => "",
X86FullDiagID::ParseRequiresClause => "",
X86FullDiagID::ParseRequiresExpression => "",
X86FullDiagID::ParseCoroutineKeyword => "",
X86FullDiagID::ParseCoAwaitOutsideCoroutine => "",
X86FullDiagID::ParseCoYieldOutsideCoroutine => "",
X86FullDiagID::ParseCoReturnOutsideCoroutine => "",
X86FullDiagID::ParseModuleDeclaration => "",
X86FullDiagID::ParseModuleImport => "",
X86FullDiagID::ParseModuleExport => "",
X86FullDiagID::ParseExpectedModuleName => "",
_ => X86DiagnosticCatalog::sema_cxx_flag_name(id),
}
}
fn sema_cxx_flag_name(id: X86FullDiagID) -> &'static str {
match id {
X86FullDiagID::SemaUnreachableCode => "-Wunreachable-code",
X86FullDiagID::SemaUnusedVariable => "-Wunused-variable",
X86FullDiagID::SemaUnusedParameter => "-Wunused-parameter",
X86FullDiagID::SemaUnusedFunction => "-Wunused-function",
X86FullDiagID::SemaUninitializedVariable => "-Wuninitialized",
X86FullDiagID::SemaPotentiallyUninitialized => "-Wconditional-uninitialized",
X86FullDiagID::SemaVLANegativeSize => "-Wvla",
X86FullDiagID::SemaOverflow => "-Woverflow",
X86FullDiagID::SemaDivisionByZero => "",
X86FullDiagID::SemaIncompatiblePointerTypes => "-Wincompatible-pointer-types",
X86FullDiagID::SemaAssignmentIncompatible => "-Wincompatible-pointer-types",
X86FullDiagID::SemaPassingArgumentIncompatible => "-Wincompatible-pointer-types",
X86FullDiagID::SemaReturnIncompatible => "-Wreturn-type",
X86FullDiagID::SemaVoidFuncReturningValue => "",
X86FullDiagID::SemaNonVoidMissingReturn => "-Wreturn-type",
X86FullDiagID::SemaDeprecatedDecl => "-Wdeprecated-declarations",
X86FullDiagID::SemaDeprecatedAttribute => "-Wdeprecated",
X86FullDiagID::SemaDeprecatedWithMessage => "-Wdeprecated",
X86FullDiagID::SemaDeprecatedEnumerator => "-Wdeprecated",
X86FullDiagID::SemaDeprecatedTypedef => "-Wdeprecated",
X86FullDiagID::SemaUnavailableDecl => "-Wunavailable-declarations",
X86FullDiagID::SemaUnavailableAttribute => "-Wunavailable-declarations",
X86FullDiagID::SemaUnavailableWithMessage => "-Wunavailable-declarations",
X86FullDiagID::SemaNullDereference => "-Wnull-dereference",
X86FullDiagID::SemaShiftByNegative => "-Wshift-count-negative",
X86FullDiagID::SemaShiftExceedsWidth => "-Wshift-count-overflow",
X86FullDiagID::SemaSignedOverflow => "-Winteger-overflow",
X86FullDiagID::SemaStrictAliasingViolation => "-Wstrict-aliasing",
X86FullDiagID::SemaUnknownAttribute => "-Wunknown-attributes",
X86FullDiagID::SemaAttributeIgnored => "-Wignored-attributes",
X86FullDiagID::SemaGNUAttributeIgnored => "-Wgnu-attribute",
X86FullDiagID::SemaGCCExtension => "-Wgnu",
X86FullDiagID::SemaMSVCCompatibility => "-Wmicrosoft",
X86FullDiagID::SemaReturnStackAddress => "-Wreturn-stack-address",
X86FullDiagID::SemaReturnLocalAddress => "-Wreturn-local-addr",
X86FullDiagID::SemaDanglingReference => "-Wdangling",
X86FullDiagID::SemaDanglingPointer => "-Wdangling",
X86FullDiagID::SemaCastAlignDown => "-Wcast-align",
X86FullDiagID::SemaCastAlignUp => "-Wcast-align",
X86FullDiagID::SemaStackProtectorFailure => "-Wstack-protector",
X86FullDiagID::SemaIntToFloatPrecisionLoss => "-Wimplicit-int-float-conversion",
X86FullDiagID::SemaFloatToIntOverflow => "-Wfloat-conversion",
X86FullDiagID::SemaDuplicateCase => "-Wduplicate-case",
X86FullDiagID::SemaDuplicateEnumValue => "-Wduplicate-enum",
X86FullDiagID::SemaEnumValueOverflow => "-Wenum-conversion",
X86FullDiagID::SemaLocalDeclNoLinkage => "-Wunused-function",
X86FullDiagID::SemaStaticInInline => "-Wstatic-in-inline",
X86FullDiagID::SemaExternInitializer => "-Wextern-initializer",
X86FullDiagID::CXXAccessControlPrivate => "-Waccess-control",
X86FullDiagID::CXXAccessControlProtected => "-Waccess-control",
X86FullDiagID::CXXAccessControlInaccessible => "-Waccess-control",
X86FullDiagID::CXXVirtualOverrideMismatch => "-Woverloaded-virtual",
X86FullDiagID::CXXMissingOverride => "-Wsuggest-override",
X86FullDiagID::CXXOverrideMismatch => "-Winconsistent-missing-override",
X86FullDiagID::CXXFinalOverride => "-Wfinal-dtor-non-final-class",
X86FullDiagID::CXXFinalClassOverride => "-Wfinal-dtor-non-final-class",
X86FullDiagID::CXXPureVirtualCall => "",
X86FullDiagID::CXXPureVirtualInCtorDtor => "-Wcall-to-pure-virtual-from-ctor-dtor",
X86FullDiagID::CXXAbstractClass => "",
X86FullDiagID::CXXDeletedFunction => "",
X86FullDiagID::CXXConstexprNonConst => "-Winvalid-constexpr",
X86FullDiagID::CXXConstexprNeverConstant => "-Winvalid-constexpr",
X86FullDiagID::CXXNoexceptMismatch => "-Wnoexcept",
X86FullDiagID::CXXNoexceptOverrideNarrower => "-Wnoexcept-type",
X86FullDiagID::CXXTemplateRecursion => "-Wrecursive-template",
X86FullDiagID::CXXDependentNameMissingTypename => "-Wmissing-typename",
X86FullDiagID::CXXOverloadAmbiguity => "-Wambiguous-reversed-operator",
X86FullDiagID::CXXDestructorProtected => "-Wdelete-non-abstract-non-virtual-dtor",
X86FullDiagID::CXXDestructorPrivate => "-Wdelete-non-abstract-non-virtual-dtor",
X86FullDiagID::CXXCopyCtorDeleted => "",
X86FullDiagID::CXXMoveCtorNotUsed => "-Wpessimizing-move",
X86FullDiagID::CXXMoveCtorElision => "-Wredundant-move",
X86FullDiagID::CXXFriendInLocalClass => "-Wlocal-type-template-args",
X86FullDiagID::CXXLambdaCaptureDefault => "-Wlambda-capture-default",
X86FullDiagID::CXXLambdaCaptureThis => "-Wimplicit-lambda-capture",
X86FullDiagID::CXXLambdaGeneric => "-Wc++14-extensions",
X86FullDiagID::CXXLambdaConstexpr => "-Wc++17-extensions",
X86FullDiagID::CXXLambdaTemplate => "-Wc++20-extensions",
X86FullDiagID::CXXCoroutineNoElision => "-Wcoroutine-missing-unhandled-exception",
X86FullDiagID::CXXDesignatedInitOutOfOrder => "-Wreorder-init-list",
X86FullDiagID::CXXDesignatedInitOverride => "-Winitializer-overrides",
X86FullDiagID::CXXCTADExplicit => "-Wctad-maybe-unsupported",
X86FullDiagID::CXXInheritingConstructorConflict => "-Winherited-variadic-ctor",
X86FullDiagID::CXXFoldExpression => "-Wc++17-extensions",
X86FullDiagID::CXXEmptyFold => "-Wempty-fold-expression",
X86FullDiagID::CXXConceptDefaultConstraint => "-Wc++20-extensions",
X86FullDiagID::CXXTwoPhaseLookup => "-Wmicrosoft-template",
X86FullDiagID::CXXTwoPhaseLookupDependent => "-Wmicrosoft-template",
X86FullDiagID::CXXTwoPhaseLookupTwoLevel => "-Wmicrosoft-template",
X86FullDiagID::CXXSFINAEContext => "",
X86FullDiagID::CXXSFINAEDeductionFailed => "",
X86FullDiagID::CXXOverloadCandidateNotViable => "",
X86FullDiagID::X86FeatureSSE => "-Wtarget-feature",
X86FullDiagID::X86FeatureSSE2 => "-Wtarget-feature",
X86FullDiagID::X86FeatureSSE3 => "-Wtarget-feature",
X86FullDiagID::X86FeatureSSSE3 => "-Wtarget-feature",
X86FullDiagID::X86FeatureSSE41 => "-Wtarget-feature",
X86FullDiagID::X86FeatureSSE42 => "-Wtarget-feature",
X86FullDiagID::X86FeatureAVX => "-Wtarget-feature",
X86FullDiagID::X86FeatureAVX2 => "-Wtarget-feature",
X86FullDiagID::X86FeatureAVX512F => "-Wtarget-feature",
X86FullDiagID::X86FeatureFMA => "-Wtarget-feature",
X86FullDiagID::X86FeatureMMX => "-Wtarget-feature",
X86FullDiagID::X86FeatureAES => "-Wtarget-feature",
X86FullDiagID::X86FeaturePCLMUL => "-Wtarget-feature",
X86FullDiagID::X86CallingConventionMismatch => "-Wcall-convention",
X86FullDiagID::X86ABIViolation => "-Wabi",
X86FullDiagID::X86StructReturnTooLarge => "-Wstruct-return",
X86FullDiagID::X86VectorTypeNotSupported => "-Wvector-type",
X86FullDiagID::X86IntrinsicNotAvailable => "-Wintrinsic-not-available",
X86FullDiagID::X86CPUFeatureNotAvailable => "-Wtarget-cpu",
X86FullDiagID::X86TargetAttributeConflict => "-Wtarget-attr",
X86FullDiagID::X86OptionArchMismatch => "-Woption-ignored",
X86FullDiagID::X86ABIStructTooLarge => "-Wpsabi",
X86FullDiagID::X86ABIHiddenPointerReturn => "-Wpsabi",
X86FullDiagID::X86ABIRedZoneViolation => "-Wred-zone",
X86FullDiagID::X86ABIStackAlignmentViolation => "-Wstack-align",
X86FullDiagID::X86ABIVectorcallAlignment => "-Wvectorcall-alignment",
X86FullDiagID::X86ABIFastcallTooManyArgs => "-Wfastcall-args",
X86FullDiagID::X86InlineASMInvalidInstruction => "-Winline-asm",
X86FullDiagID::X86InlineASMInvalidConstraint => "-Winline-asm",
X86FullDiagID::X86InlineASMClobberConflict => "-Winline-asm",
X86FullDiagID::X86InlineASMTooManyOperands => "-Winline-asm",
X86FullDiagID::X86InlineASMGlobalRegister => "-Winline-asm",
X86FullDiagID::X86VectorWidthMismatch => "-Wvector-width-mismatch",
X86FullDiagID::X86VectorShuffleInvalid => "-Wvector-shuffle",
X86FullDiagID::X86VectorGatherAlign => "-Wgather-align",
X86FullDiagID::X86VectorMaskMissing => "-Wvector-mask",
X86FullDiagID::X86AlignmentNone => "-Walignment",
X86FullDiagID::X86AlignmentUnaligned => "-Walignment",
X86FullDiagID::X86RedZoneViolation => "-Wred-zone-violation",
X86FullDiagID::X86StackSize => "-Wframe-larger-than",
X86FullDiagID::X86NopPadding => "-Wnop-padding",
X86FullDiagID::OptInlineRemark => "-Rpass=inline",
X86FullDiagID::OptInlineFailure => "-Rpass-missed=inline",
X86FullDiagID::OptVectorizationRemark => "-Rpass=loop-vectorize",
X86FullDiagID::OptVectorizationFailure => "-Rpass-missed=loop-vectorize",
X86FullDiagID::OptSLPVectorized => "-Rpass=slp-vectorize",
X86FullDiagID::OptSLPVectorizeFailure => "-Rpass-missed=slp-vectorize",
X86FullDiagID::OptLoopUnrollRemark => "-Rpass=loop-unroll",
X86FullDiagID::OptLoopUnrollFailure => "-Rpass-missed=loop-unroll",
X86FullDiagID::OptLoopFusion => "-Rpass=loop-fusion",
X86FullDiagID::OptLoopDistribution => "-Rpass=loop-distribute",
X86FullDiagID::OptDevirtualizeRemark => "-Rpass=devirtualize",
X86FullDiagID::OptDevirtualizeFailure => "-Rpass-missed=devirtualize",
X86FullDiagID::OptGVNLoadElim => "-Rpass=gvn",
X86FullDiagID::OptMemCpyOpt => "-Rpass=memcpyopt",
X86FullDiagID::OptConstantHoisting => "-Rpass=const-hoist",
X86FullDiagID::OptReassociation => "-Rpass=reassociate",
X86FullDiagID::OptLICMHoist => "-Rpass=licm",
X86FullDiagID::OptLICMSink => "-Rpass=licm",
X86FullDiagID::OptDeadStoreElim => "-Rpass=dse",
X86FullDiagID::OptDeadCodeElim => "-Rpass=dce",
X86FullDiagID::OptTailCallElim => "-Rpass=tailcallelim",
X86FullDiagID::OptSROA => "-Rpass=sroa",
X86FullDiagID::OptMergeFunctions => "-Rpass=mergefunc",
X86FullDiagID::OptGlobalOpt => "-Rpass=globalopt",
X86FullDiagID::OptIPSCCP => "-Rpass=ipsccp",
X86FullDiagID::SecFormatString => "-Wformat",
X86FullDiagID::SecFormatStringOverflow => "-Wformat-overflow",
X86FullDiagID::SecFormatStringNoArgs => "-Wformat-zero-length",
X86FullDiagID::SecFormatStringExtraArgs => "-Wformat-extra-args",
X86FullDiagID::SecFormatStringMismatch => "-Wformat",
X86FullDiagID::SecFormatStringSecurity => "-Wformat-security",
X86FullDiagID::SecFormatStringNonLiteral => "-Wformat-nonliteral",
X86FullDiagID::SecFormatStringPositional => "-Wformat",
X86FullDiagID::SecBufferOverflow => "-Warray-bounds",
X86FullDiagID::SecBufferOverflowStack => "-Wstack-protector",
X86FullDiagID::SecUseAfterFree => "-Wuse-after-free",
X86FullDiagID::SecDoubleFree => "-Wdouble-free",
X86FullDiagID::SecReturnStackBuffer => "-Wreturn-stack-address",
X86FullDiagID::SecNullDereference => "-Wnull-dereference",
X86FullDiagID::SecDivisionByZero => "-Wdiv-by-zero",
X86FullDiagID::SecIntegerOverflow => "-Winteger-overflow",
X86FullDiagID::SecShiftCountNegative => "-Wshift-count-negative",
X86FullDiagID::SecShiftCountOverflow => "-Wshift-count-overflow",
X86FullDiagID::SecShiftNegative => "-Wshift-negative-value",
X86FullDiagID::SecAlignmentViolation => "-Walignment",
X86FullDiagID::SecCastAlign => "-Wcast-align",
X86FullDiagID::SecStrictAliasing => "-Wstrict-aliasing",
X86FullDiagID::SecTypePunning => "-Wstrict-aliasing",
X86FullDiagID::SecUninitializedRead => "-Wuninitialized",
X86FullDiagID::SecUninitializedStack => "-Wuninitialized",
X86FullDiagID::SecUninitializedHeap => "-Wuninitialized",
X86FullDiagID::SecStackProtector => "-Wstack-protector",
X86FullDiagID::SecStackProtectorStrong => "-Wstack-protector",
X86FullDiagID::SecStackClash => "-Wstack-clash-protection",
X86FullDiagID::SecStackExhausted => "-Wstack-exhausted",
X86FullDiagID::SecAllocaTooLarge => "-Walloca",
X86FullDiagID::SecVLAInKernel => "-Wvla",
X86FullDiagID::SecVLATooLarge => "-Wvla-larger-than",
X86FullDiagID::SecFORTIFYSource => "-Wfortify-source",
X86FullDiagID::SecImplicitConversion => "-Wconversion",
X86FullDiagID::SecSignedToUnsigned => "-Wsign-conversion",
X86FullDiagID::SecTruncation => "-Wconversion",
X86FullDiagID::SecDeprecatedAPI => "-Wdeprecated-declarations",
X86FullDiagID::SecUnsafeFunction => "-Wunsafe-buffer-usage",
X86FullDiagID::SecUntrustedInput => "-Wtautological-unsigned-enum-zero-compare",
X86FullDiagID::SecFormatTruncation => "-Wformat-truncation",
X86FullDiagID::FatalNoInputFiles => "",
X86FullDiagID::FatalCannotOpenFile => "",
X86FullDiagID::FatalCannotWriteFile => "",
X86FullDiagID::FatalOutOfMemory => "",
X86FullDiagID::FatalTooManyErrors => "-ferror-limit",
X86FullDiagID::FatalInvalidTarget => "-march",
X86FullDiagID::FatalUnsupportedTarget => "-march",
X86FullDiagID::FatalInvalidArch => "-march",
X86FullDiagID::FatalInvalidCPU => "-mcpu",
X86FullDiagID::FatalInvalidFeature => "-m",
X86FullDiagID::FatalInvalidOption => "",
X86FullDiagID::FatalConflictingOptions => "",
X86FullDiagID::FatalMissingArg => "",
X86FullDiagID::FatalUnknownArg => "",
X86FullDiagID::FatalInternalError => "",
X86FullDiagID::FatalUnimplemented => "",
X86FullDiagID::FatalLTOError => "-flto",
X86FullDiagID::FatalBackendError => "",
X86FullDiagID::FatalCodeGenError => "",
_ => "",
}
}
pub fn message_for(id: X86FullDiagID) -> &'static str {
match id {
X86FullDiagID::LexIllegalChar => "illegal character in source file: '{}'",
X86FullDiagID::LexInvalidToken => "invalid token at start of a preprocessor expression",
X86FullDiagID::LexUnterminatedString => "unterminated string literal, expected '\"'",
X86FullDiagID::LexUnterminatedChar => "unterminated character literal, expected '\\''",
X86FullDiagID::LexInvalidEscapeSequence => "invalid escape sequence '\\{}' in literal",
X86FullDiagID::LexInvalidUniversalCharName => "invalid universal character name '\\u{}'",
X86FullDiagID::LexInvalidRawStringDelim => "raw string delimiter cannot contain ')'",
X86FullDiagID::LexInvalidRawStringPrefix => "invalid raw string delimiter prefix '{}'",
X86FullDiagID::LexNumericLiteralTooLarge => "integer literal is too large to be represented in any integer type",
X86FullDiagID::LexInvalidSuffix => "invalid suffix '{}' on numeric literal",
X86FullDiagID::LexTrigraphWarning => "trigraph converted to '{}' character",
X86FullDiagID::LexTrigraphIgnored => "trigraph ignored",
X86FullDiagID::LexDigraph => "digraph '<:' interpreted as '['",
X86FullDiagID::LexHeaderName => "header name '{}' must be enclosed in angle brackets or double quotes",
X86FullDiagID::LexNullCharInFile => "null character ignored",
X86FullDiagID::LexUnicodeSurrogate => "universal character name refers to a surrogate code point",
X86FullDiagID::LexUTF8InvalidByte => "invalid UTF-8 byte sequence in source file",
X86FullDiagID::LexMultibyteChar => "multi-character character constant",
X86FullDiagID::LexWhitespaceRequired => "whitespace required before '{}'",
X86FullDiagID::LexHexEscapeOutOfRange => "hex escape sequence out of range",
X86FullDiagID::LexOctalEscapeOutOfRange => "octal escape sequence out of range",
X86FullDiagID::LexInlineASM => "inline assembly is not allowed outside a function",
X86FullDiagID::LexHashInNonDirective => "'#' not at start of directive",
X86FullDiagID::LexUnknownPragma => "unknown pragma '{}'",
X86FullDiagID::LexUnterminatedBlockComment => "unterminated /* comment",
X86FullDiagID::LexNestedBlockComment => "'/*' within block comment",
X86FullDiagID::LexNullDirective => "null directive ignored",
X86FullDiagID::LexEmptySourceFile => "empty source file",
X86FullDiagID::LexBOMDetected => "byte order mark (BOM) detected in source file",
X86FullDiagID::LexEncodingWarning => "character encoding '{}' may not be supported",
X86FullDiagID::LexCRLFInRawString => "CRLF in raw string literal",
X86FullDiagID::LexEmbeddedDirective => "embedded directive in macro argument",
X86FullDiagID::LexLongUTF8Sequence => "UTF-8 sequence of length {} is not valid",
X86FullDiagID::LexNonASCIIIdentifier => "non-ASCII characters in identifier",
X86FullDiagID::LexReservedIdentifier => "identifier '{}' is reserved",
X86FullDiagID::LexDollarInIdentifier => "'$' in identifier",
X86FullDiagID::LexUnderscoreReserved => "identifier '_' is reserved",
X86FullDiagID::LexAlternativeToken => "use of alternative token '{}'",
X86FullDiagID::LexOperatorSpelling => "alternative operator spelling used",
X86FullDiagID::LexHexFloatLiteral => "hexadecimal floating-point constant requires C99 or later",
X86FullDiagID::LexBinaryLiteral => "binary integer literal is a GNU extension",
X86FullDiagID::LexComplexLiteral => "complex literal is a GNU extension",
X86FullDiagID::LexImaginaryLiteral => "imaginary literal is a GNU extension",
X86FullDiagID::LexUserDefinedLiteralRaw => "user-defined literal '{}' not found",
X86FullDiagID::LexUserDefinedLiteralCooked => "user-defined literal operator not found",
X86FullDiagID::LexCharLiteralMultiChar => "multi-character character constant",
X86FullDiagID::LexCharLiteralWide => "wide character constant in narrow context",
X86FullDiagID::LexCharLiteralUTF8 => "UTF-8 character constant in narrow context",
X86FullDiagID::LexCharLiteralUTF16 => "UTF-16 character literal is a C++11 extension",
X86FullDiagID::LexCharLiteralUTF32 => "UTF-32 character literal is a C++11 extension",
X86FullDiagID::LexStringLiteralWide => "wide string literal in narrow context",
X86FullDiagID::LexStringLiteralUTF8 => "UTF-8 string literal in execution character set",
X86FullDiagID::LexStringLiteralUTF16 => "UTF-16 string literal is a C++11 extension",
X86FullDiagID::LexStringLiteralUTF32 => "UTF-32 string literal is a C++11 extension",
X86FullDiagID::LexStringLiteralConcat => "concatenation of string literals with different encoding prefixes",
X86FullDiagID::LexTooManyContinuations => "too many continuation lines in string literal",
X86FullDiagID::LexMissingNewlineAtEOF => "no newline at end of file",
X86FullDiagID::LexExtraNewlineAtEOF => "extra newline at end of file",
X86FullDiagID::LexOffsetExceedsFile => "offset exceeds source file size",
X86FullDiagID::PPMacroRedefined => "macro '{}' redefined",
X86FullDiagID::PPMacroNotDefined => "macro '{}' is not defined",
X86FullDiagID::PPInvalidMacroName => "macro name must be an identifier",
X86FullDiagID::PPUnterminatedMacro => "unterminated function-like macro invocation",
X86FullDiagID::PPExtraTokensAtEndOfDirective => "extra tokens at end of '#{}' directive",
X86FullDiagID::PPMissingEndif => "expected '#endif' at end of file",
X86FullDiagID::PPElifWithoutIf => "'#elif' without '#if'",
X86FullDiagID::PPElseWithoutIf => "'#else' without '#if'",
X86FullDiagID::PPEndifWithoutIf => "'#endif' without '#if'",
X86FullDiagID::PPInvalidDirective => "invalid preprocessing directive: '{}'",
X86FullDiagID::PPWrongNumberOfMacroArgs => "macro '{}' passed {} arguments, but takes {}",
X86FullDiagID::PPTooFewMacroArgs => "too few arguments provided to function-like macro invocation",
X86FullDiagID::PPTooManyMacroArgs => "too many arguments provided to function-like macro invocation",
X86FullDiagID::PPBuiltinMacroRedefined => "redefining builtin macro '{}'",
X86FullDiagID::PPPragmaOnceInMainFile => "'#pragma once' in main file",
X86FullDiagID::PPPragmaMessage => "{}",
X86FullDiagID::PPPragmaSystemHeader => "treated as system header",
X86FullDiagID::PPPragmaDiagnosticPush => "pragma diagnostic push",
X86FullDiagID::PPPragmaDiagnosticPop => "pragma diagnostic pop",
X86FullDiagID::PPIncludeNestedTooDeeply => "'#include' nested too deeply",
X86FullDiagID::PPHeaderNotFound => "'{}' file not found",
X86FullDiagID::PPHeaderCannotOpen => "cannot open source file '{}'",
X86FullDiagID::PPInvalidIncludeDirective => "invalid #include directive",
X86FullDiagID::PPIncludeNextInPrimaryFile => "'#include_next' in primary source file",
X86FullDiagID::PPWarningDirective => "#warning: {}",
X86FullDiagID::PPErrorDirective => "#error: {}",
X86FullDiagID::PPImportInMacro => "#import directive used within macro argument",
X86FullDiagID::PPIncludeMacroUsage => "macro used within #include directive",
X86FullDiagID::PPUndefOfBuiltin => "undefining builtin macro '{}'",
X86FullDiagID::PPMacroAsArgument => "macro name used as argument to another macro",
X86FullDiagID::PPNullArgInVariadic => "must specify at least one argument for '...' parameter of macro",
X86FullDiagID::PPEmptyVariadicMacro => "empty variadic macro argument",
X86FullDiagID::PPGNUVariadicMacro => "GNU-style variadic macro used without named argument",
X86FullDiagID::PPC99VariadicMacro => "C99 requires at least one argument before '...' in variadic macro",
X86FullDiagID::PPMSVariadicMacro => "passing no argument for the '...' parameter of a variadic macro is a Microsoft extension",
X86FullDiagID::PPMissingWhitespaceAfterMacro => "missing whitespace after the macro name",
X86FullDiagID::PPPragmaUnused => "unused pragma",
X86FullDiagID::PPMacroExpansionTooDeep => "macro expansion too deeply nested",
X86FullDiagID::PPStringifyEmpty => "result of '#' operator is empty",
X86FullDiagID::PPHashHashSingleHash => "'##' cannot appear at start of macro expansion",
X86FullDiagID::PPLineDirective => "invalid #line directive",
X86FullDiagID::PPFileDirective => "#file directive is a GCC extension",
X86FullDiagID::PPBadPaste => "pasting formed '{}', an invalid preprocessing token",
X86FullDiagID::PPBadStringify => "'#' is not followed by a macro parameter",
X86FullDiagID::PPEmptyTranslationUnit => "empty translation unit",
X86FullDiagID::PPPragmaGCCSystemHeader => "#pragma GCC system_header",
X86FullDiagID::PPPragmaGCCDependency => "#pragma GCC dependency",
X86FullDiagID::PPPragmaGCCPoison => "attempt to use poisoned identifier '{}'",
X86FullDiagID::PPPragmaGCCVisibility => "#pragma GCC visibility",
X86FullDiagID::PPPragmaClangAttribute => "#pragma clang attribute",
X86FullDiagID::PPPragmaClangDiagnostic => "#pragma clang diagnostic",
X86FullDiagID::PPPragmaClangModule => "#pragma clang module",
X86FullDiagID::PPMacroUsedBeforeDefined => "macro '{}' used before definition",
X86FullDiagID::PPMacroRedefinedDifferent => "redefinition of macro '{}' differs from previous definition",
X86FullDiagID::PPMacroArgUnused => "macro argument '{}' not used in expansion",
X86FullDiagID::PPMacroArgNameConflict => "macro argument '{}' conflicts with another identifier",
X86FullDiagID::PPMacroArgReserved => "macro argument uses reserved identifier",
X86FullDiagID::PPDefinedOperatorInMacro => "macro expansion producing 'defined' has undefined behavior",
X86FullDiagID::PPPragmaAlign => "#pragma align",
X86FullDiagID::PPPragmaPack => "#pragma pack",
X86FullDiagID::PPPragmaPackShow => "current #pragma pack alignment is {}",
X86FullDiagID::PPPragmaComment => "#pragma comment",
X86FullDiagID::PPHeaderGuardMismatch => "header guard '{}' does not match file name",
X86FullDiagID::PPPragmaOnceWarning => "'#pragma once' is not in a header file",
X86FullDiagID::PPFileNotUTF8 => "source file is not valid UTF-8",
X86FullDiagID::PPImplicitDefine => "implicit '#define {}'",
X86FullDiagID::PPImplicitInclude => "implicit '#include' of '{}'",
X86FullDiagID::PPDateMacro => "__DATE__ expands to current date",
X86FullDiagID::PPTimeMacro => "__TIME__ expands to current time",
X86FullDiagID::PPFileMacro => "__FILE__ expands to current file name",
X86FullDiagID::PPLineMacro => "__LINE__ expands to current line number",
X86FullDiagID::PPCounterMacro => "__COUNTER__ expands to sequential counter",
X86FullDiagID::PPFunctionMacro => "__FUNCTION__ expands to current function",
X86FullDiagID::PPBaseFileMacro => "__BASE_FILE__ expands to main source file",
X86FullDiagID::PPIncludeDepthExceeded => "#include depth exceeded maximum of {}",
X86FullDiagID::PPPragmaRegion => "#pragma region",
X86FullDiagID::PPPragmaEndRegion => "#pragma endregion",
X86FullDiagID::PPUnterminatedConditional => "unterminated '#if' conditional directive",
X86FullDiagID::PPBadTokenPaste => "token pasting of '{}' and '{}' results in '{}', an invalid preprocessing token",
X86FullDiagID::PPAttributePushPopMismatch => "'#pragma pack(push)' without matching '#pragma pack(pop)'",
X86FullDiagID::ParseExpectedToken => "expected '{}' but found '{}'",
X86FullDiagID::ParseUnexpectedToken => "unexpected token '{}'",
X86FullDiagID::ParseExpectedExpression => "expected expression",
X86FullDiagID::ParseExpectedType => "expected type",
X86FullDiagID::ParseExpectedIdentifier => "expected identifier",
X86FullDiagID::ParseExpectedFunctionBody => "expected function body after function declarator",
X86FullDiagID::ParseMissingSemicolon => "expected ';' after expression",
X86FullDiagID::ParseMissingClosingBrace => "expected '}'",
X86FullDiagID::ParseMissingClosingParen => "expected ')'",
X86FullDiagID::ParseMissingClosingBracket => "expected ']'",
X86FullDiagID::ParseDuplicateDeclaration => "duplicate declaration specifier '{}'",
X86FullDiagID::ParseConflictingTypes => "conflicting types for '{}'",
X86FullDiagID::ParseRedefinition => "redefinition of '{}'",
X86FullDiagID::ParseTypedefRedefinition => "redefinition of '{}' as different kind of symbol",
X86FullDiagID::ParseEnumRedefinition => "redefinition of enumerator '{}'",
X86FullDiagID::ParseLabelRedefinition => "redefinition of label '{}'",
X86FullDiagID::ParseUndeclaredIdentifier => "use of undeclared identifier '{}'",
X86FullDiagID::ParseImplicitDeclaration => "implicit declaration of function '{}' is invalid in C99",
X86FullDiagID::ParseTypeMismatch => "type mismatch in '{}'",
X86FullDiagID::ParseIncompatibleTypes => "assigning to '{}' from incompatible type '{}'",
X86FullDiagID::ParseInvalidCast => "invalid cast from '{}' to '{}'",
X86FullDiagID::ParseVoidExpression => "expression result unused",
X86FullDiagID::ParseVoidParameter => "'void' must be the first and only parameter if specified",
X86FullDiagID::ParseVoidReturn => "void function '{}' should not return a value",
X86FullDiagID::ParseEmptyDeclaration => "empty declaration",
X86FullDiagID::ParseStorageClassSpecifier => "storage class specifier is not allowed here",
X86FullDiagID::ParseDuplicateSpecifier => "duplicate '{}' declaration specifier",
X86FullDiagID::ParseInvalidStorageClass => "invalid storage class specifier",
X86FullDiagID::ParseMultipleStorageClasses => "cannot combine with previous '{}' declaration specifier",
X86FullDiagID::ParseThreadNotStatic => "'thread_local' variable must have static storage duration",
X86FullDiagID::ParseUnexpectedTypedef => "unexpected typedef name '{}'",
X86FullDiagID::ParseExpectedComma => "expected ','",
X86FullDiagID::ParseExpectedColon => "expected ':'",
X86FullDiagID::ParseExpectedRBrace => "expected '}'",
X86FullDiagID::ParseExpectedRParen => "expected ')'",
X86FullDiagID::ParseExpectedRBracket => "expected ']'",
X86FullDiagID::ParseExpectedSemiAfterExpr => "expected ';' after expression",
X86FullDiagID::ParseExpectedSemiAfterDecl => "expected ';' after declaration",
X86FullDiagID::ParseExpectedStatement => "expected statement",
X86FullDiagID::ParseExpectedDeclaration => "expected declaration",
X86FullDiagID::ParseExpectedParameter => "expected parameter declarator",
X86FullDiagID::ParseExpectedLoopBody => "expected loop body",
X86FullDiagID::ParseExpectedSwitchBody => "expected switch body",
X86FullDiagID::ParseExpectedCaseOrDefault => "expected 'case' or 'default'",
X86FullDiagID::ParseExpectedStructUnion => "expected struct or union",
X86FullDiagID::ParseExpectedEnumBody => "expected body of enum declaration",
X86FullDiagID::ParseExpectedEqual => "expected '='",
X86FullDiagID::ParseExpectedAngleBracket => "expected '>'",
X86FullDiagID::ParseExpectedTypeSpecifier => "expected type specifier",
X86FullDiagID::ParseExpectedDeclarator => "expected declarator",
X86FullDiagID::ParseExpectedQualifiedName => "expected qualified name after '::'",
X86FullDiagID::ParseExpectedCompoundStmt => "expected compound statement",
X86FullDiagID::ParseExpectedInitializer => "expected initializer",
X86FullDiagID::ParseExpectedArrow => "expected '->'",
X86FullDiagID::ParseExpectedDot => "expected '.'",
X86FullDiagID::ParseExpectedOperatorName => "expected operator name",
X86FullDiagID::ParseExpectedProperty => "expected property name",
X86FullDiagID::ParseExtraneousToken => "extraneous token '{}'",
X86FullDiagID::ParseEOFExpected => "expected '{}' at end of file",
X86FullDiagID::ParseUnrecognizedDeclaration => "unrecognized declaration specifier",
X86FullDiagID::ParseDanglingElse => "add explicit braces to avoid dangling else",
X86FullDiagID::ParseAmbiguousElse => "ambiguous 'else'; add explicit braces",
X86FullDiagID::ParseExpectedAsm => "expected assembly string",
X86FullDiagID::ParseInvalidAsm => "invalid inline assembly statement",
X86FullDiagID::ParseExpectedAttribute => "expected attribute",
X86FullDiagID::ParseVexingParse => "parentheses were disambiguated as a function declaration",
X86FullDiagID::ParseMostVexingParse => "this is most likely a function declaration, not a variable definition",
X86FullDiagID::ParseFunctionDefNoPrototype => "function definition is not a prototype",
X86FullDiagID::ParseKandRParameters => "K&R-style function parameters are deprecated",
X86FullDiagID::ParseOldStyleDefinition => "old-style function definition",
X86FullDiagID::ParseNestedFunction => "function definition is not allowed here",
X86FullDiagID::ParseGNUStatementExpression => "use of GNU statement expression extension",
X86FullDiagID::ParseGNULocalLabel => "use of GNU local label extension",
X86FullDiagID::ParseGNUConditionalOmittedOperand => "use of GNU ?: conditional expression extension",
X86FullDiagID::ParseGNUDesignator => "use of GNU designated initializer syntax",
X86FullDiagID::ParseGNUAttribute => "use of GNU __attribute__ extension",
X86FullDiagID::ParseDeclspecAttribute => "use of Microsoft __declspec extension",
X86FullDiagID::ParseAlignasInvalid => "_Alignas attribute is not valid here",
X86FullDiagID::ParseAlignasOnParam => "'alignas' attribute cannot be applied to a function parameter",
X86FullDiagID::ParseAlignasOnBitField => "'alignas' attribute cannot be applied to a bit-field",
X86FullDiagID::ParseAtomicQualified => "_Atomic cannot be applied to qualified type '{}'",
X86FullDiagID::ParseNoreturnOnNonFunction => "'_Noreturn' can only be applied to functions",
X86FullDiagID::ParseInlineOnMain => "'inline' is not allowed on the 'main' function",
X86FullDiagID::ParseDeprecatedMessage => "'{}' is deprecated: {}",
X86FullDiagID::ParseUnavailableMessage => "'{}' is unavailable: {}",
X86FullDiagID::ParseUnexpectedTemplateKeyword => "unexpected 'template' keyword",
X86FullDiagID::ParseExpectedTemplateArgList => "expected template argument list after 'template'",
X86FullDiagID::ParseExpectedBaseClause => "expected base class clause",
X86FullDiagID::ParseExpectedCtorInitializer => "expected constructor initializer list",
X86FullDiagID::ParseInvalidPureSpecifier => "pure specifier ('= 0') only allowed on virtual functions",
X86FullDiagID::ParseUnexpectedFriend => "'friend' used outside of class",
X86FullDiagID::ParseFriendOnLocalClass => "friends cannot be declared in a local class",
X86FullDiagID::ParseUnexpectedVirtual => "virtual outside class declaration",
X86FullDiagID::ParseVirtualInUnion => "unions cannot have virtual functions",
X86FullDiagID::ParsePureInNonVirtual => "initializer on function does not look like a pure-specifier",
X86FullDiagID::ParseFinalInWrongContext => "'final' specifier not allowed here",
X86FullDiagID::ParseOverrideOutsideClass => "'override' specifier not allowed outside a class",
X86FullDiagID::ParseExpectedLambdaBody => "expected body of lambda expression",
X86FullDiagID::ParseInvalidLambdaCapture => "invalid capture in lambda expression",
X86FullDiagID::ParseDefaultInLambda => "default capture in lambda is a C++14 extension",
X86FullDiagID::ParseMutableOnNonLambda => "'mutable' can only be used in lambda expressions",
X86FullDiagID::ParseInitCaptureBeforeCXX14 => "initialized lambda captures are a C++14 extension",
X86FullDiagID::ParseGenericLambdaBeforeCXX14 => "generic lambdas are a C++14 extension",
X86FullDiagID::ParseReturnTypeAfterLambda => "trailing return type required for lambda",
X86FullDiagID::ParseTemplateParamTooDeep => "template parameter list exceeds maximum depth",
X86FullDiagID::ParseTemplateDefaultArg => "default template arguments can only be specified on a class template",
X86FullDiagID::ParseExpectedTemplateParam => "expected template parameter",
X86FullDiagID::ParseConceptDefinition => "expected concept definition",
X86FullDiagID::ParseRequiresClause => "expected requires-clause",
X86FullDiagID::ParseRequiresExpression => "expected requires-expression",
X86FullDiagID::ParseCoroutineKeyword => "coroutine keyword requires C++20",
X86FullDiagID::ParseCoAwaitOutsideCoroutine => "'co_await' cannot be used outside a coroutine",
X86FullDiagID::ParseCoYieldOutsideCoroutine => "'co_yield' cannot be used outside a coroutine",
X86FullDiagID::ParseCoReturnOutsideCoroutine => "'co_return' cannot be used outside a coroutine",
X86FullDiagID::ParseModuleDeclaration => "expected module declaration",
X86FullDiagID::ParseModuleImport => "expected module import",
X86FullDiagID::ParseModuleExport => "expected module export",
X86FullDiagID::ParseExpectedModuleName => "expected module name",
X86FullDiagID::SemaTypeCheckingError => "type mismatch: expected '{}' but got '{}'",
X86FullDiagID::SemaConversionError => "cannot convert '{}' to '{}' without a conversion operator",
X86FullDiagID::SemaOverflow => "overflow in expression; result is {} with type '{}'",
X86FullDiagID::SemaDivisionByZero => "division by zero is undefined",
X86FullDiagID::SemaIncompatiblePointerTypes => "incompatible pointer types passing '{}' to parameter of type '{}'",
X86FullDiagID::SemaAssignmentIncompatible => "assigning to '{}' from incompatible type '{}'",
X86FullDiagID::SemaPassingArgumentIncompatible => "passing '{}' to parameter of incompatible type '{}'",
X86FullDiagID::SemaReturnIncompatible => "returning '{}' from a function with incompatible result type '{}'",
X86FullDiagID::SemaVoidFuncReturningValue => "void function '{}' should not return a value",
X86FullDiagID::SemaNonVoidMissingReturn => "non-void function does not return a value in all control paths",
X86FullDiagID::SemaUnreachableCode => "code will never be executed",
X86FullDiagID::SemaUnusedVariable => "unused variable '{}'",
X86FullDiagID::SemaUnusedParameter => "unused parameter '{}'",
X86FullDiagID::SemaUnusedFunction => "unused function '{}'",
X86FullDiagID::SemaUninitializedVariable => "variable '{}' is uninitialized when used here",
X86FullDiagID::SemaPotentiallyUninitialized => "variable '{}' may be uninitialized when used here",
X86FullDiagID::SemaVLANegativeSize => "variable length array size evaluates to non-positive value {}",
X86FullDiagID::SemaVLANonPositiveSize => "variable length array with non-positive size",
X86FullDiagID::SemaArraySizeTooLarge => "array is too large ({} elements)",
X86FullDiagID::SemaNegativeArraySize => "array size is negative",
X86FullDiagID::SemaZeroSizeArray => "zero-size array is an extension",
X86FullDiagID::SemaFlexibleArrayMember => "flexible array member '{}' in otherwise empty struct",
X86FullDiagID::SemaFlexibleArrayInUnion => "flexible array member '{}' not allowed in union",
X86FullDiagID::SemaFlexibleArrayNotAtEnd => "flexible array member '{}' must be last member of struct",
X86FullDiagID::SemaFieldTypeIncomplete => "field has incomplete type '{}'",
X86FullDiagID::SemaBitFieldWidth => "bit-field '{}' width not an integer constant",
X86FullDiagID::SemaBitFieldWidthNegative => "bit-field '{}' cannot have negative width",
X86FullDiagID::SemaBitFieldWidthZero => "named bit-field '{}' has zero width",
X86FullDiagID::SemaEnumValueOverflow => "enumerator value is not representable in the underlying type",
X86FullDiagID::SemaEnumForwardDeclaration => "ISO C forbids forward references to 'enum' types",
X86FullDiagID::SemaEnumScopedFixed => "scoped enumeration requires a fixed underlying type",
X86FullDiagID::SemaDuplicateMember => "duplicate member '{}'",
X86FullDiagID::SemaDuplicateEnumValue => "duplicate enumerator value",
X86FullDiagID::SemaDuplicateCase => "duplicate case value '{}'",
X86FullDiagID::SemaDuplicateDefault => "multiple default labels in one switch",
X86FullDiagID::SemaMultipleDefault => "switch statement has multiple default labels",
X86FullDiagID::SemaCaseValueNotConst => "case value is not a constant expression",
X86FullDiagID::SemaCaseOutOfRange => "case value {} is out of range for switch condition type",
X86FullDiagID::SemaSwitchCondition => "statement requires expression of integer type ('{}' invalid)",
X86FullDiagID::SemaBreakNotInLoop => "'break' statement not in loop or switch statement",
X86FullDiagID::SemaContinueNotInLoop => "'continue' statement not in loop statement",
X86FullDiagID::SemaLRValueMismatch => "expression is not assignable",
X86FullDiagID::SemaConstQualified => "cannot assign to variable '{}' with const-qualified type '{}'",
X86FullDiagID::SemaVolatileQualified => "read of volatile-qualified variable may have side effects",
X86FullDiagID::SemaRestrictQualified => "'restrict' qualified parameter '{}' may overlap",
X86FullDiagID::SemaAtomicMismatch => "cannot mix atomic and non-atomic operands",
X86FullDiagID::SemaSizeofIncomplete => "invalid application of 'sizeof' to an incomplete type '{}'",
X86FullDiagID::SemaAlignofIncomplete => "invalid application of 'alignof' to an incomplete type '{}'",
X86FullDiagID::SemaSizeofFunction => "invalid application of 'sizeof' to a function type",
X86FullDiagID::SemaSizeofVoid => "invalid application of 'sizeof' to a void type",
X86FullDiagID::SemaSizeofBitField => "invalid application of 'sizeof' to a bit-field",
X86FullDiagID::SemaAlignofBitField => "invalid application of 'alignof' to a bit-field",
X86FullDiagID::SemaInvalidOperands => "invalid operands to binary expression ('{}' and '{}')",
X86FullDiagID::SemaInvalidUnaryOp => "invalid argument type '{}' to unary expression",
X86FullDiagID::SemaInvalidBinaryOp => "invalid operands to binary expression ('{}' and '{}')",
X86FullDiagID::SemaInvalidTernaryOp => "incompatible operand types ('{}' and '{}')",
X86FullDiagID::SemaInvalidCastType => "cannot cast from '{}' to '{}'",
X86FullDiagID::SemaConstCast => "const_cast from '{}' to '{}' is not allowed",
X86FullDiagID::SemaStaticCast => "static_cast from '{}' to '{}' is not allowed",
X86FullDiagID::SemaReinterpretCast => "reinterpret_cast from '{}' to '{}' is not allowed",
X86FullDiagID::SemaDynamicCast => "dynamic_cast from '{}' to '{}' is not allowed",
X86FullDiagID::SemaBadConstCast => "'const_cast' cannot cast away non-const/volatile qualifiers",
X86FullDiagID::SemaBadStaticCast => "'static_cast' not allowed for downcast from '{}'",
X86FullDiagID::SemaBadReinterpretCast => "'reinterpret_cast' from '{}' to '{}' casts away qualifiers",
X86FullDiagID::SemaBadDynamicCast => "'{}' is not a reference or pointer",
X86FullDiagID::SemaInvalidLValue => "expression is not assignable",
X86FullDiagID::SemaNotModifiableLValue => "expression is not a modifiable lvalue",
X86FullDiagID::SemaAddressOfRegister => "address of register variable requested",
X86FullDiagID::SemaAddressOfBitField => "address of bit-field requested",
X86FullDiagID::SemaAddressOfTemporary => "taking the address of a temporary object of type '{}'",
X86FullDiagID::SemaAddressOfLabel => "taking the address of a label is a GNU extension",
X86FullDiagID::SemaIndirectionOnNonPointer => "indirection requires pointer operand ('{}' invalid)",
X86FullDiagID::SemaSubscriptNonArray => "subscripted value is not an array, pointer, or vector",
X86FullDiagID::SemaSubscriptNonInteger => "array subscript is not an integer",
X86FullDiagID::SemaMemberAccessNonStruct => "member reference base type '{}' is not a structure or union",
X86FullDiagID::SemaCallNonFunction => "called object type '{}' is not a function or function pointer",
X86FullDiagID::SemaCallNonCallable => "called object is not a function or function pointer",
X86FullDiagID::SemaTooManyArgs => "too many arguments to function call, expected {}, have {}",
X86FullDiagID::SemaTooFewArgs => "too few arguments to function call, expected {}, have {}",
X86FullDiagID::SemaVoidArgInNonPrototype => "passing 'void' to parameter of non-prototype function",
X86FullDiagID::SemaDefaultArgMismatch => "default argument mismatch in declaration of '{}'",
X86FullDiagID::SemaDefaultArgRedefined => "redefinition of default argument",
X86FullDiagID::SemaDefaultArgOnParamPack => "default argument not permitted on a parameter pack",
X86FullDiagID::SemaLocalDeclNoLinkage => "unused function '{}'",
X86FullDiagID::SemaStaticInInline => "variable is static but used in inline function which is not static",
X86FullDiagID::SemaExternInitializer => "'extern' variable has an initializer",
X86FullDiagID::SemaRedefinitionOfTypedef => "redefinition of '{}' as different kind of symbol",
X86FullDiagID::SemaRedefinitionOfLabel => "redefinition of label '{}'",
X86FullDiagID::SemaConflictingFunctionTypes => "conflicting types for '{}'",
X86FullDiagID::SemaIncompatibleFunctionDecl => "incompatible function declaration for '{}'",
X86FullDiagID::SemaDuplicateAttribute => "duplicate attribute '{}'",
X86FullDiagID::SemaAttributeIgnored => "attribute '{}' ignored",
X86FullDiagID::SemaUnknownAttribute => "unknown attribute '{}' ignored",
X86FullDiagID::SemaGNUAttributeIgnored => "GNU attribute '{}' ignored",
X86FullDiagID::SemaGCCExtension => "GCC extension used",
X86FullDiagID::SemaMSVCCompatibility => "Microsoft compatibility extension used",
X86FullDiagID::SemaReturnStackAddress => "returning address of local variable or temporary",
X86FullDiagID::SemaReturnLocalAddress => "address of stack memory associated with local variable returned",
X86FullDiagID::SemaDanglingReference => "binding reference to a temporary whose lifetime has ended",
X86FullDiagID::SemaDanglingPointer => "dangling pointer to temporary",
X86FullDiagID::SemaDeallocMismatch => "allocation/deallocation type mismatch",
X86FullDiagID::SemaDoubleFree => "attempt to free memory that has already been freed",
X86FullDiagID::SemaUseAfterFree => "use of memory after it is freed",
X86FullDiagID::SemaStackBufferOverflow => "stack buffer overflow",
X86FullDiagID::SemaHeapBufferOverflow => "heap buffer overflow",
X86FullDiagID::SemaSignedOverflow => "signed integer overflow in expression",
X86FullDiagID::SemaUnsignedOverflow => "unsigned integer overflow wraps around",
X86FullDiagID::SemaFloatOverflow => "magnitude of floating-point constant too large for type",
X86FullDiagID::SemaFloatToIntOverflow => "implicit conversion from '{}' to '{}' changes value",
X86FullDiagID::SemaIntToFloatPrecisionLoss => "implicit conversion from '{}' to '{}' may lose precision",
X86FullDiagID::SemaDivisionByZeroRuntime => "division by zero is undefined",
X86FullDiagID::SemaModuloByZero => "remainder by zero in constant expression",
X86FullDiagID::SemaShiftByNegative => "shift count is negative",
X86FullDiagID::SemaShiftExceedsWidth => "shift count >= width of type",
X86FullDiagID::SemaNullDereference => "null pointer dereference",
X86FullDiagID::SemaNonNullParamNull => "null passed to a callee that requires a non-null argument",
X86FullDiagID::SemaNullPassedToNonNull => "null pointer passed to function expecting non-null",
X86FullDiagID::SemaAlignmentMismatch => "alignment requirement mismatch",
X86FullDiagID::SemaCastAlignDown => "cast from '{}' to '{}' decreases required alignment",
X86FullDiagID::SemaCastAlignUp => "cast from '{}' to '{}' increases required alignment",
X86FullDiagID::SemaStrictAliasingViolation => "dereferencing type-punned pointer will break strict-aliasing rules",
X86FullDiagID::SemaTypePunningViaUnion => "accessing union member '{}' while another member is active",
X86FullDiagID::SemaTypePunningViaCast => "type-punning via cast",
X86FullDiagID::SemaUninitializedRead => "variable is uninitialized when used here",
X86FullDiagID::SemaStackProtectorFailure => "stack-protector: variable length buffer overflow detected",
X86FullDiagID::SemaInvalidBuiltin => "invalid builtin function '{}'",
X86FullDiagID::SemaDeprecatedDecl => "'{}' is deprecated",
X86FullDiagID::SemaUnavailableDecl => "'{}' is unavailable",
X86FullDiagID::SemaDeprecatedAttribute => "'{}' has been explicitly marked deprecated here",
X86FullDiagID::SemaUnavailableAttribute => "'{}' has been explicitly marked unavailable here",
X86FullDiagID::SemaDeprecatedWithMessage => "'{}' is deprecated: {}",
X86FullDiagID::SemaUnavailableWithMessage => "'{}' is unavailable: {}",
X86FullDiagID::SemaDeprecatedEnumerator => "enumerator '{}' is deprecated",
X86FullDiagID::SemaDeprecatedTypedef => "typedef '{}' is deprecated",
X86FullDiagID::SemaRemovedFeature => "'{}' has been removed from the language",
X86FullDiagID::CXXAccessControlPrivate => "'{}' is a private member of '{}'",
X86FullDiagID::CXXAccessControlProtected => "'{}' is a protected member of '{}'",
X86FullDiagID::CXXAccessControlPublic => "declared public here",
X86FullDiagID::CXXAccessControlInaccessible => "'{}' is inaccessible within this context",
X86FullDiagID::CXXAccessControlInaccessibleBase => "base class '{}' is inaccessible",
X86FullDiagID::CXXVirtualOverrideMismatch => "'{}' overrides a member function but is not marked 'override'",
X86FullDiagID::CXXMissingOverride => "'{}' overrides a member function but is not marked 'override'",
X86FullDiagID::CXXOverrideMismatch => "'{}' marked 'override' but does not override any member function",
X86FullDiagID::CXXFinalOverride => "declaration of '{}' overrides a 'final' function",
X86FullDiagID::CXXFinalClassOverride => "cannot override '{}' in 'final' class '{}'",
X86FullDiagID::CXXPureVirtualCall => "call to pure virtual member function '{}'",
X86FullDiagID::CXXPureVirtualInCtorDtor => "call to pure virtual member function '{}' during construction/destruction",
X86FullDiagID::CXXAbstractClass => "cannot instantiate abstract class '{}'",
X86FullDiagID::CXXAbstractClassDeclaration => "abstract class '{}' cannot be instantiated",
X86FullDiagID::CXXAbstractReturnType => "abstract class '{}' cannot be used as function return type",
X86FullDiagID::CXXAbstractParameterType => "abstract class '{}' cannot be used as function parameter type",
X86FullDiagID::CXXDeletedFunction => "call to deleted function '{}'",
X86FullDiagID::CXXDeletedDefault => "explicitly defaulted function '{}' is implicitly deleted",
X86FullDiagID::CXXDeletedCopy => "call to implicitly-deleted copy constructor of '{}'",
X86FullDiagID::CXXDeletedMove => "call to implicitly-deleted move constructor of '{}'",
X86FullDiagID::CXXDeletedDestructor => "attempt to use a deleted destructor",
X86FullDiagID::CXXExplicitConversion => "explicit conversion function is not a candidate",
X86FullDiagID::CXXExplicitConstructor => "chosen constructor is explicit in copy-initialization",
X86FullDiagID::CXXExplicitBoolConversion => "explicit(bool) requires C++20",
X86FullDiagID::CXXConstexprNonConst => "'constexpr' non-static member function will not be implicitly 'const'",
X86FullDiagID::CXXConstexprNoReturn => "'constexpr' function never produces a constant expression",
X86FullDiagID::CXXConstexprNeverConstant => "'constexpr' function never produces a constant expression",
X86FullDiagID::CXXConstexprVirtual => "'constexpr' virtual function is a C++20 extension",
X86FullDiagID::CXXConstexprTryCatch => "'constexpr' function with try-catch is a C++20 extension",
X86FullDiagID::CXXConstexprAllocation => "'constexpr' allocation is a C++20 extension",
X86FullDiagID::CXXConstexprDeallocation => "'constexpr' deallocation is a C++20 extension",
X86FullDiagID::CXXConstexprDynamicCast => "'constexpr' dynamic_cast is a C++20 extension",
X86FullDiagID::CXXConstexprReinterpretCast => "'constexpr' reinterpret_cast is not allowed",
X86FullDiagID::CXXConstexprUnionActiveMember => "change of active union member in constexpr",
X86FullDiagID::CXXNoexceptMismatch => "exception specification of overriding function is more lax than base version",
X86FullDiagID::CXXNoexceptFunctionType => "noexcept cannot be applied to function type",
X86FullDiagID::CXXNoexceptFalse => "noexcept-expression evaluates to 'false'",
X86FullDiagID::CXXNoexceptOverrideNarrower => "exception specification of '{}' is narrower than that of base '{}'",
X86FullDiagID::CXXNoexceptOverrideWider => "exception specification of '{}' is wider than that of base '{}'",
X86FullDiagID::CXXTemplateArgDeductionFailed => "template argument deduction failed for '{}'",
X86FullDiagID::CXXTemplateAmbiguous => "template argument '{}' is ambiguous",
X86FullDiagID::CXXTemplateRecursion => "recursive template instantiation exceeded maximum depth of {}",
X86FullDiagID::CXXTemplateExplicitInstantiation => "explicit instantiation of '{}' does not match any declaration",
X86FullDiagID::CXXTemplateExplicitSpecialization => "explicit specialization of '{}' outside namespace scope",
X86FullDiagID::CXXTemplatePartialSpecialization => "partial specialization cannot be declared here",
X86FullDiagID::CXXTemplateDefaultArgInvalid => "default template argument in a function template is a C++11 extension",
X86FullDiagID::CXXTemplateNonTypeParamInvalid => "non-type template parameter '{}' has invalid type",
X86FullDiagID::CXXTemplateTypeParamInvalid => "type template parameter '{}' is not valid here",
X86FullDiagID::CXXTemplateTemplateParamInvalid => "template template parameter '{}' is not valid here",
X86FullDiagID::CXXTemplateVariadicParam => "variadic template parameter must be last in the parameter list",
X86FullDiagID::CXXTemplateParameterPack => "parameter pack '{}' must be at the end of the template parameter list",
X86FullDiagID::CXXTemplateArgPackExpansion => "pack expansion does not contain any unexpanded parameter packs",
X86FullDiagID::CXXDependentNameMissingTypename => "missing 'typename' prior to dependent type name '{}'",
X86FullDiagID::CXXDependentNameInvalidTypename => "typename specifier used on a non-type '{}'",
X86FullDiagID::CXXTwoPhaseLookup => "use of undeclared identifier in dependent context",
X86FullDiagID::CXXTwoPhaseLookupDependent => "dependent name lookup finds declaration at instantiation time",
X86FullDiagID::CXXTwoPhaseLookupTwoLevel => "two-phase name lookup is not enabled",
X86FullDiagID::CXXSFINAEContext => "substitution failure is not an error in this context",
X86FullDiagID::CXXSFINAEDeductionFailed => "template argument deduction/substitution failed",
X86FullDiagID::CXXOverloadAmbiguity => "call to '{}' is ambiguous",
X86FullDiagID::CXXOverloadAmbiguousConversion => "ambiguous conversion for '{}'",
X86FullDiagID::CXXOverloadAmbiguousConstructor => "call to constructor of '{}' is ambiguous",
X86FullDiagID::CXXOverloadNoViable => "no viable conversion from '{}' to '{}'",
X86FullDiagID::CXXOverloadNoViableConversion => "no viable overloaded '{}'",
X86FullDiagID::CXXOverloadDeletedFunction => "call to deleted function '{}'",
X86FullDiagID::CXXOverloadInaccessibleFunction => "calling '{}' is inaccessible",
X86FullDiagID::CXXOverloadTemplateDeduction => "template argument deduction/substitution failed",
X86FullDiagID::CXXOverloadCandidateNotViable => "candidate function not viable",
X86FullDiagID::CXXDestructorProtected => "destructor is protected and cannot be called",
X86FullDiagID::CXXDestructorPrivate => "destructor is private and cannot be called",
X86FullDiagID::CXXDestructorDeleted => "destructor is explicitly deleted",
X86FullDiagID::CXXDestructorVirtualBase => "destructor of virtual base class '{}' is not virtual",
X86FullDiagID::CXXDestructorAbstractBase => "base class '{}' has no virtual destructor",
X86FullDiagID::CXXCopyCtorDeleted => "copy constructor is implicitly deleted because '{}' has a user-declared move constructor",
X86FullDiagID::CXXCopyCtorImplicitlyDeleted => "copy constructor of '{}' is implicitly deleted",
X86FullDiagID::CXXCopyCtorNonTrivial => "copy constructor is not trivial",
X86FullDiagID::CXXCopyCtorTrivialABI => "copy constructor is trivial for ABI but not for the language",
X86FullDiagID::CXXMoveCtorDeleted => "move constructor is implicitly deleted",
X86FullDiagID::CXXMoveCtorNotUsed => "moving a local object in a return statement prevents copy elision",
X86FullDiagID::CXXMoveCtorElision => "moving a temporary object prevents copy elision",
X86FullDiagID::CXXCopyAssignmentDeleted => "copy assignment operator is implicitly deleted",
X86FullDiagID::CXXMoveAssignmentDeleted => "move assignment operator is implicitly deleted",
X86FullDiagID::CXXDefaultedDeleted => "defaulted function is implicitly deleted",
X86FullDiagID::CXXDefaultedSpecialMember => "explicitly defaulted special member function is implicitly deleted",
X86FullDiagID::CXXExplicitlyDefaulted => "explicitly defaulted function cannot be defined here",
X86FullDiagID::CXXExplicitlyDeleted => "function cannot be deleted here",
X86FullDiagID::CXXFriendNotFirst => "'friend' must be first declaration in class",
X86FullDiagID::CXXFriendRedefinition => "friend function '{}' is a redefinition",
X86FullDiagID::CXXFriendInLocalClass => "friend declaration in local class",
X86FullDiagID::CXXNamespaceAlias => "namespace alias defined here",
X86FullDiagID::CXXUsingDeclaration => "using declaration refers to '{}'",
X86FullDiagID::CXXUsingDirective => "using directive refers to namespace '{}'",
X86FullDiagID::CXXUsingShadow => "using declaration '{}' hides previous declaration",
X86FullDiagID::CXXUsingAmbiguous => "using declaration is ambiguous",
X86FullDiagID::CXXAnonymousStruct => "anonymous struct declared here",
X86FullDiagID::CXXAnonymousUnionMember => "anonymous union member of type '{}'",
X86FullDiagID::CXXLambdaCaptureDefault => "default capture in lambda expression",
X86FullDiagID::CXXLambdaCaptureExplicit => "this variable cannot be implicitly captured in a lambda",
X86FullDiagID::CXXLambdaCaptureThis => "'this' cannot be implicitly captured in this context",
X86FullDiagID::CXXLambdaCaptureByReference => "'{}' cannot be captured by reference",
X86FullDiagID::CXXLambdaCaptureByValue => "'{}' cannot be captured by value",
X86FullDiagID::CXXLambdaCaptureInit => "initialized capture in lambda is a C++14 extension",
X86FullDiagID::CXXLambdaGeneric => "generic lambda expression is a C++14 extension",
X86FullDiagID::CXXLambdaConstexpr => "'constexpr' lambda is a C++17 extension",
X86FullDiagID::CXXLambdaMutable => "'mutable' lambda requires capture-default",
X86FullDiagID::CXXLambdaDefaultArg => "lambda cannot have default arguments",
X86FullDiagID::CXXLambdaTemplate => "lambda template is a C++20 extension",
X86FullDiagID::CXXLambdaInUnevaluated => "lambda in unevaluated context is a C++20 extension",
X86FullDiagID::CXXLambdaStaticInvoker => "lambda with static invoker is a C++23 extension",
X86FullDiagID::CXXCoroutineReturnType => "coroutine return type must be a class or enumeration",
X86FullDiagID::CXXCoroutinePromiseType => "coroutine must have a promise type",
X86FullDiagID::CXXCoroutineAwaitable => "expression must be awaitable",
X86FullDiagID::CXXCoroutineSymmetricTransfer => "coroutine uses symmetric transfer",
X86FullDiagID::CXXCoroutineFrameAllocation => "coroutine frame allocation",
X86FullDiagID::CXXCoroutineNoElision => "coroutine frame was not elided",
X86FullDiagID::CXXCoroutineHeapAlloc => "coroutine frame allocated on heap",
X86FullDiagID::CXXCoroutineHeapDealloc => "coroutine frame deallocated",
X86FullDiagID::CXXConceptDefinition => "concept definition requires C++20",
X86FullDiagID::CXXConceptConstraint => "constraint was not satisfied",
X86FullDiagID::CXXConceptSatisfaction => "concept '{}' was not satisfied",
X86FullDiagID::CXXConceptAtomic => "atomic constraint evaluation",
X86FullDiagID::CXXConceptRequires => "requires-clause evaluated to false",
X86FullDiagID::CXXConceptNestedRequirement => "nested requirement failed",
X86FullDiagID::CXXConceptTypeRequirement => "type requirement failed",
X86FullDiagID::CXXConceptCompoundRequirement => "compound requirement failed",
X86FullDiagID::CXXConceptExpressionRequirement => "expression requirement failed",
X86FullDiagID::CXXConceptPartialOrdering => "concept partial ordering",
X86FullDiagID::CXXConceptSubsumption => "constraint subsumption",
X86FullDiagID::CXXConceptDefaultConstraint => "constraint not satisfied for default template argument",
X86FullDiagID::CXXModuleInterface => "module interface unit requires C++20",
X86FullDiagID::CXXModuleImplementation => "module implementation unit",
X86FullDiagID::CXXModulePartition => "module partition requires C++20",
X86FullDiagID::CXXModuleImport => "module import",
X86FullDiagID::CXXModuleExport => "module export",
X86FullDiagID::CXXModuleOwnership => "module ownership",
X86FullDiagID::CXXModuleLinkage => "module linkage",
X86FullDiagID::CXXModuleVisibility => "module visibility",
X86FullDiagID::CXXModuleReachability => "module reachability",
X86FullDiagID::CXXModuleAttainment => "module attainment",
X86FullDiagID::CXXModuleGlobalFragment => "global module fragment",
X86FullDiagID::CXXModulePrivateFragment => "private module fragment",
X86FullDiagID::CXXModuleHeaderUnit => "header unit import",
X86FullDiagID::CXXModuleBMI => "built module interface",
X86FullDiagID::CXXThreeWayComparison => "three-way comparison requires C++20",
X86FullDiagID::CXXSpaceshipAuto => "'operator<=>' cannot be auto-generated",
X86FullDiagID::CXXSpaceshipReturnType => "return type of 'operator<=>' must be a comparison category type",
X86FullDiagID::CXXDefaultedComparison => "defaulted comparison operator is deleted",
X86FullDiagID::CXXWeakEquality => "'std::weak_equality' is deprecated in C++20",
X86FullDiagID::CXXStrongEquality => "'std::strong_equality' is deprecated in C++20",
X86FullDiagID::CXXWeakOrdering => "'std::weak_ordering' comparison category",
X86FullDiagID::CXXPartialOrdering => "'std::partial_ordering' comparison category",
X86FullDiagID::CXXStrongOrdering => "'std::strong_ordering' comparison category",
X86FullDiagID::CXXDesignatedInit => "designated initializer is a C++20 extension",
X86FullDiagID::CXXDesignatedInitMixed => "mixture of designated and non-designated initializers",
X86FullDiagID::CXXDesignatedInitOutOfOrder => "designated initializer order does not match declaration order",
X86FullDiagID::CXXDesignatedInitNested => "nested designated initializer",
X86FullDiagID::CXXDesignatedInitOverride => "designated initializer overrides previous initialization",
X86FullDiagID::CXXDesignatedInitArray => "designated initializer for array element",
X86FullDiagID::CXXRangeBasedFor => "range-based 'for' loop requires C++11",
X86FullDiagID::CXXRangeBasedForBeginEnd => "'begin'/'end' functions required for range-based 'for'",
X86FullDiagID::CXXRangeBasedForADL => "calling begin/end via argument-dependent lookup",
X86FullDiagID::CXXStructuredBinding => "structured binding declaration is a C++17 extension",
X86FullDiagID::CXXStructuredBindingTuple => "cannot decompose non-tuple type '{}'",
X86FullDiagID::CXXStructuredBindingArray => "cannot decompose array of unknown bound",
X86FullDiagID::CXXStructuredBindingMember => "cannot decompose class type '{}' without public members",
X86FullDiagID::CXXInitStatement => "init-statement is a C++17 extension",
X86FullDiagID::CXXIfInit => "init-statement in 'if' is a C++17 extension",
X86FullDiagID::CXXSwitchInit => "init-statement in 'switch' is a C++17 extension",
X86FullDiagID::CXXRangeForInit => "init-statement in range-for is a C++20 extension",
X86FullDiagID::CXXCTAD => "class template argument deduction requires C++17",
X86FullDiagID::CXXCTADGuide => "deduction guide for '{}'",
X86FullDiagID::CXXCTADAggregate => "aggregate class template argument deduction",
X86FullDiagID::CXXCTADExplicit => "explicit deduction guide",
X86FullDiagID::CXXCTADDeductionFailed => "class template argument deduction failed",
X86FullDiagID::CXXAggregateInit => "aggregate initialization uses parentheses",
X86FullDiagID::CXXAggregateParenInit => "aggregate initialization with parentheses is a C++20 extension",
X86FullDiagID::CXXTrivialABI => "'trivial_abi' attribute cannot be applied",
X86FullDiagID::CXXTrivialDestructor => "destructor is non-trivial",
X86FullDiagID::CXXTrivialCopy => "copy constructor is non-trivial",
X86FullDiagID::CXXNoUniqueAddress => "'[[no_unique_address]]' is a C++20 extension",
X86FullDiagID::CXXLikely => "'[[likely]]' attribute",
X86FullDiagID::CXXUnlikely => "'[[unlikely]]' attribute",
X86FullDiagID::CXXAssume => "'[[assume]]' attribute is a C++23 extension",
X86FullDiagID::CXXDefaultMemberInit => "default member initializer for non-static data member",
X86FullDiagID::CXXDefaultMemberInitBitField => "default member initializer on bit-field is a C++20 extension",
X86FullDiagID::CXXNSDMI => "non-static data member initializer",
X86FullDiagID::CXXInheritingConstructor => "inheriting constructor is a C++11 extension",
X86FullDiagID::CXXInheritingConstructorConflict => "inheriting constructor conflicts with other constructors",
X86FullDiagID::CXXVariadicUsing => "variadic using declaration is a C++17 extension",
X86FullDiagID::CXXPackExpansion => "pack expansion contains parameter packs",
X86FullDiagID::CXXFoldExpression => "fold expression is a C++17 extension",
X86FullDiagID::CXXFoldUnaryLeft => "unary left fold",
X86FullDiagID::CXXFoldUnaryRight => "unary right fold",
X86FullDiagID::CXXFoldBinaryLeft => "binary left fold",
X86FullDiagID::CXXFoldBinaryRight => "binary right fold",
X86FullDiagID::CXXEmptyFold => "empty pack expansion in fold expression",
X86FullDiagID::X86FeatureSSE => "SSE vector type requires SSE feature, which is not enabled",
X86FullDiagID::X86FeatureSSE2 => "SSE2 vector type requires SSE2 feature, which is not enabled",
X86FullDiagID::X86FeatureSSE3 => "SSE3 operation requires SSE3 feature, which is not enabled",
X86FullDiagID::X86FeatureSSSE3 => "SSSE3 operation requires SSSE3 feature, which is not enabled",
X86FullDiagID::X86FeatureSSE41 => "SSE4.1 operation requires SSE4.1 feature, which is not enabled",
X86FullDiagID::X86FeatureSSE42 => "SSE4.2 operation requires SSE4.2 feature, which is not enabled",
X86FullDiagID::X86FeatureAVX => "AVX vector type requires AVX feature, which is not enabled",
X86FullDiagID::X86FeatureAVX2 => "AVX2 operation requires AVX2 feature, which is not enabled",
X86FullDiagID::X86FeatureAVX512F => "AVX-512 operation requires AVX-512F feature, which is not enabled",
X86FullDiagID::X86FeatureAVX512BW => "AVX-512BW operation requires AVX-512BW feature",
X86FullDiagID::X86FeatureAVX512DQ => "AVX-512DQ operation requires AVX-512DQ feature",
X86FullDiagID::X86FeatureAVX512VL => "AVX-512VL operation requires AVX-512VL feature",
X86FullDiagID::X86FeatureAVX512CD => "AVX-512CD operation requires AVX-512CD feature",
X86FullDiagID::X86FeatureAVX512ER => "AVX-512ER operation requires AVX-512ER feature",
X86FullDiagID::X86FeatureAVX512PF => "AVX-512PF operation requires AVX-512PF feature",
X86FullDiagID::X86FeatureAVX512BF16 => "AVX-512 BF16 operation requires AVX-512BF16 feature",
X86FullDiagID::X86FeatureAVX512FP16 => "AVX-512 FP16 operation requires AVX-512FP16 feature",
X86FullDiagID::X86FeatureAVX512VBMI => "AVX-512 VBMI operation requires AVX-512VBMI feature",
X86FullDiagID::X86FeatureAVX512VBMI2 => "AVX-512 VBMI2 operation requires AVX-512VBMI2 feature",
X86FullDiagID::X86FeatureAVX512VNNI => "AVX-512 VNNI operation requires AVX-512VNNI feature",
X86FullDiagID::X86FeatureAVX512BITALG => "AVX-512 BITALG operation requires AVX-512BITALG feature",
X86FullDiagID::X86FeatureAVX512VPOPCNTDQ => "AVX-512 VPOPCNTDQ operation requires AVX-512VPOPCNTDQ feature",
X86FullDiagID::X86FeatureAVX5124FMAPS => "AVX-512 4FMAPS operation requires AVX-5124FMAPS feature",
X86FullDiagID::X86FeatureAVX5124VNNIW => "AVX-512 4VNNIW operation requires AVX-5124VNNIW feature",
X86FullDiagID::X86FeatureAVX512VP2INTERSECT => "AVX-512 VP2INTERSECT operation requires AVX-512VP2INTERSECT feature",
X86FullDiagID::X86FeatureAVX512IFMA => "AVX-512 IFMA operation requires AVX-512IFMA feature",
X86FullDiagID::X86FeatureAVX512FP16Conv => "AVX-512 FP16 conversion requires AVX-512FP16 feature",
X86FullDiagID::X86FeatureAVX10_1_256 => "AVX10.1/256 operation requires AVX10.1-256 feature",
X86FullDiagID::X86FeatureAVX10_1_512 => "AVX10.1/512 operation requires AVX10.1-512 feature",
X86FullDiagID::X86FeatureAVX10_2 => "AVX10.2 operation requires AVX10.2 feature",
X86FullDiagID::X86FeatureFMA => "FMA operation requires FMA feature, which is not enabled",
X86FullDiagID::X86FeatureFMA4 => "FMA4 operation requires FMA4 feature, which is not enabled",
X86FullDiagID::X86FeatureF16C => "F16C conversion requires F16C feature, which is not enabled",
X86FullDiagID::X86FeatureMMX => "MMX vector type requires MMX feature, which is not enabled",
X86FullDiagID::X86FeatureSSE4a => "SSE4a operation requires SSE4a feature, which is not enabled",
X86FullDiagID::X86FeatureXOP => "XOP operation requires XOP feature, which is not enabled",
X86FullDiagID::X86Feature3DNOW => "3DNow! operation requires 3DNow! feature, which is not enabled",
X86FullDiagID::X86Feature3DNOWA => "3DNow!A operation requires 3DNow!A feature, which is not enabled",
X86FullDiagID::X86FeatureBMI => "BMI operation requires BMI feature, which is not enabled",
X86FullDiagID::X86FeatureBMI2 => "BMI2 operation requires BMI2 feature, which is not enabled",
X86FullDiagID::X86FeatureLZCNT => "LZCNT operation requires LZCNT feature",
X86FullDiagID::X86FeaturePOPCNT => "POPCNT operation requires POPCNT feature",
X86FullDiagID::X86FeatureTBM => "TBM operation requires TBM feature",
X86FullDiagID::X86FeatureAES => "AES operation requires AES feature, which is not enabled",
X86FullDiagID::X86FeaturePCLMUL => "PCLMUL operation requires PCLMUL feature, which is not enabled",
X86FullDiagID::X86FeatureSHA => "SHA operation requires SHA feature, which is not enabled",
X86FullDiagID::X86FeatureSHA512 => "SHA512 operation requires SHA512 feature",
X86FullDiagID::X86FeatureSM3 => "SM3 operation requires SM3 feature",
X86FullDiagID::X86FeatureSM4 => "SM4 operation requires SM4 feature",
X86FullDiagID::X86FeatureGFNI => "GFNI operation requires GFNI feature",
X86FullDiagID::X86FeatureVAES => "VAES operation requires VAES feature",
X86FullDiagID::X86FeatureVPCLMULQDQ => "VPCLMULQDQ operation requires VPCLMULQDQ feature",
X86FullDiagID::X86FeatureRDRAND => "RDRAND operation requires RDRAND feature",
X86FullDiagID::X86FeatureRDSEED => "RDSEED operation requires RDSEED feature",
X86FullDiagID::X86FeatureADX => "ADX operation requires ADX feature",
X86FullDiagID::X86FeatureRTM => "RTM operation requires RTM feature",
X86FullDiagID::X86FeatureHLE => "HLE operation requires HLE feature",
X86FullDiagID::X86FeatureSGX => "SGX operation requires SGX feature",
X86FullDiagID::X86FeatureCET => "CET operation requires CET feature",
X86FullDiagID::X86FeatureCETSS => "CET shadow stack requires CET-SS feature",
X86FullDiagID::X86FeatureXSAVE => "XSAVE operation requires XSAVE feature",
X86FullDiagID::X86FeatureXSAVEOPT => "XSAVEOPT requires XSAVEOPT feature",
X86FullDiagID::X86FeatureXSAVEC => "XSAVEC requires XSAVEC feature",
X86FullDiagID::X86FeatureXSAVES => "XSAVES requires XSAVES feature",
X86FullDiagID::X86FeatureFSGSBASE => "FSGSBASE operation requires FSGSBASE feature",
X86FullDiagID::X86FeatureMOVBE => "MOVBE operation requires MOVBE feature",
X86FullDiagID::X86FeatureMOVDIRI => "MOVDIRI operation requires MOVDIRI feature",
X86FullDiagID::X86FeatureMOVDIR64B => "MOVDIR64B operation requires MOVDIR64B feature",
X86FullDiagID::X86FeatureENQCMD => "ENQCMD operation requires ENQCMD feature",
X86FullDiagID::X86FeatureSERIALIZE => "SERIALIZE operation requires SERIALIZE feature",
X86FullDiagID::X86FeatureTSXLDTRK => "TSXLDTRK operation requires TSXLDTRK feature",
X86FullDiagID::X86FeatureWAITPKG => "WAITPKG operation requires WAITPKG feature",
X86FullDiagID::X86FeatureCLDEMOTE => "CLDEMOTE operation requires CLDEMOTE feature",
X86FullDiagID::X86FeatureCLFLUSHOPT => "CLFLUSHOPT operation requires CLFLUSHOPT feature",
X86FullDiagID::X86FeatureCLWB => "CLWB operation requires CLWB feature",
X86FullDiagID::X86FeatureCLZERO => "CLZERO operation requires CLZERO feature",
X86FullDiagID::X86FeaturePKU => "PKU operation requires PKU feature",
X86FullDiagID::X86FeatureAMX_BF16 => "AMX-BF16 operation requires AMX-BF16 feature",
X86FullDiagID::X86FeatureAMX_INT8 => "AMX-INT8 operation requires AMX-INT8 feature",
X86FullDiagID::X86FeatureAMX_TILE => "AMX-TILE operation requires AMX-TILE feature",
X86FullDiagID::X86FeatureAMX_FP16 => "AMX-FP16 operation requires AMX-FP16 feature",
X86FullDiagID::X86FeatureAMX_COMPLEX => "AMX-COMPLEX operation requires AMX-COMPLEX feature",
X86FullDiagID::X86FeatureX87 => "x87 operation requires x87 feature, which is not enabled",
X86FullDiagID::X86FeatureCMOV => "CMOV operation requires CMOV feature",
X86FullDiagID::X86CallingConventionMismatch => "calling convention mismatch: expected '{}', have '{}'",
X86FullDiagID::X86ABIViolation => "ABI violation: argument of type '{}' cannot be passed in register",
X86FullDiagID::X86StructReturnTooLarge => "return type '{}' is too large for register return on this ABI",
X86FullDiagID::X86VectorTypeNotSupported => "vector type '{}' is not supported on the current target",
X86FullDiagID::X86IntrinsicNotAvailable => "builtin intrinsic '{}' is not available on the current target",
X86FullDiagID::X86CPUFeatureNotAvailable => "CPU feature '{}' is not available on the target processor",
X86FullDiagID::X86TargetAttributeConflict => "target attribute '{}' conflicts with command-line options",
X86FullDiagID::X86OptionArchMismatch => "'-march={}' is not compatible with target '{}'",
X86FullDiagID::X86ABIStructTooLarge => "struct is too large to be passed in registers; passed in memory",
X86FullDiagID::X86ABIHiddenPointerReturn => "return type requires hidden pointer parameter per ABI",
X86FullDiagID::X86ABIRedZoneViolation => "red zone violation: address is in the 128-byte red zone",
X86FullDiagID::X86ABIStackAlignmentViolation => "stack alignment violation: expected {} bytes, got {} bytes",
X86FullDiagID::X86ABIVectorcallAlignment => "__vectorcall requires 32-byte stack alignment",
X86FullDiagID::X86ABIFastcallTooManyArgs => "__fastcall called with too many arguments",
X86FullDiagID::X86ABIThiscallNonMember => "__thiscall applied to non-member function",
X86FullDiagID::X86ABIStdCallVarArgs => "__stdcall cannot have variable arguments",
X86FullDiagID::X86ABIRegCallNotEnoughRegs => "__regcall: not enough registers for parameters",
X86FullDiagID::X86ABISysVClassificationFailed => "SysV ABI classification failed for type '{}'",
X86FullDiagID::X86ABIMicrosoftClassificationFailed => "Microsoft ABI classification failed for type '{}'",
X86FullDiagID::X86ABIRegCallClassificationFailed => "RegCall ABI classification failed for type '{}'",
X86FullDiagID::X86ABIEmptyStructPass => "empty struct passed per ABI rules",
X86FullDiagID::X86ABIPackedStructPass => "packed struct passed in memory per ABI",
X86FullDiagID::X86ABIBitfieldStraddle => "bitfield straddles alignment boundary",
X86FullDiagID::X86ABIComplexReturn => "complex return value passed in registers per ABI",
X86FullDiagID::X86ABIX87Return => "floating-point return value uses x87 stack",
X86FullDiagID::X86InlineASMInvalidInstruction => "invalid instruction mnemonic '{}'",
X86FullDiagID::X86InlineASMInvalidConstraint => "invalid operand constraint '{}' in inline assembly",
X86FullDiagID::X86InlineASMClobberConflict => "register '{}' clobbered by inline assembly is also used as output",
X86FullDiagID::X86InlineASMTooManyOperands => "too many operands in inline assembly (max {})",
X86FullDiagID::X86InlineASMGlobalRegister => "inline assembly uses global register '{}'",
X86FullDiagID::X86VectorWidthMismatch => "vector width mismatch: expected {}, got {}",
X86FullDiagID::X86VectorShuffleInvalid => "invalid shuffle mask index {}",
X86FullDiagID::X86VectorGatherAlign => "gather operation requires aligned memory",
X86FullDiagID::X86VectorMaskMissing => "mask operand required for vector operation",
X86FullDiagID::X86AlignmentNone => "no alignment specified for type '{}'",
X86FullDiagID::X86AlignmentUnaligned => "access to unaligned memory at offset {}",
X86FullDiagID::X86RedZoneViolation => "red zone violation detected",
X86FullDiagID::X86StackSize => "stack frame size of {} bytes exceeds limit of {} bytes",
X86FullDiagID::X86NopPadding => "unnecessary NOP padding between functions",
X86FullDiagID::OptInlineRemark => "'{}' inlined into '{}'",
X86FullDiagID::OptInlineFailure => "'{}' not inlined into '{}' because {}",
X86FullDiagID::OptInlineCostTooHigh => "inlining cost of {} exceeds threshold {}",
X86FullDiagID::OptInlineNoDefinition => "function definition not available",
X86FullDiagID::OptInlineRecursive => "recursive function cannot be inlined",
X86FullDiagID::OptInlineNoInlineAttr => "function has 'noinline' attribute",
X86FullDiagID::OptInlineAlwaysInline => "function has 'always_inline' attribute",
X86FullDiagID::OptInlineNoOptimize => "function compiled without optimization",
X86FullDiagID::OptInlineOptNone => "function compiled with -O0",
X86FullDiagID::OptVectorizationRemark => "vectorized loop (vectorization width: {}, interleaved count: {})",
X86FullDiagID::OptVectorizationFailure => "loop not vectorized: {}",
X86FullDiagID::OptVectorizationUnsafeDep => "unsafe dependent memory operations",
X86FullDiagID::OptVectorizationNoAlias => "pointer alias prevents vectorization",
X86FullDiagID::OptVectorizationUnaligned => "unaligned memory access prevents vectorization",
X86FullDiagID::OptVectorizationNoReduction => "no supported reduction pattern found",
X86FullDiagID::OptVectorizationSmallTrip => "trip count too small for vectorization",
X86FullDiagID::OptVectorizationNonLinear => "non-linear induction variable prevents vectorization",
X86FullDiagID::OptVectorizationIneffective => "vectorization is not beneficial",
X86FullDiagID::OptLoopUnrollRemark => "loop unrolled with count {}",
X86FullDiagID::OptLoopUnrollFailure => "loop not unrolled: {}",
X86FullDiagID::OptLoopUnrollTooLarge => "unrolled loop too large",
X86FullDiagID::OptLoopUnrollNonConstant => "trip count not constant",
X86FullDiagID::OptLoopUnrollPartial => "loop partially unrolled with factor {}",
X86FullDiagID::OptLoopUnrollComplete => "loop completely unrolled",
X86FullDiagID::OptLoopFusion => "loops fused together",
X86FullDiagID::OptLoopFusionFailure => "loops not fused: {}",
X86FullDiagID::OptLoopDistribution => "loop distributed into {} separate loops",
X86FullDiagID::OptLoopDistributionFailure => "loop not distributed: {}",
X86FullDiagID::OptLoopInterchange => "loops interchanged for better cache performance",
X86FullDiagID::OptLoopInterchangeFailure => "loop interchange not profitable",
X86FullDiagID::OptLoopUnswitch => "loop unswitched on invariant condition",
X86FullDiagID::OptLoopUnswitchFailure => "loop unswitch not profitable",
X86FullDiagID::OptDevirtualizeRemark => "devirtualized call to '{}'",
X86FullDiagID::OptDevirtualizeFailure => "call not devirtualized: {}",
X86FullDiagID::OptDevirtualizeNoVtable => "no vtable available",
X86FullDiagID::OptDevirtualizeMultiInheritance => "multiple inheritance prevents devirtualization",
X86FullDiagID::OptDevirtualizeUnknown => "unknown reason",
X86FullDiagID::OptInlineRemarkCost => "inlining cost analysis: cost={}, threshold={}",
X86FullDiagID::OptInlineRemarkCallSite => "call site in '{}' with hotness {}",
X86FullDiagID::OptGVNLoadElim => "load eliminated by GVN",
X86FullDiagID::OptMemCpyOpt => "memcpy optimized",
X86FullDiagID::OptSLPVectorized => "SLP vectorized with width {}",
X86FullDiagID::OptSLPVectorizeFailure => "SLP vectorization failed: {}",
X86FullDiagID::OptConstantHoisting => "constant hoisted from loop",
X86FullDiagID::OptReassociation => "expression reassociated for optimization",
X86FullDiagID::OptLICMHoist => "loop-invariant code hoisted out of loop",
X86FullDiagID::OptLICMSink => "expression sunk into loop",
X86FullDiagID::OptDeadStoreElim => "dead store eliminated",
X86FullDiagID::OptDeadCodeElim => "dead code eliminated",
X86FullDiagID::OptInstructionSimplify => "instruction simplified",
X86FullDiagID::OptTailCallElim => "tail call eliminated",
X86FullDiagID::OptTailCallFailure => "tail call not eliminated: {}",
X86FullDiagID::OptSROA => "scalar replacement of aggregates performed",
X86FullDiagID::OptSROAFailure => "SROA not performed: {}",
X86FullDiagID::OptMergeFunctions => "functions merged: '{}' and '{}'",
X86FullDiagID::OptGlobalOpt => "global variable optimized",
X86FullDiagID::OptIPSCCP => "interprocedural sparse conditional constant propagation",
X86FullDiagID::OptAttributeOptimize => "function attribute applied for optimization",
X86FullDiagID::OptProfileDataMissing => "profile data not available; optimization may be suboptimal",
X86FullDiagID::OptSampleProfile => "sample profile data applied",
X86FullDiagID::SecFormatString => "format string is not a string literal",
X86FullDiagID::SecFormatStringOverflow => "'{}' directive writing {} bytes into region of size {}",
X86FullDiagID::SecFormatStringNoArgs => "format string has no arguments",
X86FullDiagID::SecFormatStringExtraArgs => "data argument not used by format string",
X86FullDiagID::SecFormatStringMismatch => "format specifies type '{}' but the argument has type '{}'",
X86FullDiagID::SecFormatStringSecurity => "format string is not a string literal (potentially insecure)",
X86FullDiagID::SecFormatStringNonLiteral => "format string is not a string literal",
X86FullDiagID::SecFormatStringPositional => "positional format arguments are a GNU extension",
X86FullDiagID::SecBufferOverflow => "buffer overflow: {} bytes written to buffer of size {}",
X86FullDiagID::SecBufferOverflowStack => "stack-based buffer overflow detected",
X86FullDiagID::SecBufferOverflowHeap => "heap-based buffer overflow detected",
X86FullDiagID::SecBufferOverflowGlobal => "global buffer overflow detected",
X86FullDiagID::SecBufferOverflowDynamic => "buffer overflow in dynamically-allocated memory",
X86FullDiagID::SecBufferUnderflow => "buffer underflow: read before beginning of buffer",
X86FullDiagID::SecUseAfterFree => "use after free of heap-allocated memory",
X86FullDiagID::SecDoubleFree => "double free of heap memory",
X86FullDiagID::SecUseAfterScope => "use of object after end of scope",
X86FullDiagID::SecReturnStackBuffer => "returning address of local stack buffer",
X86FullDiagID::SecNullDereference => "null pointer dereference detected",
X86FullDiagID::SecNullDereferenceUnlikely => "null pointer dereference (unlikely path)",
X86FullDiagID::SecDivisionByZero => "division by zero will result in undefined behavior",
X86FullDiagID::SecIntegerOverflow => "signed integer overflow in expression",
X86FullDiagID::SecShiftCountNegative => "shift count is negative",
X86FullDiagID::SecShiftCountOverflow => "shift count exceeds bit width of type",
X86FullDiagID::SecShiftNegative => "shifting a negative signed value is undefined",
X86FullDiagID::SecAlignmentViolation => "accessing misaligned memory at offset {}",
X86FullDiagID::SecCastAlign => "cast from '{}' to '{}' increases required alignment from {} to {}",
X86FullDiagID::SecCastAlignDown => "cast from '{}' to '{}' decreases required alignment",
X86FullDiagID::SecStrictAliasing => "type-punning through pointer cast violates strict aliasing",
X86FullDiagID::SecTypePunning => "type-based alias analysis may produce incorrect results",
X86FullDiagID::SecUninitializedRead => "reading uninitialized variable '{}'",
X86FullDiagID::SecUninitializedStack => "stack variable used before initialization",
X86FullDiagID::SecUninitializedHeap => "dynamically-allocated memory used before initialization",
X86FullDiagID::SecStackProtector => "stack smashing detected",
X86FullDiagID::SecStackProtectorStrong => "function uses stack protector; variable-length local buffer",
X86FullDiagID::SecStackClash => "stack clash protection: probe large stack allocations",
X86FullDiagID::SecStackExhausted => "stack exhausted (recursion or large allocation)",
X86FullDiagID::SecAllocaTooLarge => "alloca size exceeds stack limit",
X86FullDiagID::SecVLAInKernel => "VLA use in kernel code",
X86FullDiagID::SecVLATooLarge => "VLA size exceeds limit of {}",
X86FullDiagID::SecFORTIFYSource => "FORTIFY_SOURCE: object size check failed",
X86FullDiagID::SecBoundsCheck => "array bounds check failed: index {} exceeds size {}",
X86FullDiagID::SecImplicitConversion => "implicit conversion from '{}' to '{}' may change value",
X86FullDiagID::SecSignedToUnsigned => "conversion of signed to unsigned type may change sign",
X86FullDiagID::SecTruncation => "implicit conversion truncates value",
X86FullDiagID::SecSignExtension => "implicit sign extension in conversion",
X86FullDiagID::SecDeprecatedAPI => "'{}' is deprecated API; use '{}' instead",
X86FullDiagID::SecUnsafeFunction => "function '{}' is considered unsafe",
X86FullDiagID::SecUntrustedInput => "untrusted input passed to sensitive function",
X86FullDiagID::SecFormatTruncation => "output may be truncated writing {} bytes into region of size {}",
X86FullDiagID::FatalNoInputFiles => "no input files",
X86FullDiagID::FatalCannotOpenFile => "cannot open file '{}': {}",
X86FullDiagID::FatalCannotWriteFile => "cannot write file '{}': {}",
X86FullDiagID::FatalCannotExecuteBinary => "cannot execute binary '{}': {}",
X86FullDiagID::FatalOutOfMemory => "out of memory",
X86FullDiagID::FatalStackExhausted => "stack exhausted",
X86FullDiagID::FatalIncludeTooDeep => "#include nested too deeply",
X86FullDiagID::FatalMacroExpansionTooDeep => "macro expansion too deeply nested",
X86FullDiagID::FatalTemplateInstantiationTooDeep => "template instantiation depth exceeds maximum of {}",
X86FullDiagID::FatalRecursiveTemplateInstantiation => "recursive template instantiation",
X86FullDiagID::FatalTooManyErrors => "too many errors emitted, stopping now",
X86FullDiagID::FatalInvalidTarget => "invalid target triple '{}'",
X86FullDiagID::FatalUnsupportedTarget => "unsupported target '{}'",
X86FullDiagID::FatalInvalidArch => "invalid architecture '{}' for target '{}'",
X86FullDiagID::FatalInvalidCPU => "invalid CPU '{}' for target '{}'",
X86FullDiagID::FatalInvalidFeature => "invalid feature '{}' for target '{}'",
X86FullDiagID::FatalInvalidOption => "invalid option '{}'",
X86FullDiagID::FatalConflictingOptions => "conflicting options '{}' and '{}'",
X86FullDiagID::FatalMissingArg => "option '{}' requires an argument",
X86FullDiagID::FatalUnknownArg => "unknown argument '{}'",
X86FullDiagID::FatalInvalidValue => "invalid value '{}' for option '{}'",
X86FullDiagID::FatalModuleBuildFailed => "module build failed",
X86FullDiagID::FatalModuleFileOutOfDate => "module file is out of date",
X86FullDiagID::FatalModuleFileInvalid => "module file is invalid or corrupt",
X86FullDiagID::FatalCyclicModuleDependency => "cyclic module dependency detected",
X86FullDiagID::FatalPCHOutOfDate => "precompiled header is out of date",
X86FullDiagID::FatalPCHInvalid => "precompiled header is invalid or corrupt",
X86FullDiagID::FatalPCHCXXMismatch => "C++ language mode mismatch in precompiled header",
X86FullDiagID::FatalPCHTargetMismatch => "target mismatch in precompiled header",
X86FullDiagID::FatalPCHLanguageMismatch => "language mismatch in precompiled header",
X86FullDiagID::FatalPCHVersionMismatch => "compiler version mismatch in precompiled header",
X86FullDiagID::FatalCannotFindHeaders => "cannot find header files for target '{}'",
X86FullDiagID::FatalCannotFindSDK => "cannot find SDK for target '{}'",
X86FullDiagID::FatalSDKTooOld => "SDK version {} is too old; minimum required is {}",
X86FullDiagID::FatalBrokenInstallation => "broken compiler installation: {}",
X86FullDiagID::FatalInternalError => "internal compiler error: {}",
X86FullDiagID::FatalUnimplemented => "unimplemented feature: {}",
X86FullDiagID::FatalLTOError => "link-time optimization error: {}",
X86FullDiagID::FatalBackendError => "code generation backend error: {}",
X86FullDiagID::FatalCodeGenError => "code generation error: {}",
}
}
pub fn is_lexer(id: X86FullDiagID) -> bool {
X86DiagnosticCatalog::category(id) == "Lexer"
}
pub fn is_preprocessor(id: X86FullDiagID) -> bool {
X86DiagnosticCatalog::category(id) == "Preprocessor"
}
pub fn is_parser(id: X86FullDiagID) -> bool {
X86DiagnosticCatalog::category(id) == "Parser"
}
pub fn is_sema(id: X86FullDiagID) -> bool {
X86DiagnosticCatalog::category(id) == "Semantic Analysis"
}
pub fn is_cxx(id: X86FullDiagID) -> bool {
X86DiagnosticCatalog::category(id) == "C++ Frontend"
}
pub fn is_x86(id: X86FullDiagID) -> bool {
X86DiagnosticCatalog::category(id) == "X86 Target"
}
pub fn is_optimization(id: X86FullDiagID) -> bool {
X86DiagnosticCatalog::category(id) == "Optimization"
}
pub fn is_security(id: X86FullDiagID) -> bool {
X86DiagnosticCatalog::category(id) == "Security"
}
pub fn is_fatal(id: X86FullDiagID) -> bool {
X86DiagnosticCatalog::category(id) == "Fatal"
}
pub fn count() -> usize {
590
}
pub fn all_ids() -> Vec<X86FullDiagID> {
vec![
X86FullDiagID::LexIllegalChar,
X86FullDiagID::LexInvalidToken,
X86FullDiagID::LexUnterminatedString,
X86FullDiagID::LexUnterminatedChar,
X86FullDiagID::LexInvalidEscapeSequence,
X86FullDiagID::LexInvalidUniversalCharName,
X86FullDiagID::LexInvalidRawStringDelim,
X86FullDiagID::LexInvalidRawStringPrefix,
X86FullDiagID::LexNumericLiteralTooLarge,
X86FullDiagID::LexInvalidSuffix,
X86FullDiagID::LexTrigraphWarning,
X86FullDiagID::LexTrigraphIgnored,
X86FullDiagID::LexDigraph,
X86FullDiagID::LexHeaderName,
X86FullDiagID::LexNullCharInFile,
X86FullDiagID::LexUnicodeSurrogate,
X86FullDiagID::LexUTF8InvalidByte,
X86FullDiagID::LexMultibyteChar,
X86FullDiagID::LexWhitespaceRequired,
X86FullDiagID::LexHexEscapeOutOfRange,
X86FullDiagID::LexOctalEscapeOutOfRange,
X86FullDiagID::LexInlineASM,
X86FullDiagID::LexHashInNonDirective,
X86FullDiagID::LexUnknownPragma,
X86FullDiagID::LexUnterminatedBlockComment,
X86FullDiagID::LexNestedBlockComment,
X86FullDiagID::LexNullDirective,
X86FullDiagID::LexEmptySourceFile,
X86FullDiagID::LexBOMDetected,
X86FullDiagID::LexEncodingWarning,
X86FullDiagID::LexCRLFInRawString,
X86FullDiagID::LexEmbeddedDirective,
X86FullDiagID::LexLongUTF8Sequence,
X86FullDiagID::LexNonASCIIIdentifier,
X86FullDiagID::LexReservedIdentifier,
X86FullDiagID::LexDollarInIdentifier,
X86FullDiagID::LexUnderscoreReserved,
X86FullDiagID::LexAlternativeToken,
X86FullDiagID::LexOperatorSpelling,
X86FullDiagID::LexHexFloatLiteral,
X86FullDiagID::LexBinaryLiteral,
X86FullDiagID::LexComplexLiteral,
X86FullDiagID::LexImaginaryLiteral,
X86FullDiagID::LexUserDefinedLiteralRaw,
X86FullDiagID::LexUserDefinedLiteralCooked,
X86FullDiagID::LexCharLiteralMultiChar,
X86FullDiagID::LexCharLiteralWide,
X86FullDiagID::LexCharLiteralUTF8,
X86FullDiagID::LexCharLiteralUTF16,
X86FullDiagID::LexCharLiteralUTF32,
X86FullDiagID::LexStringLiteralWide,
X86FullDiagID::LexStringLiteralUTF8,
X86FullDiagID::LexStringLiteralUTF16,
X86FullDiagID::LexStringLiteralUTF32,
X86FullDiagID::LexStringLiteralConcat,
X86FullDiagID::LexTooManyContinuations,
X86FullDiagID::LexMissingNewlineAtEOF,
X86FullDiagID::LexExtraNewlineAtEOF,
X86FullDiagID::LexOffsetExceedsFile,
X86FullDiagID::PPMacroRedefined,
X86FullDiagID::PPMacroNotDefined,
X86FullDiagID::PPInvalidMacroName,
X86FullDiagID::PPUnterminatedMacro,
X86FullDiagID::PPExtraTokensAtEndOfDirective,
X86FullDiagID::PPMissingEndif,
X86FullDiagID::PPElifWithoutIf,
X86FullDiagID::PPElseWithoutIf,
X86FullDiagID::PPEndifWithoutIf,
X86FullDiagID::PPInvalidDirective,
X86FullDiagID::PPWrongNumberOfMacroArgs,
X86FullDiagID::PPTooFewMacroArgs,
X86FullDiagID::PPTooManyMacroArgs,
X86FullDiagID::PPBuiltinMacroRedefined,
X86FullDiagID::PPPragmaOnceInMainFile,
X86FullDiagID::PPPragmaMessage,
X86FullDiagID::PPPragmaSystemHeader,
X86FullDiagID::PPPragmaDiagnosticPush,
X86FullDiagID::PPPragmaDiagnosticPop,
X86FullDiagID::PPIncludeNestedTooDeeply,
X86FullDiagID::PPHeaderNotFound,
X86FullDiagID::PPHeaderCannotOpen,
X86FullDiagID::PPInvalidIncludeDirective,
X86FullDiagID::PPIncludeNextInPrimaryFile,
X86FullDiagID::PPWarningDirective,
X86FullDiagID::PPErrorDirective,
X86FullDiagID::PPImportInMacro,
X86FullDiagID::PPIncludeMacroUsage,
X86FullDiagID::PPUndefOfBuiltin,
X86FullDiagID::PPMacroAsArgument,
X86FullDiagID::PPNullArgInVariadic,
X86FullDiagID::PPEmptyVariadicMacro,
X86FullDiagID::PPGNUVariadicMacro,
X86FullDiagID::PPC99VariadicMacro,
X86FullDiagID::PPMSVariadicMacro,
X86FullDiagID::PPMissingWhitespaceAfterMacro,
X86FullDiagID::PPPragmaUnused,
X86FullDiagID::PPMacroExpansionTooDeep,
X86FullDiagID::PPStringifyEmpty,
X86FullDiagID::PPHashHashSingleHash,
X86FullDiagID::PPLineDirective,
X86FullDiagID::PPFileDirective,
X86FullDiagID::PPBadPaste,
X86FullDiagID::PPBadStringify,
X86FullDiagID::PPEmptyTranslationUnit,
X86FullDiagID::PPPragmaGCCSystemHeader,
X86FullDiagID::PPPragmaGCCDependency,
X86FullDiagID::PPPragmaGCCPoison,
X86FullDiagID::PPPragmaGCCVisibility,
X86FullDiagID::PPPragmaClangAttribute,
X86FullDiagID::PPPragmaClangDiagnostic,
X86FullDiagID::PPPragmaClangModule,
X86FullDiagID::PPMacroUsedBeforeDefined,
X86FullDiagID::PPMacroRedefinedDifferent,
X86FullDiagID::PPMacroArgUnused,
X86FullDiagID::PPMacroArgNameConflict,
X86FullDiagID::PPMacroArgReserved,
X86FullDiagID::PPDefinedOperatorInMacro,
X86FullDiagID::PPPragmaAlign,
X86FullDiagID::PPPragmaPack,
X86FullDiagID::PPPragmaPackShow,
X86FullDiagID::PPPragmaComment,
X86FullDiagID::PPHeaderGuardMismatch,
X86FullDiagID::PPPragmaOnceWarning,
X86FullDiagID::PPFileNotUTF8,
X86FullDiagID::PPImplicitDefine,
X86FullDiagID::PPImplicitInclude,
X86FullDiagID::PPDateMacro,
X86FullDiagID::PPTimeMacro,
X86FullDiagID::PPFileMacro,
X86FullDiagID::PPLineMacro,
X86FullDiagID::PPCounterMacro,
X86FullDiagID::PPFunctionMacro,
X86FullDiagID::PPBaseFileMacro,
X86FullDiagID::PPIncludeDepthExceeded,
X86FullDiagID::PPPragmaRegion,
X86FullDiagID::PPPragmaEndRegion,
X86FullDiagID::PPUnterminatedConditional,
X86FullDiagID::PPBadTokenPaste,
X86FullDiagID::PPAttributePushPopMismatch,
X86FullDiagID::ParseExpectedToken,
X86FullDiagID::ParseUnexpectedToken,
X86FullDiagID::ParseExpectedExpression,
X86FullDiagID::ParseExpectedType,
X86FullDiagID::ParseExpectedIdentifier,
X86FullDiagID::ParseExpectedFunctionBody,
X86FullDiagID::ParseMissingSemicolon,
X86FullDiagID::ParseMissingClosingBrace,
X86FullDiagID::ParseMissingClosingParen,
X86FullDiagID::ParseMissingClosingBracket,
X86FullDiagID::ParseDuplicateDeclaration,
X86FullDiagID::ParseConflictingTypes,
X86FullDiagID::ParseRedefinition,
X86FullDiagID::ParseTypedefRedefinition,
X86FullDiagID::ParseEnumRedefinition,
X86FullDiagID::ParseLabelRedefinition,
X86FullDiagID::ParseUndeclaredIdentifier,
X86FullDiagID::ParseImplicitDeclaration,
X86FullDiagID::ParseTypeMismatch,
X86FullDiagID::ParseIncompatibleTypes,
X86FullDiagID::ParseInvalidCast,
X86FullDiagID::ParseVoidExpression,
X86FullDiagID::ParseVoidParameter,
X86FullDiagID::ParseVoidReturn,
X86FullDiagID::ParseEmptyDeclaration,
X86FullDiagID::ParseStorageClassSpecifier,
X86FullDiagID::ParseDuplicateSpecifier,
X86FullDiagID::ParseInvalidStorageClass,
X86FullDiagID::ParseMultipleStorageClasses,
X86FullDiagID::ParseThreadNotStatic,
X86FullDiagID::ParseUnexpectedTypedef,
X86FullDiagID::ParseExpectedComma,
X86FullDiagID::ParseExpectedColon,
X86FullDiagID::ParseExpectedRBrace,
X86FullDiagID::ParseExpectedRParen,
X86FullDiagID::ParseExpectedRBracket,
X86FullDiagID::ParseExpectedSemiAfterExpr,
X86FullDiagID::ParseExpectedSemiAfterDecl,
X86FullDiagID::ParseExpectedStatement,
X86FullDiagID::ParseExpectedDeclaration,
X86FullDiagID::ParseExpectedParameter,
X86FullDiagID::ParseExpectedLoopBody,
X86FullDiagID::ParseExpectedSwitchBody,
X86FullDiagID::ParseExpectedCaseOrDefault,
X86FullDiagID::ParseExpectedStructUnion,
X86FullDiagID::ParseExpectedEnumBody,
X86FullDiagID::ParseExpectedEqual,
X86FullDiagID::ParseExpectedAngleBracket,
X86FullDiagID::ParseExpectedTypeSpecifier,
X86FullDiagID::ParseExpectedDeclarator,
X86FullDiagID::ParseExpectedQualifiedName,
X86FullDiagID::ParseExpectedCompoundStmt,
X86FullDiagID::ParseExpectedInitializer,
X86FullDiagID::ParseExpectedArrow,
X86FullDiagID::ParseExpectedDot,
X86FullDiagID::ParseExpectedOperatorName,
X86FullDiagID::ParseExpectedProperty,
X86FullDiagID::ParseExtraneousToken,
X86FullDiagID::ParseEOFExpected,
X86FullDiagID::ParseUnrecognizedDeclaration,
X86FullDiagID::ParseDanglingElse,
X86FullDiagID::ParseAmbiguousElse,
X86FullDiagID::ParseExpectedAsm,
X86FullDiagID::ParseInvalidAsm,
X86FullDiagID::ParseExpectedAttribute,
X86FullDiagID::ParseVexingParse,
X86FullDiagID::ParseMostVexingParse,
X86FullDiagID::ParseFunctionDefNoPrototype,
X86FullDiagID::ParseKandRParameters,
X86FullDiagID::ParseOldStyleDefinition,
X86FullDiagID::ParseNestedFunction,
X86FullDiagID::ParseGNUStatementExpression,
X86FullDiagID::ParseGNULocalLabel,
X86FullDiagID::ParseGNUConditionalOmittedOperand,
X86FullDiagID::ParseGNUDesignator,
X86FullDiagID::ParseGNUAttribute,
X86FullDiagID::ParseDeclspecAttribute,
X86FullDiagID::ParseAlignasInvalid,
X86FullDiagID::ParseAlignasOnParam,
X86FullDiagID::ParseAlignasOnBitField,
X86FullDiagID::ParseAtomicQualified,
X86FullDiagID::ParseNoreturnOnNonFunction,
X86FullDiagID::ParseInlineOnMain,
X86FullDiagID::ParseDeprecatedMessage,
X86FullDiagID::ParseUnavailableMessage,
X86FullDiagID::ParseUnexpectedTemplateKeyword,
X86FullDiagID::ParseExpectedTemplateArgList,
X86FullDiagID::ParseExpectedBaseClause,
X86FullDiagID::ParseExpectedCtorInitializer,
X86FullDiagID::ParseInvalidPureSpecifier,
X86FullDiagID::ParseUnexpectedFriend,
X86FullDiagID::ParseFriendOnLocalClass,
X86FullDiagID::ParseUnexpectedVirtual,
X86FullDiagID::ParseVirtualInUnion,
X86FullDiagID::ParsePureInNonVirtual,
X86FullDiagID::ParseFinalInWrongContext,
X86FullDiagID::ParseOverrideOutsideClass,
X86FullDiagID::ParseExpectedLambdaBody,
X86FullDiagID::ParseInvalidLambdaCapture,
X86FullDiagID::ParseDefaultInLambda,
X86FullDiagID::ParseMutableOnNonLambda,
X86FullDiagID::ParseInitCaptureBeforeCXX14,
X86FullDiagID::ParseGenericLambdaBeforeCXX14,
X86FullDiagID::ParseReturnTypeAfterLambda,
X86FullDiagID::ParseTemplateParamTooDeep,
X86FullDiagID::ParseTemplateDefaultArg,
X86FullDiagID::ParseExpectedTemplateParam,
X86FullDiagID::ParseConceptDefinition,
X86FullDiagID::ParseRequiresClause,
X86FullDiagID::ParseRequiresExpression,
X86FullDiagID::ParseCoroutineKeyword,
X86FullDiagID::ParseCoAwaitOutsideCoroutine,
X86FullDiagID::ParseCoYieldOutsideCoroutine,
X86FullDiagID::ParseCoReturnOutsideCoroutine,
X86FullDiagID::ParseModuleDeclaration,
X86FullDiagID::ParseModuleImport,
X86FullDiagID::ParseModuleExport,
X86FullDiagID::ParseExpectedModuleName,
X86FullDiagID::SemaTypeCheckingError,
X86FullDiagID::SemaConversionError,
X86FullDiagID::SemaOverflow,
X86FullDiagID::SemaDivisionByZero,
X86FullDiagID::SemaIncompatiblePointerTypes,
X86FullDiagID::SemaAssignmentIncompatible,
X86FullDiagID::SemaPassingArgumentIncompatible,
X86FullDiagID::SemaReturnIncompatible,
X86FullDiagID::SemaVoidFuncReturningValue,
X86FullDiagID::SemaNonVoidMissingReturn,
X86FullDiagID::SemaUnreachableCode,
X86FullDiagID::SemaUnusedVariable,
X86FullDiagID::SemaUnusedParameter,
X86FullDiagID::SemaUnusedFunction,
X86FullDiagID::SemaUninitializedVariable,
X86FullDiagID::SemaPotentiallyUninitialized,
X86FullDiagID::SemaVLANegativeSize,
X86FullDiagID::SemaVLANonPositiveSize,
X86FullDiagID::SemaArraySizeTooLarge,
X86FullDiagID::SemaNegativeArraySize,
X86FullDiagID::SemaZeroSizeArray,
X86FullDiagID::SemaFlexibleArrayMember,
X86FullDiagID::SemaFlexibleArrayInUnion,
X86FullDiagID::SemaFlexibleArrayNotAtEnd,
X86FullDiagID::SemaFieldTypeIncomplete,
X86FullDiagID::SemaBitFieldWidth,
X86FullDiagID::SemaBitFieldWidthNegative,
X86FullDiagID::SemaBitFieldWidthZero,
X86FullDiagID::SemaEnumValueOverflow,
X86FullDiagID::SemaEnumForwardDeclaration,
X86FullDiagID::SemaEnumScopedFixed,
X86FullDiagID::SemaDuplicateMember,
X86FullDiagID::SemaDuplicateEnumValue,
X86FullDiagID::SemaDuplicateCase,
X86FullDiagID::SemaDuplicateDefault,
X86FullDiagID::SemaMultipleDefault,
X86FullDiagID::SemaCaseValueNotConst,
X86FullDiagID::SemaCaseOutOfRange,
X86FullDiagID::SemaSwitchCondition,
X86FullDiagID::SemaBreakNotInLoop,
X86FullDiagID::SemaContinueNotInLoop,
X86FullDiagID::SemaLRValueMismatch,
X86FullDiagID::SemaConstQualified,
X86FullDiagID::SemaVolatileQualified,
X86FullDiagID::SemaRestrictQualified,
X86FullDiagID::SemaAtomicMismatch,
X86FullDiagID::SemaSizeofIncomplete,
X86FullDiagID::SemaAlignofIncomplete,
X86FullDiagID::SemaSizeofFunction,
X86FullDiagID::SemaSizeofVoid,
X86FullDiagID::SemaSizeofBitField,
X86FullDiagID::SemaAlignofBitField,
X86FullDiagID::SemaInvalidOperands,
X86FullDiagID::SemaInvalidUnaryOp,
X86FullDiagID::SemaInvalidBinaryOp,
X86FullDiagID::SemaInvalidTernaryOp,
X86FullDiagID::SemaInvalidCastType,
X86FullDiagID::SemaConstCast,
X86FullDiagID::SemaStaticCast,
X86FullDiagID::SemaReinterpretCast,
X86FullDiagID::SemaDynamicCast,
X86FullDiagID::SemaBadConstCast,
X86FullDiagID::SemaBadStaticCast,
X86FullDiagID::SemaBadReinterpretCast,
X86FullDiagID::SemaBadDynamicCast,
X86FullDiagID::SemaInvalidLValue,
X86FullDiagID::SemaNotModifiableLValue,
X86FullDiagID::SemaAddressOfRegister,
X86FullDiagID::SemaAddressOfBitField,
X86FullDiagID::SemaAddressOfTemporary,
X86FullDiagID::SemaAddressOfLabel,
X86FullDiagID::SemaIndirectionOnNonPointer,
X86FullDiagID::SemaSubscriptNonArray,
X86FullDiagID::SemaSubscriptNonInteger,
X86FullDiagID::SemaMemberAccessNonStruct,
X86FullDiagID::SemaCallNonFunction,
X86FullDiagID::SemaCallNonCallable,
X86FullDiagID::SemaTooManyArgs,
X86FullDiagID::SemaTooFewArgs,
X86FullDiagID::SemaVoidArgInNonPrototype,
X86FullDiagID::SemaDefaultArgMismatch,
X86FullDiagID::SemaDefaultArgRedefined,
X86FullDiagID::SemaDefaultArgOnParamPack,
X86FullDiagID::SemaLocalDeclNoLinkage,
X86FullDiagID::SemaStaticInInline,
X86FullDiagID::SemaExternInitializer,
X86FullDiagID::SemaRedefinitionOfTypedef,
X86FullDiagID::SemaRedefinitionOfLabel,
X86FullDiagID::SemaConflictingFunctionTypes,
X86FullDiagID::SemaIncompatibleFunctionDecl,
X86FullDiagID::SemaDuplicateAttribute,
X86FullDiagID::SemaAttributeIgnored,
X86FullDiagID::SemaUnknownAttribute,
X86FullDiagID::SemaGNUAttributeIgnored,
X86FullDiagID::SemaGCCExtension,
X86FullDiagID::SemaMSVCCompatibility,
X86FullDiagID::SemaReturnStackAddress,
X86FullDiagID::SemaReturnLocalAddress,
X86FullDiagID::SemaDanglingReference,
X86FullDiagID::SemaDanglingPointer,
X86FullDiagID::SemaDeallocMismatch,
X86FullDiagID::SemaDoubleFree,
X86FullDiagID::SemaUseAfterFree,
X86FullDiagID::SemaStackBufferOverflow,
X86FullDiagID::SemaHeapBufferOverflow,
X86FullDiagID::SemaSignedOverflow,
X86FullDiagID::SemaUnsignedOverflow,
X86FullDiagID::SemaFloatOverflow,
X86FullDiagID::SemaFloatToIntOverflow,
X86FullDiagID::SemaIntToFloatPrecisionLoss,
X86FullDiagID::SemaDivisionByZeroRuntime,
X86FullDiagID::SemaModuloByZero,
X86FullDiagID::SemaShiftByNegative,
X86FullDiagID::SemaShiftExceedsWidth,
X86FullDiagID::SemaNullDereference,
X86FullDiagID::SemaNonNullParamNull,
X86FullDiagID::SemaNullPassedToNonNull,
X86FullDiagID::SemaAlignmentMismatch,
X86FullDiagID::SemaCastAlignDown,
X86FullDiagID::SemaCastAlignUp,
X86FullDiagID::SemaStrictAliasingViolation,
X86FullDiagID::SemaTypePunningViaUnion,
X86FullDiagID::SemaTypePunningViaCast,
X86FullDiagID::SemaUninitializedRead,
X86FullDiagID::SemaStackProtectorFailure,
X86FullDiagID::SemaInvalidBuiltin,
X86FullDiagID::SemaDeprecatedDecl,
X86FullDiagID::SemaUnavailableDecl,
X86FullDiagID::SemaDeprecatedAttribute,
X86FullDiagID::SemaUnavailableAttribute,
X86FullDiagID::SemaDeprecatedWithMessage,
X86FullDiagID::SemaUnavailableWithMessage,
X86FullDiagID::SemaDeprecatedEnumerator,
X86FullDiagID::SemaDeprecatedTypedef,
X86FullDiagID::SemaRemovedFeature,
X86FullDiagID::CXXAccessControlPrivate,
X86FullDiagID::CXXAccessControlProtected,
X86FullDiagID::CXXAccessControlPublic,
X86FullDiagID::CXXAccessControlInaccessible,
X86FullDiagID::CXXAccessControlInaccessibleBase,
X86FullDiagID::CXXVirtualOverrideMismatch,
X86FullDiagID::CXXMissingOverride,
X86FullDiagID::CXXOverrideMismatch,
X86FullDiagID::CXXFinalOverride,
X86FullDiagID::CXXFinalClassOverride,
X86FullDiagID::CXXPureVirtualCall,
X86FullDiagID::CXXPureVirtualInCtorDtor,
X86FullDiagID::CXXAbstractClass,
X86FullDiagID::CXXAbstractClassDeclaration,
X86FullDiagID::CXXAbstractReturnType,
X86FullDiagID::CXXAbstractParameterType,
X86FullDiagID::CXXDeletedFunction,
X86FullDiagID::CXXDeletedDefault,
X86FullDiagID::CXXDeletedCopy,
X86FullDiagID::CXXDeletedMove,
X86FullDiagID::CXXDeletedDestructor,
X86FullDiagID::CXXExplicitConversion,
X86FullDiagID::CXXExplicitConstructor,
X86FullDiagID::CXXExplicitBoolConversion,
X86FullDiagID::CXXConstexprNonConst,
X86FullDiagID::CXXConstexprNoReturn,
X86FullDiagID::CXXConstexprNeverConstant,
X86FullDiagID::CXXConstexprVirtual,
X86FullDiagID::CXXConstexprTryCatch,
X86FullDiagID::CXXConstexprAllocation,
X86FullDiagID::CXXConstexprDeallocation,
X86FullDiagID::CXXConstexprDynamicCast,
X86FullDiagID::CXXConstexprReinterpretCast,
X86FullDiagID::CXXConstexprUnionActiveMember,
X86FullDiagID::CXXNoexceptMismatch,
X86FullDiagID::CXXNoexceptFunctionType,
X86FullDiagID::CXXNoexceptFalse,
X86FullDiagID::CXXNoexceptOverrideNarrower,
X86FullDiagID::CXXNoexceptOverrideWider,
X86FullDiagID::CXXTemplateArgDeductionFailed,
X86FullDiagID::CXXTemplateAmbiguous,
X86FullDiagID::CXXTemplateRecursion,
X86FullDiagID::CXXTemplateExplicitInstantiation,
X86FullDiagID::CXXTemplateExplicitSpecialization,
X86FullDiagID::CXXTemplatePartialSpecialization,
X86FullDiagID::CXXTemplateDefaultArgInvalid,
X86FullDiagID::CXXTemplateNonTypeParamInvalid,
X86FullDiagID::CXXTemplateTypeParamInvalid,
X86FullDiagID::CXXTemplateTemplateParamInvalid,
X86FullDiagID::CXXTemplateVariadicParam,
X86FullDiagID::CXXTemplateParameterPack,
X86FullDiagID::CXXTemplateArgPackExpansion,
X86FullDiagID::CXXDependentNameMissingTypename,
X86FullDiagID::CXXDependentNameInvalidTypename,
X86FullDiagID::CXXTwoPhaseLookup,
X86FullDiagID::CXXTwoPhaseLookupDependent,
X86FullDiagID::CXXTwoPhaseLookupTwoLevel,
X86FullDiagID::CXXSFINAEContext,
X86FullDiagID::CXXSFINAEDeductionFailed,
X86FullDiagID::CXXOverloadAmbiguity,
X86FullDiagID::CXXOverloadAmbiguousConversion,
X86FullDiagID::CXXOverloadAmbiguousConstructor,
X86FullDiagID::CXXOverloadNoViable,
X86FullDiagID::CXXOverloadNoViableConversion,
X86FullDiagID::CXXOverloadDeletedFunction,
X86FullDiagID::CXXOverloadInaccessibleFunction,
X86FullDiagID::CXXOverloadTemplateDeduction,
X86FullDiagID::CXXOverloadCandidateNotViable,
X86FullDiagID::CXXDestructorProtected,
X86FullDiagID::CXXDestructorPrivate,
X86FullDiagID::CXXDestructorDeleted,
X86FullDiagID::CXXDestructorVirtualBase,
X86FullDiagID::CXXDestructorAbstractBase,
X86FullDiagID::CXXCopyCtorDeleted,
X86FullDiagID::CXXCopyCtorImplicitlyDeleted,
X86FullDiagID::CXXCopyCtorNonTrivial,
X86FullDiagID::CXXCopyCtorTrivialABI,
X86FullDiagID::CXXMoveCtorDeleted,
X86FullDiagID::CXXMoveCtorNotUsed,
X86FullDiagID::CXXMoveCtorElision,
X86FullDiagID::CXXCopyAssignmentDeleted,
X86FullDiagID::CXXMoveAssignmentDeleted,
X86FullDiagID::CXXDefaultedDeleted,
X86FullDiagID::CXXDefaultedSpecialMember,
X86FullDiagID::CXXExplicitlyDefaulted,
X86FullDiagID::CXXExplicitlyDeleted,
X86FullDiagID::CXXFriendNotFirst,
X86FullDiagID::CXXFriendRedefinition,
X86FullDiagID::CXXFriendInLocalClass,
X86FullDiagID::CXXNamespaceAlias,
X86FullDiagID::CXXUsingDeclaration,
X86FullDiagID::CXXUsingDirective,
X86FullDiagID::CXXUsingShadow,
X86FullDiagID::CXXUsingAmbiguous,
X86FullDiagID::CXXAnonymousStruct,
X86FullDiagID::CXXAnonymousUnionMember,
X86FullDiagID::CXXLambdaCaptureDefault,
X86FullDiagID::CXXLambdaCaptureExplicit,
X86FullDiagID::CXXLambdaCaptureThis,
X86FullDiagID::CXXLambdaCaptureByReference,
X86FullDiagID::CXXLambdaCaptureByValue,
X86FullDiagID::CXXLambdaCaptureInit,
X86FullDiagID::CXXLambdaGeneric,
X86FullDiagID::CXXLambdaConstexpr,
X86FullDiagID::CXXLambdaMutable,
X86FullDiagID::CXXLambdaDefaultArg,
X86FullDiagID::CXXLambdaTemplate,
X86FullDiagID::CXXLambdaInUnevaluated,
X86FullDiagID::CXXLambdaStaticInvoker,
X86FullDiagID::CXXCoroutineReturnType,
X86FullDiagID::CXXCoroutinePromiseType,
X86FullDiagID::CXXCoroutineAwaitable,
X86FullDiagID::CXXCoroutineSymmetricTransfer,
X86FullDiagID::CXXCoroutineFrameAllocation,
X86FullDiagID::CXXCoroutineNoElision,
X86FullDiagID::CXXCoroutineHeapAlloc,
X86FullDiagID::CXXCoroutineHeapDealloc,
X86FullDiagID::CXXConceptDefinition,
X86FullDiagID::CXXConceptConstraint,
X86FullDiagID::CXXConceptSatisfaction,
X86FullDiagID::CXXConceptAtomic,
X86FullDiagID::CXXConceptRequires,
X86FullDiagID::CXXConceptNestedRequirement,
X86FullDiagID::CXXConceptTypeRequirement,
X86FullDiagID::CXXConceptCompoundRequirement,
X86FullDiagID::CXXConceptExpressionRequirement,
X86FullDiagID::CXXConceptPartialOrdering,
X86FullDiagID::CXXConceptSubsumption,
X86FullDiagID::CXXConceptDefaultConstraint,
X86FullDiagID::CXXModuleInterface,
X86FullDiagID::CXXModuleImplementation,
X86FullDiagID::CXXModulePartition,
X86FullDiagID::CXXModuleImport,
X86FullDiagID::CXXModuleExport,
X86FullDiagID::CXXModuleOwnership,
X86FullDiagID::CXXModuleLinkage,
X86FullDiagID::CXXModuleVisibility,
X86FullDiagID::CXXModuleReachability,
X86FullDiagID::CXXModuleAttainment,
X86FullDiagID::CXXModuleGlobalFragment,
X86FullDiagID::CXXModulePrivateFragment,
X86FullDiagID::CXXModuleHeaderUnit,
X86FullDiagID::CXXModuleBMI,
X86FullDiagID::CXXThreeWayComparison,
X86FullDiagID::CXXSpaceshipAuto,
X86FullDiagID::CXXSpaceshipReturnType,
X86FullDiagID::CXXDefaultedComparison,
X86FullDiagID::CXXWeakEquality,
X86FullDiagID::CXXStrongEquality,
X86FullDiagID::CXXWeakOrdering,
X86FullDiagID::CXXPartialOrdering,
X86FullDiagID::CXXStrongOrdering,
X86FullDiagID::CXXDesignatedInit,
X86FullDiagID::CXXDesignatedInitMixed,
X86FullDiagID::CXXDesignatedInitOutOfOrder,
X86FullDiagID::CXXDesignatedInitNested,
X86FullDiagID::CXXDesignatedInitOverride,
X86FullDiagID::CXXDesignatedInitArray,
X86FullDiagID::CXXRangeBasedFor,
X86FullDiagID::CXXRangeBasedForBeginEnd,
X86FullDiagID::CXXRangeBasedForADL,
X86FullDiagID::CXXStructuredBinding,
X86FullDiagID::CXXStructuredBindingTuple,
X86FullDiagID::CXXStructuredBindingArray,
X86FullDiagID::CXXStructuredBindingMember,
X86FullDiagID::CXXInitStatement,
X86FullDiagID::CXXIfInit,
X86FullDiagID::CXXSwitchInit,
X86FullDiagID::CXXRangeForInit,
X86FullDiagID::CXXCTAD,
X86FullDiagID::CXXCTADGuide,
X86FullDiagID::CXXCTADAggregate,
X86FullDiagID::CXXCTADExplicit,
X86FullDiagID::CXXCTADDeductionFailed,
X86FullDiagID::CXXAggregateInit,
X86FullDiagID::CXXAggregateParenInit,
X86FullDiagID::CXXTrivialABI,
X86FullDiagID::CXXTrivialDestructor,
X86FullDiagID::CXXTrivialCopy,
X86FullDiagID::CXXNoUniqueAddress,
X86FullDiagID::CXXLikely,
X86FullDiagID::CXXUnlikely,
X86FullDiagID::CXXAssume,
X86FullDiagID::CXXDefaultMemberInit,
X86FullDiagID::CXXDefaultMemberInitBitField,
X86FullDiagID::CXXNSDMI,
X86FullDiagID::CXXInheritingConstructor,
X86FullDiagID::CXXInheritingConstructorConflict,
X86FullDiagID::CXXVariadicUsing,
X86FullDiagID::CXXPackExpansion,
X86FullDiagID::CXXFoldExpression,
X86FullDiagID::CXXFoldUnaryLeft,
X86FullDiagID::CXXFoldUnaryRight,
X86FullDiagID::CXXFoldBinaryLeft,
X86FullDiagID::CXXFoldBinaryRight,
X86FullDiagID::CXXEmptyFold,
X86FullDiagID::X86FeatureSSE,
X86FullDiagID::X86FeatureSSE2,
X86FullDiagID::X86FeatureSSE3,
X86FullDiagID::X86FeatureSSSE3,
X86FullDiagID::X86FeatureSSE41,
X86FullDiagID::X86FeatureSSE42,
X86FullDiagID::X86FeatureAVX,
X86FullDiagID::X86FeatureAVX2,
X86FullDiagID::X86FeatureAVX512F,
X86FullDiagID::X86FeatureAVX512BW,
X86FullDiagID::X86FeatureAVX512DQ,
X86FullDiagID::X86FeatureAVX512VL,
X86FullDiagID::X86FeatureAVX512CD,
X86FullDiagID::X86FeatureAVX512ER,
X86FullDiagID::X86FeatureAVX512PF,
X86FullDiagID::X86FeatureAVX512BF16,
X86FullDiagID::X86FeatureAVX512FP16,
X86FullDiagID::X86FeatureAVX512VBMI,
X86FullDiagID::X86FeatureAVX512VBMI2,
X86FullDiagID::X86FeatureAVX512VNNI,
X86FullDiagID::X86FeatureAVX512BITALG,
X86FullDiagID::X86FeatureAVX512VPOPCNTDQ,
X86FullDiagID::X86FeatureAVX5124FMAPS,
X86FullDiagID::X86FeatureAVX5124VNNIW,
X86FullDiagID::X86FeatureAVX512VP2INTERSECT,
X86FullDiagID::X86FeatureAVX512IFMA,
X86FullDiagID::X86FeatureAVX512FP16Conv,
X86FullDiagID::X86FeatureAVX10_1_256,
X86FullDiagID::X86FeatureAVX10_1_512,
X86FullDiagID::X86FeatureAVX10_2,
X86FullDiagID::X86FeatureFMA,
X86FullDiagID::X86FeatureFMA4,
X86FullDiagID::X86FeatureF16C,
X86FullDiagID::X86FeatureMMX,
X86FullDiagID::X86FeatureSSE4a,
X86FullDiagID::X86FeatureXOP,
X86FullDiagID::X86Feature3DNOW,
X86FullDiagID::X86Feature3DNOWA,
X86FullDiagID::X86FeatureBMI,
X86FullDiagID::X86FeatureBMI2,
X86FullDiagID::X86FeatureLZCNT,
X86FullDiagID::X86FeaturePOPCNT,
X86FullDiagID::X86FeatureTBM,
X86FullDiagID::X86FeatureAES,
X86FullDiagID::X86FeaturePCLMUL,
X86FullDiagID::X86FeatureSHA,
X86FullDiagID::X86FeatureSHA512,
X86FullDiagID::X86FeatureSM3,
X86FullDiagID::X86FeatureSM4,
X86FullDiagID::X86FeatureGFNI,
X86FullDiagID::X86FeatureVAES,
X86FullDiagID::X86FeatureVPCLMULQDQ,
X86FullDiagID::X86FeatureRDRAND,
X86FullDiagID::X86FeatureRDSEED,
X86FullDiagID::X86FeatureADX,
X86FullDiagID::X86FeatureRTM,
X86FullDiagID::X86FeatureHLE,
X86FullDiagID::X86FeatureSGX,
X86FullDiagID::X86FeatureCET,
X86FullDiagID::X86FeatureCETSS,
X86FullDiagID::X86FeatureXSAVE,
X86FullDiagID::X86FeatureXSAVEOPT,
X86FullDiagID::X86FeatureXSAVEC,
X86FullDiagID::X86FeatureXSAVES,
X86FullDiagID::X86FeatureFSGSBASE,
X86FullDiagID::X86FeatureMOVBE,
X86FullDiagID::X86FeatureMOVDIRI,
X86FullDiagID::X86FeatureMOVDIR64B,
X86FullDiagID::X86FeatureENQCMD,
X86FullDiagID::X86FeatureSERIALIZE,
X86FullDiagID::X86FeatureTSXLDTRK,
X86FullDiagID::X86FeatureWAITPKG,
X86FullDiagID::X86FeatureCLDEMOTE,
X86FullDiagID::X86FeatureCLFLUSHOPT,
X86FullDiagID::X86FeatureCLWB,
X86FullDiagID::X86FeatureCLZERO,
X86FullDiagID::X86FeaturePKU,
X86FullDiagID::X86FeatureAMX_BF16,
X86FullDiagID::X86FeatureAMX_INT8,
X86FullDiagID::X86FeatureAMX_TILE,
X86FullDiagID::X86FeatureAMX_FP16,
X86FullDiagID::X86FeatureAMX_COMPLEX,
X86FullDiagID::X86FeatureX87,
X86FullDiagID::X86FeatureCMOV,
X86FullDiagID::X86CallingConventionMismatch,
X86FullDiagID::X86ABIViolation,
X86FullDiagID::X86StructReturnTooLarge,
X86FullDiagID::X86VectorTypeNotSupported,
X86FullDiagID::X86IntrinsicNotAvailable,
X86FullDiagID::X86CPUFeatureNotAvailable,
X86FullDiagID::X86TargetAttributeConflict,
X86FullDiagID::X86OptionArchMismatch,
X86FullDiagID::X86ABIStructTooLarge,
X86FullDiagID::X86ABIHiddenPointerReturn,
X86FullDiagID::X86ABIRedZoneViolation,
X86FullDiagID::X86ABIStackAlignmentViolation,
X86FullDiagID::X86ABIVectorcallAlignment,
X86FullDiagID::X86ABIFastcallTooManyArgs,
X86FullDiagID::X86ABIThiscallNonMember,
X86FullDiagID::X86ABIStdCallVarArgs,
X86FullDiagID::X86ABIRegCallNotEnoughRegs,
X86FullDiagID::X86ABISysVClassificationFailed,
X86FullDiagID::X86ABIMicrosoftClassificationFailed,
X86FullDiagID::X86ABIRegCallClassificationFailed,
X86FullDiagID::X86ABIEmptyStructPass,
X86FullDiagID::X86ABIPackedStructPass,
X86FullDiagID::X86ABIBitfieldStraddle,
X86FullDiagID::X86ABIComplexReturn,
X86FullDiagID::X86ABIX87Return,
X86FullDiagID::X86InlineASMInvalidInstruction,
X86FullDiagID::X86InlineASMInvalidConstraint,
X86FullDiagID::X86InlineASMClobberConflict,
X86FullDiagID::X86InlineASMTooManyOperands,
X86FullDiagID::X86InlineASMGlobalRegister,
X86FullDiagID::X86VectorWidthMismatch,
X86FullDiagID::X86VectorShuffleInvalid,
X86FullDiagID::X86VectorGatherAlign,
X86FullDiagID::X86VectorMaskMissing,
X86FullDiagID::X86AlignmentNone,
X86FullDiagID::X86AlignmentUnaligned,
X86FullDiagID::X86RedZoneViolation,
X86FullDiagID::X86StackSize,
X86FullDiagID::X86NopPadding,
X86FullDiagID::OptInlineRemark,
X86FullDiagID::OptInlineFailure,
X86FullDiagID::OptInlineCostTooHigh,
X86FullDiagID::OptInlineNoDefinition,
X86FullDiagID::OptInlineRecursive,
X86FullDiagID::OptInlineNoInlineAttr,
X86FullDiagID::OptInlineAlwaysInline,
X86FullDiagID::OptInlineNoOptimize,
X86FullDiagID::OptInlineOptNone,
X86FullDiagID::OptVectorizationRemark,
X86FullDiagID::OptVectorizationFailure,
X86FullDiagID::OptVectorizationUnsafeDep,
X86FullDiagID::OptVectorizationNoAlias,
X86FullDiagID::OptVectorizationUnaligned,
X86FullDiagID::OptVectorizationNoReduction,
X86FullDiagID::OptVectorizationSmallTrip,
X86FullDiagID::OptVectorizationNonLinear,
X86FullDiagID::OptVectorizationIneffective,
X86FullDiagID::OptLoopUnrollRemark,
X86FullDiagID::OptLoopUnrollFailure,
X86FullDiagID::OptLoopUnrollTooLarge,
X86FullDiagID::OptLoopUnrollNonConstant,
X86FullDiagID::OptLoopUnrollPartial,
X86FullDiagID::OptLoopUnrollComplete,
X86FullDiagID::OptLoopFusion,
X86FullDiagID::OptLoopFusionFailure,
X86FullDiagID::OptLoopDistribution,
X86FullDiagID::OptLoopDistributionFailure,
X86FullDiagID::OptLoopInterchange,
X86FullDiagID::OptLoopInterchangeFailure,
X86FullDiagID::OptLoopUnswitch,
X86FullDiagID::OptLoopUnswitchFailure,
X86FullDiagID::OptDevirtualizeRemark,
X86FullDiagID::OptDevirtualizeFailure,
X86FullDiagID::OptDevirtualizeNoVtable,
X86FullDiagID::OptDevirtualizeMultiInheritance,
X86FullDiagID::OptDevirtualizeUnknown,
X86FullDiagID::OptInlineRemarkCost,
X86FullDiagID::OptInlineRemarkCallSite,
X86FullDiagID::OptGVNLoadElim,
X86FullDiagID::OptMemCpyOpt,
X86FullDiagID::OptSLPVectorized,
X86FullDiagID::OptSLPVectorizeFailure,
X86FullDiagID::OptConstantHoisting,
X86FullDiagID::OptReassociation,
X86FullDiagID::OptLICMHoist,
X86FullDiagID::OptLICMSink,
X86FullDiagID::OptDeadStoreElim,
X86FullDiagID::OptDeadCodeElim,
X86FullDiagID::OptInstructionSimplify,
X86FullDiagID::OptTailCallElim,
X86FullDiagID::OptTailCallFailure,
X86FullDiagID::OptSROA,
X86FullDiagID::OptSROAFailure,
X86FullDiagID::OptMergeFunctions,
X86FullDiagID::OptGlobalOpt,
X86FullDiagID::OptIPSCCP,
X86FullDiagID::OptAttributeOptimize,
X86FullDiagID::OptProfileDataMissing,
X86FullDiagID::OptSampleProfile,
X86FullDiagID::SecFormatString,
X86FullDiagID::SecFormatStringOverflow,
X86FullDiagID::SecFormatStringNoArgs,
X86FullDiagID::SecFormatStringExtraArgs,
X86FullDiagID::SecFormatStringMismatch,
X86FullDiagID::SecFormatStringSecurity,
X86FullDiagID::SecFormatStringNonLiteral,
X86FullDiagID::SecFormatStringPositional,
X86FullDiagID::SecBufferOverflow,
X86FullDiagID::SecBufferOverflowStack,
X86FullDiagID::SecBufferOverflowHeap,
X86FullDiagID::SecBufferOverflowGlobal,
X86FullDiagID::SecBufferOverflowDynamic,
X86FullDiagID::SecBufferUnderflow,
X86FullDiagID::SecUseAfterFree,
X86FullDiagID::SecDoubleFree,
X86FullDiagID::SecUseAfterScope,
X86FullDiagID::SecReturnStackBuffer,
X86FullDiagID::SecNullDereference,
X86FullDiagID::SecNullDereferenceUnlikely,
X86FullDiagID::SecDivisionByZero,
X86FullDiagID::SecIntegerOverflow,
X86FullDiagID::SecShiftCountNegative,
X86FullDiagID::SecShiftCountOverflow,
X86FullDiagID::SecShiftNegative,
X86FullDiagID::SecAlignmentViolation,
X86FullDiagID::SecCastAlign,
X86FullDiagID::SecCastAlignDown,
X86FullDiagID::SecStrictAliasing,
X86FullDiagID::SecTypePunning,
X86FullDiagID::SecUninitializedRead,
X86FullDiagID::SecUninitializedStack,
X86FullDiagID::SecUninitializedHeap,
X86FullDiagID::SecStackProtector,
X86FullDiagID::SecStackProtectorStrong,
X86FullDiagID::SecStackClash,
X86FullDiagID::SecStackExhausted,
X86FullDiagID::SecAllocaTooLarge,
X86FullDiagID::SecVLAInKernel,
X86FullDiagID::SecVLATooLarge,
X86FullDiagID::SecFORTIFYSource,
X86FullDiagID::SecBoundsCheck,
X86FullDiagID::SecImplicitConversion,
X86FullDiagID::SecSignedToUnsigned,
X86FullDiagID::SecTruncation,
X86FullDiagID::SecSignExtension,
X86FullDiagID::SecDeprecatedAPI,
X86FullDiagID::SecUnsafeFunction,
X86FullDiagID::SecUntrustedInput,
X86FullDiagID::SecFormatTruncation,
X86FullDiagID::FatalNoInputFiles,
X86FullDiagID::FatalCannotOpenFile,
X86FullDiagID::FatalCannotWriteFile,
X86FullDiagID::FatalCannotExecuteBinary,
X86FullDiagID::FatalOutOfMemory,
X86FullDiagID::FatalStackExhausted,
X86FullDiagID::FatalIncludeTooDeep,
X86FullDiagID::FatalMacroExpansionTooDeep,
X86FullDiagID::FatalTemplateInstantiationTooDeep,
X86FullDiagID::FatalRecursiveTemplateInstantiation,
X86FullDiagID::FatalTooManyErrors,
X86FullDiagID::FatalInvalidTarget,
X86FullDiagID::FatalUnsupportedTarget,
X86FullDiagID::FatalInvalidArch,
X86FullDiagID::FatalInvalidCPU,
X86FullDiagID::FatalInvalidFeature,
X86FullDiagID::FatalInvalidOption,
X86FullDiagID::FatalConflictingOptions,
X86FullDiagID::FatalMissingArg,
X86FullDiagID::FatalUnknownArg,
X86FullDiagID::FatalInvalidValue,
X86FullDiagID::FatalModuleBuildFailed,
X86FullDiagID::FatalModuleFileOutOfDate,
X86FullDiagID::FatalModuleFileInvalid,
X86FullDiagID::FatalCyclicModuleDependency,
X86FullDiagID::FatalPCHOutOfDate,
X86FullDiagID::FatalPCHInvalid,
X86FullDiagID::FatalPCHCXXMismatch,
X86FullDiagID::FatalPCHTargetMismatch,
X86FullDiagID::FatalPCHLanguageMismatch,
X86FullDiagID::FatalPCHVersionMismatch,
X86FullDiagID::FatalCannotFindHeaders,
X86FullDiagID::FatalCannotFindSDK,
X86FullDiagID::FatalSDKTooOld,
X86FullDiagID::FatalBrokenInstallation,
X86FullDiagID::FatalInternalError,
X86FullDiagID::FatalUnimplemented,
X86FullDiagID::FatalLTOError,
X86FullDiagID::FatalBackendError,
X86FullDiagID::FatalCodeGenError,
]
}
}
#[derive(Debug, Clone)]
pub struct X86ColorScheme {
pub use_colors: bool,
pub error_color: String,
pub warning_color: String,
pub note_color: String,
pub fixit_color: String,
pub caret_color: String,
pub filename_color: String,
pub line_number_color: String,
pub range_color: String,
pub reset: String,
}
impl X86ColorScheme {
pub fn clang_style() -> Self {
Self {
use_colors: true,
error_color: "\x1b[1;31m".to_string(),
warning_color: "\x1b[1;35m".to_string(),
note_color: "\x1b[1;36m".to_string(),
fixit_color: "\x1b[1;32m".to_string(),
caret_color: "\x1b[1;32m".to_string(),
filename_color: "\x1b[1m".to_string(),
line_number_color: "\x1b[1m".to_string(),
range_color: "\x1b[32m".to_string(),
reset: "\x1b[0m".to_string(),
}
}
pub fn monochrome() -> Self {
Self {
use_colors: false,
error_color: String::new(),
warning_color: String::new(),
note_color: String::new(),
fixit_color: String::new(),
caret_color: String::new(),
filename_color: String::new(),
line_number_color: String::new(),
range_color: String::new(),
reset: String::new(),
}
}
pub fn wrap(&self, text: &str, color: &str) -> String {
if self.use_colors {
format!("{}{}{}", color, text, self.reset)
} else {
text.to_string()
}
}
}
impl Default for X86ColorScheme {
fn default() -> Self {
Self::clang_style()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RenderOutputFormat {
Clang,
GCC,
MSVC,
JSON,
SARIF,
XML,
}
impl RenderOutputFormat {
pub fn is_machine_readable(&self) -> bool {
matches!(self, Self::JSON | Self::SARIF | Self::XML)
}
pub fn extension(&self) -> &'static str {
match self {
Self::JSON => "json",
Self::SARIF => "sarif",
Self::XML => "xml",
_ => "txt",
}
}
}
#[derive(Debug, Clone)]
pub struct RenderedLine {
pub line_number: Option<usize>,
pub source_line: Option<String>,
pub caret_line: Option<String>,
pub ranges: Vec<(usize, usize)>,
}
pub struct X86DiagnosticRenderer {
pub color_scheme: X86ColorScheme,
pub format: RenderOutputFormat,
pub show_column: bool,
pub show_source_line: bool,
pub show_carets: bool,
pub show_fixits: bool,
pub show_option_names: bool,
pub show_categories: bool,
pub context_lines: usize,
pub tab_stop: usize,
pub message_length: usize,
source_lines: HashMap<String, Vec<String>>,
}
impl X86DiagnosticRenderer {
pub fn new() -> Self {
Self {
color_scheme: X86ColorScheme::clang_style(),
format: RenderOutputFormat::Clang,
show_column: true,
show_source_line: true,
show_carets: true,
show_fixits: true,
show_option_names: true,
show_categories: true,
context_lines: 1,
tab_stop: 8,
message_length: 120,
source_lines: HashMap::new(),
}
}
pub fn with_format(mut self, format: RenderOutputFormat) -> Self {
self.format = format;
self
}
pub fn with_colors(mut self, use_colors: bool) -> Self {
self.color_scheme.use_colors = use_colors;
self
}
pub fn for_ide() -> Self {
Self {
show_column: true,
show_source_line: true,
show_carets: true,
show_fixits: true,
show_categories: false,
show_option_names: false,
context_lines: 0,
..Self::new()
}
}
pub fn register_source(&mut self, filename: &str, content: &str) {
let lines: Vec<String> = content.lines().map(|s| s.to_string()).collect();
self.source_lines.insert(filename.to_string(), lines);
}
pub fn build_caret_line(
&self,
source_line: &str,
column: usize,
ranges: &[(usize, usize)],
) -> String {
let mut caret = String::new();
let line_len = source_line.len().max(1);
let expanded_line = source_line.replace('\t', &" ".repeat(self.tab_stop));
let col = column.min(line_len);
for i in 0..line_len.max(col + 1) {
if i + 1 == col {
caret.push('^');
} else if ranges.iter().any(|&(s, e)| i + 1 >= s && i + 1 < e) {
caret.push('~');
} else {
if i < col.saturating_sub(1)
&& source_line
.chars()
.nth(i)
.map_or(false, |c| c == ' ' || c == '\t')
{
caret.push(' ');
} else if i < col.saturating_sub(1) {
caret.push(' ');
} else {
caret.push(' ');
}
}
}
let mut result = String::new();
for (i, ch) in caret.char_indices() {
if i < col.saturating_sub(1) && ch != '^' {
result.push(' ');
} else {
result.push(ch);
}
}
result
}
pub fn build_caret_with_ranges(
&self,
source_line: &str,
primary_col: usize,
ranges: &[(usize, usize, bool, Option<&str>)],
) -> String {
let expanded = source_line.replace('\t', &" ".repeat(self.tab_stop));
let len = expanded.len().max(primary_col);
let mut caret = String::with_capacity(len);
let mut in_primary = false;
let mut in_range = false;
let mut range_end = 0;
for col in 1..=len {
for &(start, end, primary, _msg) in ranges {
if col == start {
if primary {
in_primary = true;
} else {
in_range = true;
}
range_end = end;
}
}
if col >= range_end {
in_primary = false;
in_range = false;
}
if col == primary_col {
caret.push('^');
} else if in_primary {
caret.push('~');
} else if in_range {
caret.push('~');
} else {
caret.push(' ');
}
}
caret.to_string()
}
pub fn render_fixit(&self, fixit: &FixItHint) -> String {
let prefix = if self.color_scheme.use_colors {
format!(
"{}fix-it:{} ",
self.color_scheme.fixit_color, self.color_scheme.reset
)
} else {
"fix-it: ".to_string()
};
if fixit.is_insertion {
format!("{}{{\"{}\"}}", prefix, fixit.code)
} else {
format!("{}{{\"{}\"}}", prefix, fixit.code)
}
}
pub fn format_location(&self, loc: &ClangSourceLocation) -> String {
if !loc.is_valid {
return "<invalid>".to_string();
}
if self.show_column {
format!("{}:{}:{}", loc.file, loc.line, loc.column)
} else {
format!("{}:{}", loc.file, loc.line)
}
}
pub fn format_severity(&self, severity: DiagSeverity) -> String {
let label = match severity {
DiagSeverity::Ignored => "ignored",
DiagSeverity::Remark => "remark",
DiagSeverity::Note => "note",
DiagSeverity::Warning => "warning",
DiagSeverity::Error => "error",
DiagSeverity::Fatal => "fatal error",
};
match severity {
DiagSeverity::Error | DiagSeverity::Fatal => self
.color_scheme
.wrap(label, &self.color_scheme.error_color),
DiagSeverity::Warning => self
.color_scheme
.wrap(label, &self.color_scheme.warning_color),
DiagSeverity::Note => self.color_scheme.wrap(label, &self.color_scheme.note_color),
_ => label.to_string(),
}
}
pub fn render_clang(
&self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
ranges: &[SourceRange],
fixits: &[FixItHint],
notes: &[String],
) -> String {
let mut output = String::new();
let loc_str = self.format_location(location);
let sev_str = self.format_severity(severity);
output.push_str(&loc_str);
output.push_str(": ");
output.push_str(&sev_str);
output.push_str(": ");
output.push_str(message);
if self.show_option_names {
let flag = X86DiagnosticCatalog::flag_name(id);
if !flag.is_empty() {
output.push_str(&format!(" [{}]", flag));
}
}
if self.show_categories {
let cat = X86DiagnosticCatalog::category(id);
output.push_str(&format!(" [{}]", cat));
}
output.push('\n');
if self.show_source_line && location.is_valid {
if let Some(lines) = self
.source_lines
.get(&location.file.to_string_lossy().to_string())
{
let line_idx = location.line.saturating_sub(1) as usize;
if line_idx < lines.len() {
let source_line = &lines[line_idx];
output.push_str(&format!(" {:>4} | {}\n", location.line, source_line));
output.push_str(&format!(" | "));
if self.show_carets {
let simple_ranges: Vec<(usize, usize)> = ranges
.iter()
.filter(|r| r.is_valid())
.map(|r| (r.begin.column, r.end.column))
.collect();
let caret = self.build_caret_line(
source_line,
location.column as usize,
&simple_ranges,
);
output.push_str(&caret);
output.push('\n');
}
}
}
}
if self.show_fixits && !fixits.is_empty() {
for fixit in fixits {
output.push_str(&self.render_fixit(fixit));
output.push('\n');
}
}
for note in notes {
output.push_str(&format!("note: {}\n", note));
}
output
}
pub fn render_gcc(
&self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
) -> String {
let flag = X86DiagnosticCatalog::flag_name(id);
let sev = match severity {
DiagSeverity::Error | DiagSeverity::Fatal => "error",
DiagSeverity::Warning => "warning",
DiagSeverity::Note => "note",
_ => "remark",
};
let mut output = format!("{}:{}: {}: {}", location.file, location.line, sev, message);
if !flag.is_empty() {
output.push_str(&format!(" [{}]", flag));
}
output.push('\n');
output
}
pub fn render_msvc(
&self,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
id: X86FullDiagID,
) -> String {
let sev = match severity {
DiagSeverity::Error | DiagSeverity::Fatal => "error",
DiagSeverity::Warning => "warning",
_ => "info",
};
let code = format!("{:?}", id).to_uppercase();
format!(
"{}({},{}): {} C{}: {}\n",
location.file, location.line, location.column, sev, code, message
)
}
pub fn render(
&self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
ranges: &[SourceRange],
fixits: &[FixItHint],
notes: &[String],
) -> String {
match self.format {
RenderOutputFormat::Clang => {
self.render_clang(id, severity, message, location, ranges, fixits, notes)
}
RenderOutputFormat::GCC => self.render_gcc(id, severity, message, location),
RenderOutputFormat::MSVC => self.render_msvc(severity, message, location, id),
RenderOutputFormat::JSON => {
self.render_json(id, severity, message, location, ranges, fixits, notes)
}
RenderOutputFormat::SARIF => {
self.render_sarif(id, severity, message, location, ranges, fixits, notes)
}
RenderOutputFormat::XML => {
self.render_xml(id, severity, message, location, ranges, fixits, notes)
}
}
}
pub fn render_json(
&self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
ranges: &[SourceRange],
fixits: &[FixItHint],
notes: &[String],
) -> String {
let sev_str = match severity {
DiagSeverity::Ignored => "ignored",
DiagSeverity::Remark => "remark",
DiagSeverity::Note => "note",
DiagSeverity::Warning => "warning",
DiagSeverity::Error => "error",
DiagSeverity::Fatal => "fatal",
};
let mut json = format!(
r#"{{"id":"{:?}","severity":"{}","message":"{}""#,
id,
sev_str,
message.replace('\"', "\\\"")
);
if location.is_valid {
json.push_str(&format!(
r#","location":{{"file":"{}","line":{},"column":{},"offset":{}}}"#,
location.file, location.line, location.column, location.offset
));
}
if !ranges.is_empty() {
json.push_str(r#","ranges":["#);
for (i, r) in ranges.iter().enumerate() {
if i > 0 {
json.push(',');
}
json.push_str(&format!(
r#"{{"begin":{{"line":{},"col":{}}},"end":{{"line":{},"col":{}}}}}"#,
r.begin.line, r.begin.column, r.end.line, r.end.column
));
}
json.push(']');
}
if !fixits.is_empty() {
json.push_str(r#","fixits":["#);
for (i, f) in fixits.iter().enumerate() {
if i > 0 {
json.push(',');
}
json.push_str(&format!(
r#"{{"code":"{}","is_insertion":{}}}"#,
f.code.replace('\"', "\\\""),
f.is_insertion
));
}
json.push(']');
}
if !notes.is_empty() {
json.push_str(r#","notes":["#);
for (i, n) in notes.iter().enumerate() {
if i > 0 {
json.push(',');
}
json.push_str(&format!(r#""{}""#, n.replace('\"', "\\\"")));
}
json.push(']');
}
let flag = X86DiagnosticCatalog::flag_name(id);
if !flag.is_empty() {
json.push_str(&format!(r#","flag":"{}""#, flag));
}
json.push('}');
json.push('\n');
json
}
pub fn render_sarif(
&self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
_ranges: &[SourceRange],
_fixits: &[FixItHint],
_notes: &[String],
) -> String {
let level = match severity {
DiagSeverity::Error | DiagSeverity::Fatal => "error",
DiagSeverity::Warning => "warning",
DiagSeverity::Note => "note",
_ => "none",
};
format!(
r#"{{"ruleId":"{:?}","level":"{}","message":{{"text":"{}"}},"locations":[{{"physicalLocation":{{"artifactLocation":{{"uri":"{}"}},"region":{{"startLine":{},"startColumn":{}}}}}}}]}}"#,
id,
level,
message.replace('\"', "\\\""),
location.file,
location.line,
location.column
)
}
pub fn render_xml(
&self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
ranges: &[SourceRange],
fixits: &[FixItHint],
notes: &[String],
) -> String {
let sev = match severity {
DiagSeverity::Error | DiagSeverity::Fatal => "error",
DiagSeverity::Warning => "warning",
DiagSeverity::Note => "note",
_ => "info",
};
let mut xml = format!(
r#"<diagnostic id="{:?}" severity="{}" category="{}">"#,
id,
sev,
X86DiagnosticCatalog::category(id)
);
xml.push_str(&format!("<message>{}</message>", escape_xml(message)));
if location.is_valid {
xml.push_str(&format!(
"<location file=\"{}\" line=\"{}\" column=\"{}\" offset=\"{}\"/>",
location.file, location.line, location.column, location.offset
));
}
for range in ranges {
if range.is_valid() {
xml.push_str(&format!(
"<range start_line=\"{}\" start_col=\"{}\" end_line=\"{}\" end_col=\"{}\"/>",
range.begin.line, range.begin.column, range.end.line, range.end.column
));
}
}
for fixit in fixits {
xml.push_str(&format!(
"<fixit is_insertion=\"{}\"><![CDATA[{}]]></fixit>",
fixit.is_insertion, fixit.code
));
}
for note in notes {
xml.push_str(&format!("<note>{}</note>", escape_xml(note)));
}
xml.push_str("</diagnostic>\n");
xml
}
}
impl Default for X86DiagnosticRenderer {
fn default() -> Self {
Self::new()
}
}
fn escape_xml(s: &str) -> String {
s.replace('&', "&")
.replace('<', "<")
.replace('>', ">")
.replace('"', """)
.replace('\'', "'")
}
#[derive(Debug, Clone)]
pub struct X86DiagGroup {
pub name: String,
pub members: Vec<X86FullDiagID>,
pub enabled_by_default: bool,
pub description: String,
pub sub_groups: Vec<String>,
}
pub struct X86DiagnosticGroups {
pub groups: HashMap<String, X86DiagGroup>,
}
impl X86DiagnosticGroups {
pub fn new() -> Self {
let mut registry = Self {
groups: HashMap::new(),
};
registry.register_default_groups();
registry
}
fn register_default_groups(&mut self) {
self.add_group(X86DiagGroup {
name: "all".to_string(),
enabled_by_default: false,
description: "Enable most common warnings (-Wall)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SemaUnusedVariable,
X86FullDiagID::SemaUnusedParameter,
X86FullDiagID::SemaUnusedFunction,
X86FullDiagID::SemaUninitializedVariable,
X86FullDiagID::SemaPotentiallyUninitialized,
X86FullDiagID::SemaOverflow,
X86FullDiagID::SemaReturnIncompatible,
X86FullDiagID::SemaNonVoidMissingReturn,
X86FullDiagID::SemaUnreachableCode,
X86FullDiagID::SemaAddressOfTemporary,
X86FullDiagID::SemaShiftByNegative,
X86FullDiagID::SemaShiftExceedsWidth,
X86FullDiagID::SemaNullDereference,
X86FullDiagID::SemaDivisionByZero,
X86FullDiagID::SemaIncompatiblePointerTypes,
X86FullDiagID::SemaAssignmentIncompatible,
X86FullDiagID::ParseImplicitDeclaration,
X86FullDiagID::ParseMissingSemicolon,
X86FullDiagID::ParseDanglingElse,
X86FullDiagID::PPMacroRedefined,
X86FullDiagID::PPExtraTokensAtEndOfDirective,
X86FullDiagID::PPWrongNumberOfMacroArgs,
X86FullDiagID::LexInvalidEscapeSequence,
X86FullDiagID::LexTrigraphWarning,
X86FullDiagID::SecFormatString,
X86FullDiagID::SecFormatStringSecurity,
X86FullDiagID::SecNullDereference,
X86FullDiagID::SecDivisionByZero,
X86FullDiagID::SecIntegerOverflow,
],
});
self.add_group(X86DiagGroup {
name: "extra".to_string(),
enabled_by_default: false,
description: "Enable extra warnings (-Wextra)".to_string(),
sub_groups: vec!["all".to_string()],
members: vec![
X86FullDiagID::SemaOverflow,
X86FullDiagID::SemaConversionError,
X86FullDiagID::SemaUnusedVariable,
X86FullDiagID::SemaFloatToIntOverflow,
X86FullDiagID::SemaIntToFloatPrecisionLoss,
X86FullDiagID::SemaEnumValueOverflow,
X86FullDiagID::SemaUnreachableCode,
X86FullDiagID::CXXMissingOverride,
X86FullDiagID::CXXOverloadAmbiguity,
X86FullDiagID::CXXLambdaCaptureDefault,
X86FullDiagID::ParseExtraneousToken,
X86FullDiagID::ParseOldStyleDefinition,
X86FullDiagID::PPUndefOfBuiltin,
X86FullDiagID::LexMissingNewlineAtEOF,
X86FullDiagID::LexNonASCIIIdentifier,
X86FullDiagID::SecImplicitConversion,
X86FullDiagID::SecSignedToUnsigned,
X86FullDiagID::SecTruncation,
],
});
self.add_group(X86DiagGroup {
name: "pedantic".to_string(),
enabled_by_default: false,
description: "Enable pedantic warnings (-Wpedantic)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::LexHexFloatLiteral,
X86FullDiagID::LexBinaryLiteral,
X86FullDiagID::LexComplexLiteral,
X86FullDiagID::LexImaginaryLiteral,
X86FullDiagID::LexAlternativeToken,
X86FullDiagID::PPGNUVariadicMacro,
X86FullDiagID::PPC99VariadicMacro,
X86FullDiagID::ParseGNUStatementExpression,
X86FullDiagID::ParseGNULocalLabel,
X86FullDiagID::ParseGNUConditionalOmittedOperand,
X86FullDiagID::ParseGNUDesignator,
X86FullDiagID::ParseGNUAttribute,
X86FullDiagID::ParseKandRParameters,
X86FullDiagID::ParseOldStyleDefinition,
X86FullDiagID::SemaGCCExtension,
X86FullDiagID::SemaZeroSizeArray,
X86FullDiagID::SemaEnumForwardDeclaration,
X86FullDiagID::CXXLambdaGeneric,
X86FullDiagID::CXXLambdaCaptureInit,
X86FullDiagID::CXXFoldExpression,
],
});
self.add_group(X86DiagGroup {
name: "conversion".to_string(),
enabled_by_default: false,
description: "Warn about implicit conversions (-Wconversion)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SemaConversionError,
X86FullDiagID::SemaFloatToIntOverflow,
X86FullDiagID::SemaIntToFloatPrecisionLoss,
X86FullDiagID::SemaConversionError,
X86FullDiagID::SemaOverflow,
X86FullDiagID::SemaSignedOverflow,
X86FullDiagID::SecImplicitConversion,
X86FullDiagID::SecSignedToUnsigned,
X86FullDiagID::SecTruncation,
X86FullDiagID::SecSignExtension,
],
});
self.add_group(X86DiagGroup {
name: "sign-conversion".to_string(),
enabled_by_default: false,
description: "Warn about implicit sign conversions (-Wsign-conversion)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SemaIncompatibleTypes,
X86FullDiagID::SemaConversionError,
X86FullDiagID::SecSignedToUnsigned,
X86FullDiagID::SecSignExtension,
],
});
self.add_group(X86DiagGroup {
name: "shadow".to_string(),
enabled_by_default: false,
description: "Warn about variable shadowing (-Wshadow)".to_string(),
sub_groups: vec![],
members: vec![X86FullDiagID::CXXUsingShadow],
});
self.add_group(X86DiagGroup {
name: "unused".to_string(),
enabled_by_default: false,
description: "Warn about unused entities (-Wunused)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SemaUnusedVariable,
X86FullDiagID::SemaUnusedParameter,
X86FullDiagID::SemaUnusedFunction,
X86FullDiagID::PPMacroArgUnused,
],
});
self.add_group(X86DiagGroup {
name: "format".to_string(),
enabled_by_default: false,
description: "Warn about format string issues (-Wformat)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SecFormatString,
X86FullDiagID::SecFormatStringOverflow,
X86FullDiagID::SecFormatStringNoArgs,
X86FullDiagID::SecFormatStringExtraArgs,
X86FullDiagID::SecFormatStringMismatch,
X86FullDiagID::SecFormatStringSecurity,
X86FullDiagID::SecFormatStringNonLiteral,
X86FullDiagID::SecFormatStringPositional,
X86FullDiagID::SecFormatTruncation,
],
});
self.add_group(X86DiagGroup {
name: "implicit-fallthrough".to_string(),
enabled_by_default: false,
description: "Warn about implicit fallthrough in switch (-Wimplicit-fallthrough)"
.to_string(),
sub_groups: vec![],
members: vec![X86FullDiagID::SemaDuplicateCase],
});
self.add_group(X86DiagGroup {
name: "strict-aliasing".to_string(),
enabled_by_default: false,
description: "Warn about strict-aliasing rule violations (-Wstrict-aliasing)"
.to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SemaStrictAliasingViolation,
X86FullDiagID::SemaTypePunningViaCast,
X86FullDiagID::SemaTypePunningViaUnion,
X86FullDiagID::SecStrictAliasing,
X86FullDiagID::SecTypePunning,
],
});
self.add_group(X86DiagGroup {
name: "strict-overflow".to_string(),
enabled_by_default: false,
description: "Warn about strict overflow assumptions (-Wstrict-overflow)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SemaSignedOverflow,
X86FullDiagID::SemaOverflow,
X86FullDiagID::SecIntegerOverflow,
],
});
self.add_group(X86DiagGroup {
name: "null-dereference".to_string(),
enabled_by_default: false,
description: "Warn about potential null pointer dereferences (-Wnull-dereference)"
.to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SemaNullDereference,
X86FullDiagID::SemaNonNullParamNull,
X86FullDiagID::SemaNullPassedToNonNull,
X86FullDiagID::SecNullDereference,
X86FullDiagID::SecNullDereferenceUnlikely,
],
});
self.add_group(X86DiagGroup {
name: "return-type".to_string(),
enabled_by_default: true,
description: "Warn about return type issues (-Wreturn-type)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SemaNonVoidMissingReturn,
X86FullDiagID::SemaReturnIncompatible,
X86FullDiagID::SemaVoidFuncReturningValue,
X86FullDiagID::SemaReturnStackAddress,
X86FullDiagID::SemaReturnLocalAddress,
],
});
self.add_group(X86DiagGroup {
name: "unknown-pragmas".to_string(),
enabled_by_default: true,
description: "Warn about unknown pragmas (-Wunknown-pragmas)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::LexUnknownPragma,
X86FullDiagID::PPPragmaUnused,
],
});
self.add_group(X86DiagGroup {
name: "unknown-attributes".to_string(),
enabled_by_default: true,
description: "Warn about unknown attributes (-Wunknown-attributes)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::SemaUnknownAttribute,
X86FullDiagID::SemaAttributeIgnored,
X86FullDiagID::SemaGNUAttributeIgnored,
],
});
self.add_group(X86DiagGroup {
name: "newline-eof".to_string(),
enabled_by_default: false,
description: "Warn about missing newline at end of file (-Wnewline-eof)".to_string(),
sub_groups: vec![],
members: vec![X86FullDiagID::LexMissingNewlineAtEOF],
});
self.add_group(X86DiagGroup {
name: "target-feature".to_string(),
enabled_by_default: true,
description: "Warn about target feature requirements (-Wtarget-feature)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::X86FeatureSSE,
X86FullDiagID::X86FeatureSSE2,
X86FullDiagID::X86FeatureSSE3,
X86FullDiagID::X86FeatureSSSE3,
X86FullDiagID::X86FeatureSSE41,
X86FullDiagID::X86FeatureSSE42,
X86FullDiagID::X86FeatureAVX,
X86FullDiagID::X86FeatureAVX2,
X86FullDiagID::X86FeatureAVX512F,
X86FullDiagID::X86FeatureAVX512BW,
X86FullDiagID::X86FeatureAVX512DQ,
X86FullDiagID::X86FeatureAVX512VL,
X86FullDiagID::X86FeatureAVX512BF16,
X86FullDiagID::X86FeatureAVX512FP16,
X86FullDiagID::X86FeatureAVX512VBMI,
X86FullDiagID::X86FeatureAVX512VBMI2,
X86FullDiagID::X86FeatureAVX512VNNI,
X86FullDiagID::X86FeatureAVX512BITALG,
X86FullDiagID::X86FeatureAVX512VPOPCNTDQ,
X86FullDiagID::X86FeatureAVX10_1_256,
X86FullDiagID::X86FeatureAVX10_1_512,
X86FullDiagID::X86FeatureAVX10_2,
X86FullDiagID::X86FeatureFMA,
X86FullDiagID::X86FeatureFMA4,
X86FullDiagID::X86FeatureF16C,
X86FullDiagID::X86FeatureMMX,
X86FullDiagID::X86FeatureAES,
X86FullDiagID::X86FeaturePCLMUL,
X86FullDiagID::X86FeatureSHA,
X86FullDiagID::X86FeatureRDRAND,
X86FullDiagID::X86FeatureRDSEED,
X86FullDiagID::X86FeatureBMI,
X86FullDiagID::X86FeatureBMI2,
X86FullDiagID::X86FeatureLZCNT,
X86FullDiagID::X86FeaturePOPCNT,
X86FullDiagID::X86FeatureAMX_BF16,
X86FullDiagID::X86FeatureAMX_INT8,
X86FullDiagID::X86FeatureAMX_TILE,
X86FullDiagID::X86FeatureAMX_FP16,
X86FullDiagID::X86FeatureAMX_COMPLEX,
],
});
self.add_group(X86DiagGroup {
name: "abi-x86".to_string(),
enabled_by_default: false,
description: "Warn about x86 ABI compatibility issues (-Wabi-x86)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::X86ABIViolation,
X86FullDiagID::X86ABIStructTooLarge,
X86FullDiagID::X86ABIHiddenPointerReturn,
X86FullDiagID::X86ABIRedZoneViolation,
X86FullDiagID::X86ABIStackAlignmentViolation,
X86FullDiagID::X86ABIVectorcallAlignment,
X86FullDiagID::X86ABIFastcallTooManyArgs,
X86FullDiagID::X86ABIThiscallNonMember,
X86FullDiagID::X86ABIStdCallVarArgs,
X86FullDiagID::X86ABIRegCallNotEnoughRegs,
X86FullDiagID::X86ABISysVClassificationFailed,
X86FullDiagID::X86ABIMicrosoftClassificationFailed,
X86FullDiagID::X86ABIRegCallClassificationFailed,
X86FullDiagID::X86ABIEmptyStructPass,
X86FullDiagID::X86ABIPackedStructPass,
X86FullDiagID::X86ABIBitfieldStraddle,
X86FullDiagID::X86ABIComplexReturn,
X86FullDiagID::X86ABIX87Return,
],
});
self.add_group(X86DiagGroup {
name: "vector-x86".to_string(),
enabled_by_default: false,
description: "Warn about x86 vector operation issues (-Wvector-x86)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::X86VectorWidthMismatch,
X86FullDiagID::X86VectorShuffleInvalid,
X86FullDiagID::X86VectorGatherAlign,
X86FullDiagID::X86VectorMaskMissing,
X86FullDiagID::X86VectorTypeNotSupported,
],
});
self.add_group(X86DiagGroup {
name: "alignment-x86".to_string(),
enabled_by_default: false,
description: "Warn about x86 alignment issues (-Walignment-x86)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::X86AlignmentNone,
X86FullDiagID::X86AlignmentUnaligned,
X86FullDiagID::SemaAlignmentMismatch,
X86FullDiagID::SemaCastAlignDown,
X86FullDiagID::SemaCastAlignUp,
X86FullDiagID::SecAlignmentViolation,
X86FullDiagID::SecCastAlign,
X86FullDiagID::SecCastAlignDown,
],
});
self.add_group(X86DiagGroup {
name: "inline-asm-x86".to_string(),
enabled_by_default: true,
description: "Warn about x86 inline assembly issues (-Winline-asm-x86)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::X86InlineASMInvalidInstruction,
X86FullDiagID::X86InlineASMInvalidConstraint,
X86FullDiagID::X86InlineASMClobberConflict,
X86FullDiagID::X86InlineASMTooManyOperands,
X86FullDiagID::X86InlineASMGlobalRegister,
],
});
self.add_group(X86DiagGroup {
name: "stack-size-x86".to_string(),
enabled_by_default: false,
description: "Warn about large stack frames on x86 (-Wstack-size-x86)".to_string(),
sub_groups: vec![],
members: vec![
X86FullDiagID::X86StackSize,
X86FullDiagID::X86RedZoneViolation,
X86FullDiagID::X86NopPadding,
],
});
}
fn add_group(&mut self, group: X86DiagGroup) {
self.groups.insert(group.name.clone(), group);
}
pub fn resolve_group(&self, name: &str) -> Vec<X86FullDiagID> {
let mut result = Vec::new();
let mut visited = HashSet::new();
self.resolve_group_recursive(name, &mut result, &mut visited);
result
}
fn resolve_group_recursive(
&self,
name: &str,
result: &mut Vec<X86FullDiagID>,
visited: &mut HashSet<String>,
) {
if visited.contains(name) {
return;
}
visited.insert(name.to_string());
if let Some(group) = self.groups.get(name) {
for sub in &group.sub_groups {
self.resolve_group_recursive(sub, result, visited);
}
result.extend(&group.members);
}
}
pub fn has_group(&self, name: &str) -> bool {
self.groups.contains_key(name)
}
pub fn group_names(&self) -> Vec<&str> {
self.groups.keys().map(|s| s.as_str()).collect()
}
pub fn get_group(&self, name: &str) -> Option<&X86DiagGroup> {
self.groups.get(name)
}
pub fn is_in_group(&self, id: X86FullDiagID, group_name: &str) -> bool {
let members = self.resolve_group(group_name);
members.contains(&id)
}
pub fn enable_group(&self, id: X86FullDiagID, group_name: &str) -> Option<DiagSeverity> {
if self.is_in_group(id, group_name) {
Some(X86DiagnosticCatalog::default_severity(id))
} else {
None
}
}
pub fn len(&self) -> usize {
self.groups.len()
}
pub fn is_empty(&self) -> bool {
self.groups.is_empty()
}
}
impl Default for X86DiagnosticGroups {
fn default() -> Self {
Self::new()
}
}
pub trait X86DiagnosticConsumer {
fn begin_diagnostic(&mut self, id: X86FullDiagID, severity: DiagSeverity);
fn end_diagnostic(&mut self);
fn handle_note(&mut self, message: &str, location: &ClangSourceLocation);
fn handle_fixit(&mut self, fixit: &FixItHint);
fn handle_range(&mut self, range: &SourceRange);
fn flush(&mut self);
fn error_count(&self) -> usize;
fn warning_count(&self) -> usize;
fn clear(&mut self);
}
pub struct X86TextDiagnosticPrinter<W: Write> {
pub writer: W,
pub renderer: X86DiagnosticRenderer,
pub error_count: usize,
pub warning_count: usize,
pub note_count: usize,
current_id: Option<X86FullDiagID>,
current_severity: Option<DiagSeverity>,
current_message: Option<String>,
current_location: Option<ClangSourceLocation>,
current_ranges: Vec<SourceRange>,
current_fixits: Vec<FixItHint>,
current_notes: Vec<String>,
}
impl<W: Write> X86TextDiagnosticPrinter<W> {
pub fn new(writer: W) -> Self {
Self {
writer,
renderer: X86DiagnosticRenderer::new(),
error_count: 0,
warning_count: 0,
note_count: 0,
current_id: None,
current_severity: None,
current_message: None,
current_location: None,
current_ranges: Vec::new(),
current_fixits: Vec::new(),
current_notes: Vec::new(),
}
}
pub fn with_renderer(mut self, renderer: X86DiagnosticRenderer) -> Self {
self.renderer = renderer;
self
}
pub fn emit(
&mut self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
ranges: &[SourceRange],
fixits: &[FixItHint],
notes: &[String],
) -> io::Result<()> {
match severity {
DiagSeverity::Error | DiagSeverity::Fatal => self.error_count += 1,
DiagSeverity::Warning => self.warning_count += 1,
DiagSeverity::Note => self.note_count += 1,
_ => {}
}
let output = self
.renderer
.render(id, severity, message, location, ranges, fixits, notes);
self.writer.write_all(output.as_bytes())?;
self.writer.flush()
}
}
impl<W: Write> X86DiagnosticConsumer for X86TextDiagnosticPrinter<W> {
fn begin_diagnostic(&mut self, id: X86FullDiagID, severity: DiagSeverity) {
self.current_id = Some(id);
self.current_severity = Some(severity);
}
fn end_diagnostic(&mut self) {
if let (Some(id), Some(sev)) = (self.current_id, self.current_severity) {
let msg = self.current_message.as_deref().unwrap_or("");
let loc = self
.current_location
.as_ref()
.unwrap_or(&ClangSourceLocation::invalid());
let _ = self.emit(
id,
sev,
msg,
loc,
&self.current_ranges,
&self.current_fixits,
&self.current_notes,
);
}
self.current_id = None;
self.current_severity = None;
self.current_message = None;
self.current_location = None;
self.current_ranges.clear();
self.current_fixits.clear();
self.current_notes.clear();
}
fn handle_note(&mut self, message: &str, _location: &ClangSourceLocation) {
self.current_notes.push(message.to_string());
}
fn handle_fixit(&mut self, fixit: &FixItHint) {
self.current_fixits.push(FixItHint {
remove_range: fixit.remove_range.clone(),
code: fixit.code.clone(),
is_insertion: fixit.is_insertion,
});
}
fn handle_range(&mut self, range: &SourceRange) {
self.current_ranges.push(SourceRange {
begin: range.begin.clone(),
end: range.end.clone(),
});
}
fn flush(&mut self) {
let _ = self.writer.flush();
}
fn error_count(&self) -> usize {
self.error_count
}
fn warning_count(&self) -> usize {
self.warning_count
}
fn clear(&mut self) {
self.error_count = 0;
self.warning_count = 0;
self.note_count = 0;
}
}
pub struct JSONDiagnosticConsumer<W: Write> {
pub writer: W,
pub error_count: usize,
pub warning_count: usize,
pub compact: bool,
first: bool,
}
impl<W: Write> JSONDiagnosticConsumer<W> {
pub fn new(writer: W) -> Self {
Self {
writer,
error_count: 0,
warning_count: 0,
compact: false,
first: true,
}
}
pub fn compact(mut self, compact: bool) -> Self {
self.compact = compact;
self
}
}
impl<W: Write> X86DiagnosticConsumer for JSONDiagnosticConsumer<W> {
fn begin_diagnostic(&mut self, _id: X86FullDiagID, severity: DiagSeverity) {
match severity {
DiagSeverity::Error | DiagSeverity::Fatal => self.error_count += 1,
DiagSeverity::Warning => self.warning_count += 1,
_ => {}
}
}
fn end_diagnostic(&mut self) {
}
fn handle_note(&mut self, _message: &str, _location: &ClangSourceLocation) {}
fn handle_fixit(&mut self, _fixit: &FixItHint) {}
fn handle_range(&mut self, _range: &SourceRange) {}
fn flush(&mut self) {
let _ = self.writer.flush();
}
fn error_count(&self) -> usize {
self.error_count
}
fn warning_count(&self) -> usize {
self.warning_count
}
fn clear(&mut self) {
self.error_count = 0;
self.warning_count = 0;
}
}
pub struct SARIFDiagnosticConsumer<W: Write> {
pub writer: W,
pub error_count: usize,
pub warning_count: usize,
pub tool_name: String,
pub tool_version: String,
results: Vec<String>,
}
impl<W: Write> SARIFDiagnosticConsumer<W> {
pub fn new(writer: W) -> Self {
Self {
writer,
error_count: 0,
warning_count: 0,
tool_name: "clang-llvm-native-x86".to_string(),
tool_version: "1.0.0".to_string(),
results: Vec::new(),
}
}
pub fn with_tool_info(mut self, name: &str, version: &str) -> Self {
self.tool_name = name.to_string();
self.tool_version = version.to_string();
self
}
pub fn add_result(&mut self, sarif_record: String) {
self.results.push(sarif_record);
}
pub fn finalize(&mut self) -> io::Result<()> {
let results_json = self.results.join(",\n ");
let sarif = format!(
r#"{{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[{{"tool":{{"driver":{{"name":"{}","version":"{}"}}}},"results":[{}]}}]}}"#,
self.tool_name, self.tool_version, results_json
);
self.writer.write_all(sarif.as_bytes())?;
self.writer.write_all(b"\n")?;
self.writer.flush()
}
}
impl<W: Write> X86DiagnosticConsumer for SARIFDiagnosticConsumer<W> {
fn begin_diagnostic(&mut self, _id: X86FullDiagID, severity: DiagSeverity) {
match severity {
DiagSeverity::Error | DiagSeverity::Fatal => self.error_count += 1,
DiagSeverity::Warning => self.warning_count += 1,
_ => {}
}
}
fn end_diagnostic(&mut self) {}
fn handle_note(&mut self, _message: &str, _location: &ClangSourceLocation) {}
fn handle_fixit(&mut self, _fixit: &FixItHint) {}
fn handle_range(&mut self, _range: &SourceRange) {}
fn flush(&mut self) {
let _ = self.finalize();
}
fn error_count(&self) -> usize {
self.error_count
}
fn warning_count(&self) -> usize {
self.warning_count
}
fn clear(&mut self) {
self.error_count = 0;
self.warning_count = 0;
self.results.clear();
}
}
pub struct CountingDiagnosticConsumer<C: X86DiagnosticConsumer> {
inner: C,
pub warnings_as_errors: bool,
pub error_limit: Option<usize>,
upgraded: HashMap<X86FullDiagID, DiagSeverity>,
}
impl<C: X86DiagnosticConsumer> CountingDiagnosticConsumer<C> {
pub fn new(inner: C) -> Self {
Self {
inner,
warnings_as_errors: false,
error_limit: None,
upgraded: HashMap::new(),
}
}
pub fn with_warnings_as_errors(mut self, enable: bool) -> Self {
self.warnings_as_errors = enable;
self
}
pub fn with_error_limit(mut self, limit: usize) -> Self {
self.error_limit = Some(limit);
self
}
pub fn promote_to_error(&mut self, id: X86FullDiagID) {
self.upgraded.insert(id, DiagSeverity::Error);
}
pub fn demote_to_warning(&mut self, id: X86FullDiagID) {
self.upgraded.insert(id, DiagSeverity::Warning);
}
pub fn suppress(&mut self, id: X86FullDiagID) {
self.upgraded.insert(id, DiagSeverity::Ignored);
}
pub fn effective_severity(&self, id: X86FullDiagID, default: DiagSeverity) -> DiagSeverity {
if let Some(&sev) = self.upgraded.get(&id) {
return sev;
}
if self.warnings_as_errors && default == DiagSeverity::Warning {
return DiagSeverity::Error;
}
default
}
pub fn error_limit_reached(&self) -> bool {
if let Some(limit) = self.error_limit {
self.inner.error_count() >= limit
} else {
false
}
}
}
impl<C: X86DiagnosticConsumer> X86DiagnosticConsumer for CountingDiagnosticConsumer<C> {
fn begin_diagnostic(&mut self, id: X86FullDiagID, severity: DiagSeverity) {
let effective = self.effective_severity(id, severity);
self.inner.begin_diagnostic(id, effective);
}
fn end_diagnostic(&mut self) {
self.inner.end_diagnostic();
}
fn handle_note(&mut self, msg: &str, loc: &ClangSourceLocation) {
self.inner.handle_note(msg, loc);
}
fn handle_fixit(&mut self, fixit: &FixItHint) {
self.inner.handle_fixit(fixit);
}
fn handle_range(&mut self, range: &SourceRange) {
self.inner.handle_range(range);
}
fn flush(&mut self) {
self.inner.flush();
}
fn error_count(&self) -> usize {
self.inner.error_count()
}
fn warning_count(&self) -> usize {
self.inner.warning_count()
}
fn clear(&mut self) {
self.inner.clear();
}
}
pub struct FilteringDiagnosticConsumer<C: X86DiagnosticConsumer, F>
where
F: Fn(X86FullDiagID, DiagSeverity, &ClangSourceLocation) -> bool,
{
inner: C,
predicate: F,
allowed_files: HashSet<String>,
blocked_files: HashSet<String>,
allowed_categories: HashSet<String>,
blocked_categories: HashSet<String>,
min_severity: Option<DiagSeverity>,
suppressed_count: usize,
}
impl<
C: X86DiagnosticConsumer,
F: Fn(X86FullDiagID, DiagSeverity, &ClangSourceLocation) -> bool,
> FilteringDiagnosticConsumer<C, F>
{
pub fn new(inner: C, predicate: F) -> Self {
Self {
inner,
predicate,
allowed_files: HashSet::new(),
blocked_files: HashSet::new(),
allowed_categories: HashSet::new(),
blocked_categories: HashSet::new(),
min_severity: None,
suppressed_count: 0,
}
}
pub fn allow_file(&mut self, file: &str) {
self.allowed_files.insert(file.to_string());
}
pub fn block_file(&mut self, file: &str) {
self.blocked_files.insert(file.to_string());
}
pub fn allow_category(&mut self, category: &str) {
self.allowed_categories.insert(category.to_string());
}
pub fn block_category(&mut self, category: &str) {
self.blocked_categories.insert(category.to_string());
}
pub fn set_min_severity(&mut self, severity: DiagSeverity) {
self.min_severity = Some(severity);
}
fn is_allowed(
&self,
id: X86FullDiagID,
severity: DiagSeverity,
location: &ClangSourceLocation,
) -> bool {
if !self.allowed_files.is_empty() && !self.allowed_files.contains(&location.file) {
return false;
}
if self.blocked_files.contains(&location.file) {
return false;
}
let category = X86DiagnosticCatalog::category(id);
if !self.allowed_categories.is_empty() && !self.allowed_categories.contains(category) {
return false;
}
if self.blocked_categories.contains(category) {
return false;
}
if let Some(min) = &self.min_severity {
if severity_level(severity) < severity_level(*min) {
return false;
}
}
(self.predicate)(id, severity, location)
}
pub fn suppressed_count(&self) -> usize {
self.suppressed_count
}
}
fn severity_level(s: DiagSeverity) -> u8 {
match s {
DiagSeverity::Ignored => 0,
DiagSeverity::Remark => 1,
DiagSeverity::Note => 2,
DiagSeverity::Warning => 3,
DiagSeverity::Error => 4,
DiagSeverity::Fatal => 5,
}
}
impl<
C: X86DiagnosticConsumer,
F: Fn(X86FullDiagID, DiagSeverity, &ClangSourceLocation) -> bool,
> X86DiagnosticConsumer for FilteringDiagnosticConsumer<C, F>
{
fn begin_diagnostic(&mut self, id: X86FullDiagID, severity: DiagSeverity) {
self.inner.begin_diagnostic(id, severity);
}
fn end_diagnostic(&mut self) {
self.inner.end_diagnostic();
}
fn handle_note(&mut self, msg: &str, loc: &ClangSourceLocation) {
self.inner.handle_note(msg, loc);
}
fn handle_fixit(&mut self, fixit: &FixItHint) {
self.inner.handle_fixit(fixit);
}
fn handle_range(&mut self, range: &SourceRange) {
self.inner.handle_range(range);
}
fn flush(&mut self) {
self.inner.flush();
}
fn error_count(&self) -> usize {
self.inner.error_count()
}
fn warning_count(&self) -> usize {
self.inner.warning_count()
}
fn clear(&mut self) {
self.inner.clear();
self.suppressed_count = 0;
}
}
pub struct ChainedDiagnosticConsumer<C: X86DiagnosticConsumer> {
consumers: Vec<C>,
}
impl<C: X86DiagnosticConsumer> ChainedDiagnosticConsumer<C> {
pub fn new() -> Self {
Self {
consumers: Vec::new(),
}
}
pub fn add(&mut self, consumer: C) {
self.consumers.push(consumer);
}
pub fn len(&self) -> usize {
self.consumers.len()
}
pub fn is_empty(&self) -> bool {
self.consumers.is_empty()
}
}
impl<C: X86DiagnosticConsumer> Default for ChainedDiagnosticConsumer<C> {
fn default() -> Self {
Self::new()
}
}
impl<C: X86DiagnosticConsumer> X86DiagnosticConsumer for ChainedDiagnosticConsumer<C> {
fn begin_diagnostic(&mut self, id: X86FullDiagID, severity: DiagSeverity) {
for c in &mut self.consumers {
c.begin_diagnostic(id, severity);
}
}
fn end_diagnostic(&mut self) {
for c in &mut self.consumers {
c.end_diagnostic();
}
}
fn handle_note(&mut self, msg: &str, loc: &ClangSourceLocation) {
for c in &mut self.consumers {
c.handle_note(msg, loc);
}
}
fn handle_fixit(&mut self, fixit: &FixItHint) {
for c in &mut self.consumers {
c.handle_fixit(fixit);
}
}
fn handle_range(&mut self, range: &SourceRange) {
for c in &mut self.consumers {
c.handle_range(range);
}
}
fn flush(&mut self) {
for c in &mut self.consumers {
c.flush();
}
}
fn error_count(&self) -> usize {
self.consumers
.iter()
.map(|c| c.error_count())
.max()
.unwrap_or(0)
}
fn warning_count(&self) -> usize {
self.consumers
.iter()
.map(|c| c.warning_count())
.max()
.unwrap_or(0)
}
fn clear(&mut self) {
for c in &mut self.consumers {
c.clear();
}
}
}
pub struct X86DiagnosticEngine<W: Write> {
pub groups: X86DiagnosticGroups,
pub renderer: X86DiagnosticRenderer,
pub printer: X86TextDiagnosticPrinter<W>,
pub warnings_as_errors: bool,
pub error_limit: Option<usize>,
pub suppress_all: bool,
enabled_ids: HashSet<X86FullDiagID>,
disabled_ids: HashSet<X86FullDiagID>,
severity_overrides: HashMap<X86FullDiagID, DiagSeverity>,
}
impl<W: Write> X86DiagnosticEngine<W> {
pub fn new(writer: W) -> Self {
Self {
groups: X86DiagnosticGroups::new(),
renderer: X86DiagnosticRenderer::new(),
printer: X86TextDiagnosticPrinter::new(writer),
warnings_as_errors: false,
error_limit: Some(20),
suppress_all: false,
enabled_ids: HashSet::new(),
disabled_ids: HashSet::new(),
severity_overrides: HashMap::new(),
}
}
pub fn with_warnings_as_errors(mut self, enable: bool) -> Self {
self.warnings_as_errors = enable;
self
}
pub fn with_error_limit(mut self, limit: usize) -> Self {
self.error_limit = Some(limit);
self
}
pub fn enable_warning(&mut self, id: X86FullDiagID) {
self.enabled_ids.insert(id);
self.disabled_ids.remove(&id);
}
pub fn disable_warning(&mut self, id: X86FullDiagID) {
self.disabled_ids.insert(id);
self.enabled_ids.remove(&id);
}
pub fn set_severity(&mut self, id: X86FullDiagID, severity: DiagSeverity) {
self.severity_overrides.insert(id, severity);
}
pub fn enable_group(&mut self, group_name: &str) {
for id in self.groups.resolve_group(group_name) {
self.enable_warning(id);
}
}
pub fn disable_group(&mut self, group_name: &str) {
for id in self.groups.resolve_group(group_name) {
self.disable_warning(id);
}
}
pub fn enable_all_warnings(&mut self) {
for id in X86DiagnosticCatalog::all_ids() {
self.enable_warning(id);
}
}
pub fn get_effective_severity(&self, id: X86FullDiagID) -> DiagSeverity {
if self.suppress_all {
return DiagSeverity::Ignored;
}
if let Some(&sev) = self.severity_overrides.get(&id) {
return sev;
}
let default = X86DiagnosticCatalog::default_severity(id);
if self.disabled_ids.contains(&id) {
return DiagSeverity::Ignored;
}
let severity = if !self.enabled_ids.is_empty() && !self.enabled_ids.contains(&id) {
DiagSeverity::Ignored
} else {
default
};
if self.warnings_as_errors && severity == DiagSeverity::Warning {
DiagSeverity::Error
} else {
severity
}
}
pub fn emit(
&mut self,
id: X86FullDiagID,
message: &str,
location: &ClangSourceLocation,
ranges: &[SourceRange],
fixits: &[FixItHint],
notes: &[String],
) -> io::Result<()> {
let severity = self.get_effective_severity(id);
if severity == DiagSeverity::Ignored {
return Ok(());
}
self.printer
.emit(id, severity, message, location, ranges, fixits, notes)
}
pub fn has_errors(&self) -> bool {
self.printer.error_count() > 0
}
pub fn has_warnings(&self) -> bool {
self.printer.warning_count() > 0
}
pub fn error_count(&self) -> usize {
self.printer.error_count()
}
pub fn warning_count(&self) -> usize {
self.printer.warning_count()
}
pub fn reset(&mut self) {
self.printer.clear();
self.enabled_ids.clear();
self.disabled_ids.clear();
self.severity_overrides.clear();
}
}
pub fn make_x86_diagnostic_engine() -> X86DiagnosticEngine<Vec<u8>> {
X86DiagnosticEngine::new(Vec::new())
}
pub fn x86_get_message(id: X86FullDiagID) -> &'static str {
X86DiagnosticCatalog::message_for(id)
}
pub fn x86_get_severity(id: X86FullDiagID) -> DiagSeverity {
X86DiagnosticCatalog::default_severity(id)
}
pub fn x86_get_flag(id: X86FullDiagID) -> &'static str {
X86DiagnosticCatalog::flag_name(id)
}
pub fn x86_get_category(id: X86FullDiagID) -> &'static str {
X86DiagnosticCatalog::category(id)
}
pub fn x86_location(file: &str, line: u32, col: u32) -> ClangSourceLocation {
use std::path::Path;
ClangSourceLocation::new(Path::new(file), line, col)
}
pub fn x86_invalid_location() -> ClangSourceLocation {
ClangSourceLocation::invalid()
}
pub struct X86DiagnosticEmitter<W: Write> {
pub engine: X86DiagnosticEngine<W>,
pub source_cache: HashMap<String, String>,
pub show_notes: bool,
pub show_ranges: bool,
pub show_fixits: bool,
pub max_errors: usize,
emitted_errors: usize,
}
impl<W: Write> X86DiagnosticEmitter<W> {
pub fn new(writer: W) -> Self {
Self {
engine: X86DiagnosticEngine::new(writer),
source_cache: HashMap::new(),
show_notes: true,
show_ranges: true,
show_fixits: true,
max_errors: 20,
emitted_errors: 0,
}
}
pub fn register_source(&mut self, filename: &str, content: &str) {
self.source_cache
.insert(filename.to_string(), content.to_string());
self.engine.renderer.register_source(filename, content);
}
pub fn emit(
&mut self,
id: X86FullDiagID,
location: &ClangSourceLocation,
args: &[&str],
) -> io::Result<()> {
if self.emitted_errors >= self.max_errors {
return Ok(());
}
let severity = self.engine.get_effective_severity(id);
if severity == DiagSeverity::Ignored {
return Ok(());
}
let mut msg = X86DiagnosticCatalog::message_for(id).to_string();
for arg in args {
msg = msg.replacen("{}", arg, 1);
}
if severity == DiagSeverity::Error || severity == DiagSeverity::Fatal {
self.emitted_errors += 1;
}
self.engine.emit(id, &msg, location, &[], &[], &[])
}
pub fn warn(
&mut self,
id: X86FullDiagID,
location: &ClangSourceLocation,
arg: &str,
) -> io::Result<()> {
self.emit(id, location, &[arg])
}
pub fn error(
&mut self,
id: X86FullDiagID,
location: &ClangSourceLocation,
arg: &str,
) -> io::Result<()> {
self.emit(id, location, &[arg])
}
pub fn fatal(
&mut self,
id: X86FullDiagID,
location: &ClangSourceLocation,
arg: &str,
) -> io::Result<()> {
self.emit(id, location, &[arg])
}
pub fn note(&mut self, message: &str, location: &ClangSourceLocation) {
if self.show_notes {
self.engine.printer.handle_note(message, location);
}
}
pub fn fixit(&mut self, code: &str, location: &ClangSourceLocation, is_insertion: bool) {
if self.show_fixits {
let fixit = FixItHint {
remove_range: SourceRange::point(location.clone()),
code: code.to_string(),
is_insertion,
};
self.engine.printer.handle_fixit(&fixit);
}
}
pub fn error_limit_reached(&self) -> bool {
self.emitted_errors >= self.max_errors
}
pub fn total_errors(&self) -> usize {
self.engine.error_count()
}
pub fn total_warnings(&self) -> usize {
self.engine.warning_count()
}
pub fn reset(&mut self) {
self.engine.reset();
self.emitted_errors = 0;
}
pub fn flush(&mut self) -> io::Result<()> {
self.engine.printer.flush();
Ok(())
}
pub fn into_output(self) -> Vec<u8>
where
W: AsRef<[u8]>,
{
Vec::new()
}
}
pub struct X86FixItEngine;
impl X86FixItEngine {
pub fn insert_semicolon(loc: &ClangSourceLocation) -> FixItHint {
FixItHint::insertion(loc.clone(), ";")
}
pub fn insert_closing_brace(loc: &ClangSourceLocation) -> FixItHint {
FixItHint::insertion(loc.clone(), "}")
}
pub fn insert_closing_paren(loc: &ClangSourceLocation) -> FixItHint {
FixItHint::insertion(loc.clone(), ")")
}
pub fn insert_closing_bracket(loc: &ClangSourceLocation) -> FixItHint {
FixItHint::insertion(loc.clone(), "]")
}
pub fn replace(range: SourceRange, new_text: &str) -> FixItHint {
FixItHint::replacement(range, &new_text.to_string())
}
pub fn remove(range: SourceRange) -> FixItHint {
FixItHint::removal(range)
}
pub fn insert_include(loc: &ClangSourceLocation, header: &str) -> FixItHint {
FixItHint::insertion(loc.clone(), &format!("#include <{}>\n", header))
}
pub fn add_const(loc: &ClangSourceLocation) -> FixItHint {
FixItHint::insertion(loc.clone(), "const ")
}
pub fn add_static(loc: &ClangSourceLocation) -> FixItHint {
FixItHint::insertion(loc.clone(), "static ")
}
pub fn add_override(loc: &ClangSourceLocation) -> FixItHint {
FixItHint::insertion(loc.clone(), " override")
}
pub fn add_cast(loc: &ClangSourceLocation, target_type: &str) -> FixItHint {
let s = format!("({})", target_type);
FixItHint::insertion(loc.clone(), &s)
}
pub fn replace_assign_with_eq(range: SourceRange) -> FixItHint {
FixItHint::replacement(range, "==")
}
pub fn parenthesize(range: SourceRange) -> FixItHint {
FixItHint::replacement(range, "(expr)")
}
pub fn add_typename(loc: &ClangSourceLocation) -> FixItHint {
FixItHint::insertion(loc.clone(), "typename ")
}
pub fn suggest_x86_flag(loc: &ClangSourceLocation, flag: &str) -> FixItHint {
let s = format!("/* Add -{} to your compiler flags */", flag);
FixItHint::insertion(loc.clone(), &s)
}
pub fn suggest_alignas(loc: &ClangSourceLocation, alignment: usize) -> FixItHint {
let s = format!("alignas({}) ", alignment);
FixItHint::insertion(loc.clone(), &s)
}
pub fn missing_endif(loc: &ClangSourceLocation) -> FixItHint {
FixItHint::insertion(loc.clone(), "#endif\n")
}
pub fn fix_escape(loc: &ClangSourceLocation, from: &str, to: &str) -> FixItHint {
let end_col = (loc.column as usize + from.len()) as u32;
FixItHint::replacement(
SourceRange::new(
ClangSourceLocation::new(&loc.file, loc.line, loc.column),
ClangSourceLocation::new(&loc.file, loc.line, end_col),
),
to,
)
}
}
pub struct X86DiagnosticSuppression {
suppressed_ids: HashSet<X86FullDiagID>,
file_suppressed: HashMap<String, HashSet<X86FullDiagID>>,
line_suppressed: HashMap<(String, usize), HashSet<X86FullDiagID>>,
suppressed_files: HashSet<String>,
suppressed_lines: HashMap<String, HashSet<usize>>,
suppress_system_headers: bool,
suppress_macro_expansions: bool,
suppress_all_warnings: bool,
}
impl X86DiagnosticSuppression {
pub fn new() -> Self {
Self {
suppressed_ids: HashSet::new(),
file_suppressed: HashMap::new(),
line_suppressed: HashMap::new(),
suppressed_files: HashSet::new(),
suppressed_lines: HashMap::new(),
suppress_system_headers: false,
suppress_macro_expansions: false,
suppress_all_warnings: false,
}
}
pub fn suppress_id(&mut self, id: X86FullDiagID) {
self.suppressed_ids.insert(id);
}
pub fn suppress_in_file(&mut self, file: &str, id: X86FullDiagID) {
self.file_suppressed
.entry(file.to_string())
.or_default()
.insert(id);
}
pub fn suppress_on_line(&mut self, file: &str, line: usize, id: X86FullDiagID) {
self.line_suppressed
.entry((file.to_string(), line))
.or_default()
.insert(id);
}
pub fn suppress_file(&mut self, file: &str) {
self.suppressed_files.insert(file.to_string());
}
pub fn suppress_line(&mut self, file: &str, line: usize) {
self.suppressed_lines
.entry(file.to_string())
.or_default()
.insert(line);
}
pub fn is_suppressed(
&self,
id: X86FullDiagID,
file: &str,
line: usize,
is_macro: bool,
is_system_header: bool,
) -> bool {
if self.suppress_all_warnings {
return true;
}
if self.suppress_system_headers && is_system_header {
return true;
}
if self.suppress_macro_expansions && is_macro {
return true;
}
if self.suppressed_ids.contains(&id) {
return true;
}
if self.suppressed_files.contains(file) {
return true;
}
if let Some(lines) = self.suppressed_lines.get(file) {
if lines.contains(&line) {
return true;
}
}
if let Some(ids) = self.file_suppressed.get(file) {
if ids.contains(&id) {
return true;
}
}
if let Some(ids) = self.line_suppressed.get(&(file.to_string(), line)) {
if ids.contains(&id) {
return true;
}
}
false
}
pub fn reset(&mut self) {
self.suppressed_ids.clear();
self.file_suppressed.clear();
self.line_suppressed.clear();
self.suppressed_files.clear();
self.suppressed_lines.clear();
}
pub fn total_rules(&self) -> usize {
self.suppressed_ids.len()
+ self
.file_suppressed
.values()
.map(|v| v.len())
.sum::<usize>()
+ self
.line_suppressed
.values()
.map(|v| v.len())
.sum::<usize>()
+ self.suppressed_files.len()
+ self
.suppressed_lines
.values()
.map(|v| v.len())
.sum::<usize>()
}
}
impl Default for X86DiagnosticSuppression {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone)]
pub struct X86DiagnosticStats {
pub per_id: HashMap<X86FullDiagID, usize>,
pub per_category: HashMap<String, usize>,
pub per_severity: HashMap<DiagSeverity, usize>,
pub per_file: HashMap<String, usize>,
pub total: usize,
pub total_errors: usize,
pub total_warnings: usize,
pub total_remarks: usize,
pub total_notes: usize,
pub total_fatal: usize,
pub first_at: Option<std::time::Instant>,
pub last_at: Option<std::time::Instant>,
}
impl X86DiagnosticStats {
pub fn new() -> Self {
Self {
per_id: HashMap::new(),
per_category: HashMap::new(),
per_severity: HashMap::new(),
per_file: HashMap::new(),
total: 0,
total_errors: 0,
total_warnings: 0,
total_remarks: 0,
total_notes: 0,
total_fatal: 0,
first_at: None,
last_at: None,
}
}
pub fn record(&mut self, id: X86FullDiagID, severity: DiagSeverity, file: &str) {
self.total += 1;
*self.per_id.entry(id).or_default() += 1;
*self
.per_category
.entry(X86DiagnosticCatalog::category(id).to_string())
.or_default() += 1;
*self.per_severity.entry(severity).or_default() += 1;
*self.per_file.entry(file.to_string()).or_default() += 1;
match severity {
DiagSeverity::Error => self.total_errors += 1,
DiagSeverity::Warning => self.total_warnings += 1,
DiagSeverity::Remark => self.total_remarks += 1,
DiagSeverity::Note => self.total_notes += 1,
DiagSeverity::Fatal => self.total_fatal += 1,
_ => {}
}
}
pub fn top_diagnostic(&self) -> Option<(X86FullDiagID, usize)> {
self.per_id
.iter()
.max_by_key(|(_, &c)| c)
.map(|(&id, &c)| (id, c))
}
pub fn top_category(&self) -> Option<(&str, usize)> {
self.per_category
.iter()
.max_by_key(|(_, &c)| c)
.map(|(s, &c)| (s.as_str(), c))
}
pub fn top_file(&self) -> Option<(&str, usize)> {
self.per_file
.iter()
.max_by_key(|(_, &c)| c)
.map(|(s, &c)| (s.as_str(), c))
}
pub fn diagnostics_by_frequency(&self) -> Vec<(X86FullDiagID, usize)> {
let mut pairs: Vec<_> = self.per_id.iter().map(|(&id, &c)| (id, c)).collect();
pairs.sort_by(|a, b| b.1.cmp(&a.1));
pairs
}
pub fn summary(&self) -> String {
let mut s = String::new();
s.push_str(&format!("Diagnostic Statistics Summary\n"));
s.push_str(&format!("============================\n"));
s.push_str(&format!("Total: {}\n", self.total));
s.push_str(&format!("Errors: {}\n", self.total_errors));
s.push_str(&format!("Warnings: {}\n", self.total_warnings));
s.push_str(&format!("Remarks: {}\n", self.total_remarks));
s.push_str(&format!("Notes: {}\n", self.total_notes));
s.push_str(&format!("Fatal: {}\n", self.total_fatal));
s.push_str(&format!("Categories: {}\n", self.per_category.len()));
s.push_str(&format!("Files: {}\n", self.per_file.len()));
s.push_str(&format!("Unique IDs: {}\n", self.per_id.len()));
if let Some((cat, count)) = self.top_category() {
s.push_str(&format!("Top category: {} ({} diagnostics)\n", cat, count));
}
if let Some((file, count)) = self.top_file() {
s.push_str(&format!("Top file: {} ({} diagnostics)\n", file, count));
}
s
}
pub fn reset(&mut self) {
self.per_id.clear();
self.per_category.clear();
self.per_severity.clear();
self.per_file.clear();
self.total = 0;
self.total_errors = 0;
self.total_warnings = 0;
self.total_remarks = 0;
self.total_notes = 0;
self.total_fatal = 0;
self.first_at = None;
self.last_at = None;
}
}
impl Default for X86DiagnosticStats {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum X86DiagnosticPreset {
NoWarnings,
Default,
All,
AllExtra,
Pedantic,
Everything,
WarningsAsErrors,
X86Only,
SecurityOnly,
OptimizationRemarks,
}
impl X86DiagnosticPreset {
pub fn apply<W: Write>(&self, engine: &mut X86DiagnosticEngine<W>) {
match self {
Self::NoWarnings => {
engine.suppress_all = true;
}
Self::Default => {
for id in X86DiagnosticCatalog::all_ids() {
let sev = X86DiagnosticCatalog::default_severity(id);
if sev == DiagSeverity::Warning {
engine.enable_warning(id);
}
}
}
Self::All => {
engine.enable_group("all");
}
Self::AllExtra => {
engine.enable_group("all");
engine.enable_group("extra");
}
Self::Pedantic => {
engine.enable_group("all");
engine.enable_group("extra");
engine.enable_group("pedantic");
}
Self::Everything => {
engine.enable_all_warnings();
}
Self::WarningsAsErrors => {
engine.enable_group("all");
engine.enable_group("extra");
engine.warnings_as_errors = true;
}
Self::X86Only => {
engine.enable_group("target-feature");
engine.enable_group("abi-x86");
engine.enable_group("inline-asm-x86");
}
Self::SecurityOnly => {
engine.enable_group("format");
engine.enable_group("null-dereference");
engine.enable_group("strict-aliasing");
engine.enable_group("strict-overflow");
}
Self::OptimizationRemarks => {
for id in X86DiagnosticCatalog::all_ids() {
if X86DiagnosticCatalog::is_optimization(id) {
engine.set_severity(id, DiagSeverity::Remark);
engine.enable_warning(id);
}
}
}
}
}
pub fn name(&self) -> &'static str {
match self {
Self::NoWarnings => "no-warnings",
Self::Default => "default",
Self::All => "all",
Self::AllExtra => "all-extra",
Self::Pedantic => "pedantic",
Self::Everything => "everything",
Self::WarningsAsErrors => "warnings-as-errors",
Self::X86Only => "x86-only",
Self::SecurityOnly => "security-only",
Self::OptimizationRemarks => "optimization-remarks",
}
}
}
pub struct X86SeverityMap;
impl X86SeverityMap {
pub fn to_str(severity: DiagSeverity) -> &'static str {
match severity {
DiagSeverity::Ignored => "ignored",
DiagSeverity::Remark => "remark",
DiagSeverity::Note => "note",
DiagSeverity::Warning => "warning",
DiagSeverity::Error => "error",
DiagSeverity::Fatal => "fatal error",
}
}
pub fn from_str(s: &str) -> Option<DiagSeverity> {
match s {
"ignored" | "none" => Some(DiagSeverity::Ignored),
"remark" | "info" => Some(DiagSeverity::Remark),
"note" => Some(DiagSeverity::Note),
"warning" | "warn" => Some(DiagSeverity::Warning),
"error" | "err" => Some(DiagSeverity::Error),
"fatal" | "fatal error" => Some(DiagSeverity::Fatal),
_ => None,
}
}
pub fn flag_to_severity(flag: &str) -> Option<DiagSeverity> {
if flag.starts_with("-Werror=") {
Some(DiagSeverity::Error)
} else if flag == "-Werror" {
Some(DiagSeverity::Error)
} else if flag.starts_with("-W") {
Some(DiagSeverity::Warning)
} else if flag == "-w" {
Some(DiagSeverity::Ignored)
} else {
None
}
}
}
pub struct X86DiagnosticCodeMap {
code_to_id: HashMap<u32, X86FullDiagID>,
id_to_code: HashMap<X86FullDiagID, u32>,
}
impl X86DiagnosticCodeMap {
pub fn new() -> Self {
let mut map = Self {
code_to_id: HashMap::new(),
id_to_code: HashMap::new(),
};
map.assign_codes();
map
}
fn assign_codes(&mut self) {
let ids = X86DiagnosticCatalog::all_ids();
for (idx, id) in ids.iter().enumerate() {
let code = (idx + 1) as u32;
self.code_to_id.insert(code, *id);
self.id_to_code.insert(*id, code);
}
}
pub fn lookup(&self, code: u32) -> Option<X86FullDiagID> {
self.code_to_id.get(&code).copied()
}
pub fn code_for(&self, id: X86FullDiagID) -> Option<u32> {
self.id_to_code.get(&id).copied()
}
pub fn len(&self) -> usize {
self.code_to_id.len()
}
pub fn is_empty(&self) -> bool {
self.code_to_id.is_empty()
}
pub fn to_json(&self) -> String {
let mut entries: Vec<String> = Vec::new();
let mut pairs: Vec<_> = self.id_to_code.iter().collect();
pairs.sort_by_key(|(_, &c)| c);
for (id, code) in pairs {
let name = format!("{:?}", id);
let msg = X86DiagnosticCatalog::message_for(*id).replace('"', "\\\"");
let cat = X86DiagnosticCatalog::category(*id);
let sev = match X86DiagnosticCatalog::default_severity(*id) {
DiagSeverity::Ignored => "ignored",
DiagSeverity::Remark => "remark",
DiagSeverity::Note => "note",
DiagSeverity::Warning => "warning",
DiagSeverity::Error => "error",
DiagSeverity::Fatal => "fatal",
};
entries.push(format!(
r#""{}": {{"code": {},"name": "{}","message": "{}","category": "{}","severity": "{}"}}"#,
code, code, name, msg, cat, sev
));
}
format!("{{\n {}\n}}\n", entries.join(",\n "))
}
}
impl Default for X86DiagnosticCodeMap {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone)]
pub struct X86DiagnosticReport {
pub title: String,
pub total_diagnostics: usize,
pub errors: Vec<(X86FullDiagID, String, ClangSourceLocation)>,
pub warnings: Vec<(X86FullDiagID, String, ClangSourceLocation)>,
pub notes: Vec<(X86FullDiagID, String, ClangSourceLocation)>,
pub remarks: Vec<(X86FullDiagID, String, ClangSourceLocation)>,
pub fatals: Vec<(X86FullDiagID, String, ClangSourceLocation)>,
pub files_affected: HashSet<String>,
pub stats: X86DiagnosticStats,
}
impl X86DiagnosticReport {
pub fn new(title: &str) -> Self {
Self {
title: title.to_string(),
total_diagnostics: 0,
errors: Vec::new(),
warnings: Vec::new(),
notes: Vec::new(),
remarks: Vec::new(),
fatals: Vec::new(),
files_affected: HashSet::new(),
stats: X86DiagnosticStats::new(),
}
}
pub fn record(
&mut self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
) {
self.total_diagnostics += 1;
self.files_affected
.insert(location.file.to_string_lossy().to_string());
self.stats
.record(id, severity, &location.file.to_string_lossy());
let entry = (id, message.to_string(), location.clone());
match severity {
DiagSeverity::Error => self.errors.push(entry),
DiagSeverity::Warning => self.warnings.push(entry),
DiagSeverity::Note => self.notes.push(entry),
DiagSeverity::Remark => self.remarks.push(entry),
DiagSeverity::Fatal => self.fatals.push(entry),
_ => {}
}
}
pub fn has_errors(&self) -> bool {
!self.errors.is_empty() || !self.fatals.is_empty()
}
pub fn is_clean(&self) -> bool {
self.errors.is_empty() && self.warnings.is_empty() && self.fatals.is_empty()
}
pub fn summary(&self) -> String {
let mut s = String::new();
s.push_str(&format!("=== {} ===\n\n", self.title));
s.push_str(&format!("Files affected: {}\n", self.files_affected.len()));
s.push_str(&format!("Total: {}\n", self.total_diagnostics));
s.push_str(&format!("Errors: {}\n", self.errors.len()));
s.push_str(&format!("Warnings: {}\n", self.warnings.len()));
s.push_str(&format!("Notes: {}\n", self.notes.len()));
s.push_str(&format!("Remarks: {}\n", self.remarks.len()));
s.push_str(&format!("Fatal: {}\n", self.fatals.len()));
if !self.errors.is_empty() {
s.push_str("\n--- Errors ---\n");
for (i, (id, msg, loc)) in self.errors.iter().take(10).enumerate() {
s.push_str(&format!(
" {}. {:?}: {} [{}:{}]\n",
i + 1,
id,
msg,
loc.file,
loc.line
));
}
if self.errors.len() > 10 {
s.push_str(&format!(" ... and {} more\n", self.errors.len() - 10));
}
}
if !self.warnings.is_empty() {
s.push_str("\n--- Warnings ---\n");
for (i, (id, msg, loc)) in self.warnings.iter().take(10).enumerate() {
s.push_str(&format!(
" {}. {:?}: {} [{}:{}]\n",
i + 1,
id,
msg,
loc.file,
loc.line
));
}
if self.warnings.len() > 10 {
s.push_str(&format!(" ... and {} more\n", self.warnings.len() - 10));
}
}
s.push_str("\n");
s.push_str(&self.stats.summary());
s
}
pub fn to_json(&self) -> String {
let mut json = String::from("{\n");
json.push_str(&format!(" \"title\": \"{}\",\n", self.title));
json.push_str(&format!(" \"total\": {},\n", self.total_diagnostics));
json.push_str(&format!(" \"errors\": {},\n", self.errors.len()));
json.push_str(&format!(" \"warnings\": {},\n", self.warnings.len()));
json.push_str(&format!(" \"notes\": {},\n", self.notes.len()));
json.push_str(&format!(" \"remarks\": {},\n", self.remarks.len()));
json.push_str(&format!(" \"fatal\": {},\n", self.fatals.len()));
json.push_str(&format!(
" \"files_affected\": {}\n",
self.files_affected.len()
));
json.push_str("}\n");
json
}
pub fn to_markdown(&self) -> String {
let mut md = String::new();
md.push_str(&format!("# {}\n\n", self.title));
md.push_str("| Category | Count |\n");
md.push_str("|----------|-------|\n");
md.push_str(&format!("| Errors | {} |\n", self.errors.len()));
md.push_str(&format!("| Warnings | {} |\n", self.warnings.len()));
md.push_str(&format!("| Notes | {} |\n", self.notes.len()));
md.push_str(&format!("| Remarks | {} |\n", self.remarks.len()));
md.push_str(&format!("| Fatal | {} |\n", self.fatals.len()));
md.push_str(&format!(
"| **Total**| **{}** |\n\n",
self.total_diagnostics
));
if !self.errors.is_empty() {
md.push_str("## Errors\n\n");
for (id, msg, loc) in &self.errors {
md.push_str(&format!(
"- **`{:?}`** at `{}:{}` — {}\n",
id, loc.file, loc.line, msg
));
}
}
if !self.warnings.is_empty() {
md.push_str("\n## Warnings\n\n");
for (id, msg, loc) in &self.warnings {
md.push_str(&format!(
"- **`{:?}`** at `{}:{}` — {}\n",
id, loc.file, loc.line, msg
));
}
}
md
}
pub fn reset(&mut self) {
self.total_diagnostics = 0;
self.errors.clear();
self.warnings.clear();
self.notes.clear();
self.remarks.clear();
self.fatals.clear();
self.files_affected.clear();
self.stats.reset();
}
}
impl Default for X86DiagnosticReport {
fn default() -> Self {
Self::new("X86 Diagnostic Report")
}
}
#[derive(Debug)]
pub struct X86DiagnosticBatchProcessor<W: Write> {
pub engine: X86DiagnosticEngine<W>,
pub suppression: X86DiagnosticSuppression,
pub report: X86DiagnosticReport,
pub sources: HashMap<String, Vec<String>>,
pub per_file_error_limit: Option<usize>,
}
impl<W: Write> X86DiagnosticBatchProcessor<W> {
pub fn new(writer: W) -> Self {
Self {
engine: X86DiagnosticEngine::new(writer),
suppression: X86DiagnosticSuppression::new(),
report: X86DiagnosticReport::new("Batch Diagnostic Report"),
sources: HashMap::new(),
per_file_error_limit: None,
}
}
pub fn add_source(&mut self, filename: &str, content: &str) {
let lines: Vec<String> = content.lines().map(|s| s.to_string()).collect();
self.sources.insert(filename.to_string(), lines);
self.engine.renderer.register_source(filename, content);
}
pub fn process(
&mut self,
id: X86FullDiagID,
location: &ClangSourceLocation,
is_macro: bool,
is_system_header: bool,
args: &[&str],
) -> io::Result<()> {
if self.suppression.is_suppressed(
id,
&location.file.to_string_lossy(),
location.line as usize,
is_macro,
is_system_header,
) {
return Ok(());
}
if let Some(limit) = self.per_file_error_limit {
let file_errors = self
.report
.errors
.iter()
.filter(|(_, _, l)| l.file == location.file)
.count();
if file_errors >= limit {
return Ok(());
}
}
let severity = self.engine.get_effective_severity(id);
if severity == DiagSeverity::Ignored {
return Ok(());
}
let mut msg = X86DiagnosticCatalog::message_for(id).to_string();
for arg in args {
msg = msg.replacen("{}", arg, 1);
}
self.report.record(id, severity, &msg, location);
self.engine.emit(id, &msg, location, &[], &[], &[])
}
pub fn process_batch(
&mut self,
diagnostics: &[(X86FullDiagID, ClangSourceLocation, Vec<String>)],
is_macro: bool,
is_system_header: bool,
) -> io::Result<()> {
for (id, loc, args) in diagnostics {
let args_refs: Vec<&str> = args.iter().map(|s| s.as_str()).collect();
self.process(*id, loc, is_macro, is_system_header, &args_refs)?;
}
Ok(())
}
pub fn finalize(self) -> X86DiagnosticReport {
self.report
}
pub fn has_errors(&self) -> bool {
self.report.has_errors()
}
pub fn summary(&self) -> String {
self.report.summary()
}
}
#[derive(Debug, Clone)]
pub struct X86DiagnosticContext {
entries: Vec<X86DiagnosticEntry>,
deduplicate: bool,
sort_by_location: bool,
}
#[derive(Debug, Clone)]
pub struct X86DiagnosticEntry {
pub id: X86FullDiagID,
pub severity: DiagSeverity,
pub message: String,
pub location: ClangSourceLocation,
pub notes: Vec<String>,
}
impl X86DiagnosticEntry {
pub fn new(
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
) -> Self {
Self {
id,
severity,
message: message.to_string(),
location: location.clone(),
notes: Vec::new(),
}
}
pub fn with_note(mut self, note: &str) -> Self {
self.notes.push(note.to_string());
self
}
}
impl X86DiagnosticContext {
pub fn new() -> Self {
Self {
entries: Vec::new(),
deduplicate: true,
sort_by_location: true,
}
}
pub fn add(
&mut self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
) {
let entry = X86DiagnosticEntry::new(id, severity, message, location);
self.entries.push(entry);
}
pub fn add_with_note(
&mut self,
id: X86FullDiagID,
severity: DiagSeverity,
message: &str,
location: &ClangSourceLocation,
note: &str,
) {
let entry = X86DiagnosticEntry::new(id, severity, message, location).with_note(note);
self.entries.push(entry);
}
pub fn len(&self) -> usize {
self.entries.len()
}
pub fn is_empty(&self) -> bool {
self.entries.is_empty()
}
pub fn entries(&self) -> Vec<&X86DiagnosticEntry> {
let mut result: Vec<&X86DiagnosticEntry> = self.entries.iter().collect();
if self.sort_by_location {
result.sort_by(|a, b| {
a.location
.file
.cmp(&b.location.file)
.then(a.location.line.cmp(&b.location.line))
.then(a.location.column.cmp(&b.location.column))
});
}
if self.deduplicate {
let mut seen = HashSet::new();
result.retain(|e| {
seen.insert((e.id, e.location.line, e.location.column, e.message.clone()))
});
}
result
}
pub fn errors(&self) -> Vec<&X86DiagnosticEntry> {
self.entries()
.into_iter()
.filter(|e| e.severity == DiagSeverity::Error || e.severity == DiagSeverity::Fatal)
.collect()
}
pub fn for_file(&self, file: &str) -> Vec<&X86DiagnosticEntry> {
self.entries()
.into_iter()
.filter(|e| e.location.file == file)
.collect()
}
pub fn emit_all<W: Write>(&self, engine: &mut X86DiagnosticEngine<W>) -> io::Result<()> {
for entry in self.entries() {
engine.emit(
entry.id,
&entry.message,
&entry.location,
&[],
&[],
&entry.notes,
)?;
}
Ok(())
}
pub fn clear(&mut self) {
self.entries.clear();
}
pub fn set_deduplicate(&mut self, enable: bool) {
self.deduplicate = enable;
}
pub fn set_sort_by_location(&mut self, enable: bool) {
self.sort_by_location = enable;
}
}
impl Default for X86DiagnosticContext {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone)]
pub struct X86DiagnosticThreshold {
thresholds: HashMap<String, DiagSeverity>,
default_threshold: DiagSeverity,
}
impl X86DiagnosticThreshold {
pub fn new() -> Self {
Self {
thresholds: HashMap::new(),
default_threshold: DiagSeverity::Warning,
}
}
pub fn set_category_threshold(&mut self, category: &str, threshold: DiagSeverity) {
self.thresholds.insert(category.to_string(), threshold);
}
pub fn set_default_threshold(&mut self, threshold: DiagSeverity) {
self.default_threshold = threshold;
}
pub fn meets_threshold(&self, id: X86FullDiagID, severity: DiagSeverity) -> bool {
let cat = X86DiagnosticCatalog::category(id);
let threshold = self.thresholds.get(cat).unwrap_or(&self.default_threshold);
severity_level(severity) >= severity_level(*threshold)
}
pub fn all_thresholds(&self) -> Vec<(&str, DiagSeverity)> {
self.thresholds
.iter()
.map(|(k, v)| (k.as_str(), *v))
.collect()
}
pub fn remove_category_threshold(&mut self, category: &str) {
self.thresholds.remove(category);
}
pub fn reset(&mut self) {
self.thresholds.clear();
self.default_threshold = DiagSeverity::Warning;
}
}
impl Default for X86DiagnosticThreshold {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_catalog_default_severity_error() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::LexIllegalChar),
DiagSeverity::Error
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::PPMissingEndif),
DiagSeverity::Error
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::ParseExpectedExpression),
DiagSeverity::Error
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::SemaDivisionByZero),
DiagSeverity::Error
);
}
#[test]
fn test_catalog_default_severity_warning() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Warning
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::X86FeatureAVX),
DiagSeverity::Warning
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::SecFormatString),
DiagSeverity::Warning
);
}
#[test]
fn test_catalog_default_severity_fatal() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::FatalNoInputFiles),
DiagSeverity::Fatal
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::FatalInternalError),
DiagSeverity::Fatal
);
}
#[test]
fn test_catalog_default_severity_remark() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::OptInlineRemark),
DiagSeverity::Remark
);
}
#[test]
fn test_catalog_category_lexer() {
assert_eq!(
X86DiagnosticCatalog::category(X86FullDiagID::LexIllegalChar),
"Lexer"
);
assert_eq!(
X86DiagnosticCatalog::category(X86FullDiagID::LexTrigraphWarning),
"Lexer"
);
}
#[test]
fn test_catalog_category_preprocessor() {
assert_eq!(
X86DiagnosticCatalog::category(X86FullDiagID::PPMacroRedefined),
"Preprocessor"
);
}
#[test]
fn test_catalog_category_parser() {
assert_eq!(
X86DiagnosticCatalog::category(X86FullDiagID::ParseExpectedToken),
"Parser"
);
}
#[test]
fn test_catalog_category_sema() {
assert_eq!(
X86DiagnosticCatalog::category(X86FullDiagID::SemaUnusedVariable),
"Semantic Analysis"
);
}
#[test]
fn test_catalog_category_cxx() {
assert_eq!(
X86DiagnosticCatalog::category(X86FullDiagID::CXXAccessControlPrivate),
"C++ Frontend"
);
}
#[test]
fn test_catalog_category_x86() {
assert_eq!(
X86DiagnosticCatalog::category(X86FullDiagID::X86FeatureSSE),
"X86 Target"
);
}
#[test]
fn test_catalog_flag_name() {
assert_eq!(
X86DiagnosticCatalog::flag_name(X86FullDiagID::SemaUnusedVariable),
"-Wunused-variable"
);
assert_eq!(
X86DiagnosticCatalog::flag_name(X86FullDiagID::SecFormatString),
"-Wformat"
);
assert_eq!(
X86DiagnosticCatalog::flag_name(X86FullDiagID::X86FeatureAVX),
"-Wtarget-feature"
);
}
#[test]
fn test_catalog_message_for() {
assert_eq!(
X86DiagnosticCatalog::message_for(X86FullDiagID::LexIllegalChar),
"illegal character in source file: '{}'"
);
assert_eq!(
X86DiagnosticCatalog::message_for(X86FullDiagID::PPMacroRedefined),
"macro '{}' redefined"
);
assert_eq!(
X86DiagnosticCatalog::message_for(X86FullDiagID::ParseMissingSemicolon),
"expected ';' after expression"
);
assert_eq!(
X86DiagnosticCatalog::message_for(X86FullDiagID::SemaUnusedVariable),
"unused variable '{}'"
);
}
#[test]
fn test_catalog_fatal_ids() {
assert!(X86DiagnosticCatalog::is_fatal(
X86FullDiagID::FatalCannotOpenFile
));
assert!(X86DiagnosticCatalog::is_fatal(
X86FullDiagID::FatalInternalError
));
assert!(!X86DiagnosticCatalog::is_fatal(
X86FullDiagID::SemaUnusedVariable
));
}
#[test]
fn test_catalog_is_lexer() {
assert!(X86DiagnosticCatalog::is_lexer(
X86FullDiagID::LexUnterminatedString
));
assert!(!X86DiagnosticCatalog::is_lexer(
X86FullDiagID::PPMacroRedefined
));
}
#[test]
fn test_catalog_is_x86() {
assert!(X86DiagnosticCatalog::is_x86(X86FullDiagID::X86FeatureAVX2));
assert!(!X86DiagnosticCatalog::is_x86(
X86FullDiagID::SemaUnusedVariable
));
}
#[test]
fn test_catalog_is_security() {
assert!(X86DiagnosticCatalog::is_security(
X86FullDiagID::SecUseAfterFree
));
assert!(!X86DiagnosticCatalog::is_security(
X86FullDiagID::LexIllegalChar
));
}
#[test]
fn test_catalog_count() {
assert!(X86DiagnosticCatalog::count() > 500);
}
#[test]
fn test_renderer_new() {
let r = X86DiagnosticRenderer::new();
assert!(r.show_column);
assert!(r.show_source_line);
assert!(r.show_carets);
}
#[test]
fn test_renderer_for_ide() {
let r = X86DiagnosticRenderer::for_ide();
assert!(r.show_source_line);
assert!(!r.show_categories);
assert!(!r.show_option_names);
}
#[test]
fn test_build_caret_line_simple() {
let r = X86DiagnosticRenderer::new();
let caret = r.build_caret_line("int x = 42;", 5, &[]);
assert!(caret.contains('^'));
}
#[test]
fn test_build_caret_line_with_range() {
let r = X86DiagnosticRenderer::new();
let caret = r.build_caret_line("int foo = bar;", 5, &[(5, 8)]);
assert!(caret.contains('^'));
}
#[test]
fn test_format_location() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 10 as u32, 5 as u32);
let formatted = r.format_location(&loc);
assert!(formatted.contains("test.c"));
assert!(formatted.contains("10"));
assert!(formatted.contains("5"));
}
#[test]
fn test_format_invalid_location() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::invalid();
assert_eq!(r.format_location(&loc), "<invalid>");
}
#[test]
fn test_format_severity_error() {
let r = X86DiagnosticRenderer::new();
let s = r.format_severity(DiagSeverity::Error);
assert!(s.contains("error"));
}
#[test]
fn test_format_severity_warning() {
let r = X86DiagnosticRenderer::new();
let s = r.format_severity(DiagSeverity::Warning);
assert!(s.contains("warning"));
}
#[test]
fn test_render_clang_basic() {
let mut r = X86DiagnosticRenderer::new();
r.register_source("test.c", "int main() {\n return x;\n}\n");
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 2 as u32, 10 as u32);
let output = r.render_clang(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"unused variable 'x'",
&loc,
&[],
&[],
&[],
);
assert!(output.contains("test.c"));
assert!(output.contains("warning"));
assert!(output.contains("unused"));
}
#[test]
fn test_render_gcc() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let output = r.render_gcc(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"expected ';'",
&loc,
);
assert!(output.contains("test.c"));
assert!(output.contains("error"));
}
#[test]
fn test_render_msvc() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let output = r.render_msvc(
DiagSeverity::Warning,
"unused variable",
&loc,
X86FullDiagID::SemaUnusedVariable,
);
assert!(output.contains("warning"));
assert!(output.contains("test.c"));
}
#[test]
fn test_render_json() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let json = r.render_json(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"expected ';'",
&loc,
&[SourceRange::point(ClangSourceLocation::new(
std::path::Path::new("test.c"),
1 as u32,
1 as u32,
))],
&[],
&[],
);
assert!(json.contains("\"severity\":\"error\""));
assert!(json.contains("ParseMissingSemicolon"));
}
#[test]
fn test_render_sarif() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let sarif = r.render_sarif(
X86FullDiagID::FatalCannotOpenFile,
DiagSeverity::Fatal,
"cannot open file",
&loc,
&[],
&[],
&[],
);
assert!(sarif.contains("error"));
assert!(sarif.contains("FatalCannotOpenFile"));
}
#[test]
fn test_render_xml() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let xml = r.render_xml(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"expected ';'",
&loc,
&[],
&[],
&[],
);
assert!(xml.contains("<diagnostic"));
assert!(xml.contains("severity=\"error\""));
}
#[test]
fn test_color_scheme_clang() {
let cs = X86ColorScheme::clang_style();
assert!(cs.use_colors);
assert!(!cs.error_color.is_empty());
}
#[test]
fn test_color_scheme_monochrome() {
let cs = X86ColorScheme::monochrome();
assert!(!cs.use_colors);
assert!(cs.error_color.is_empty());
}
#[test]
fn test_color_scheme_wrap() {
let cs = X86ColorScheme::clang_style();
let wrapped = cs.wrap("error", &cs.error_color);
assert!(wrapped.contains("error"));
if cs.use_colors {
assert!(wrapped.starts_with("\x1b["));
}
}
#[test]
fn test_output_format_is_machine_readable() {
assert!(RenderOutputFormat::JSON.is_machine_readable());
assert!(RenderOutputFormat::SARIF.is_machine_readable());
assert!(RenderOutputFormat::XML.is_machine_readable());
assert!(!RenderOutputFormat::Clang.is_machine_readable());
assert!(!RenderOutputFormat::GCC.is_machine_readable());
}
#[test]
fn test_groups_all_has_members() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("all");
assert!(!members.is_empty());
assert!(members.contains(&X86FullDiagID::SemaUnusedVariable));
assert!(members.contains(&X86FullDiagID::SecFormatString));
}
#[test]
fn test_groups_extra_has_members() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("extra");
assert!(!members.is_empty());
}
#[test]
fn test_groups_format_has_members() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("format");
assert!(!members.is_empty());
assert!(members.contains(&X86FullDiagID::SecFormatString));
}
#[test]
fn test_groups_target_feature() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("target-feature");
assert!(!members.is_empty());
assert!(members.contains(&X86FullDiagID::X86FeatureAVX));
assert!(members.contains(&X86FullDiagID::X86FeatureSSE2));
}
#[test]
fn test_groups_abi_x86() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("abi-x86");
assert!(!members.is_empty());
assert!(members.contains(&X86FullDiagID::X86ABIViolation));
}
#[test]
fn test_groups_vector_x86() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("vector-x86");
assert!(!members.is_empty());
}
#[test]
fn test_groups_inline_asm_x86() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("inline-asm-x86");
assert!(!members.is_empty());
assert!(members.contains(&X86FullDiagID::X86InlineASMInvalidInstruction));
}
#[test]
fn test_groups_has_group() {
let groups = X86DiagnosticGroups::new();
assert!(groups.has_group("all"));
assert!(groups.has_group("target-feature"));
assert!(!groups.has_group("nonexistent"));
}
#[test]
fn test_groups_is_in_group() {
let groups = X86DiagnosticGroups::new();
assert!(groups.is_in_group(X86FullDiagID::SecFormatString, "format"));
assert!(!groups.is_in_group(X86FullDiagID::LexIllegalChar, "format"));
}
#[test]
fn test_groups_len() {
let groups = X86DiagnosticGroups::new();
assert!(groups.len() > 10);
}
#[test]
fn test_text_printer_new() {
let writer = Vec::new();
let printer = X86TextDiagnosticPrinter::new(writer);
assert_eq!(printer.error_count(), 0);
assert_eq!(printer.warning_count(), 0);
}
#[test]
fn test_text_printer_error_count() {
let writer = Vec::new();
let mut printer = X86TextDiagnosticPrinter::new(writer);
printer.begin_diagnostic(X86FullDiagID::ParseExpectedToken, DiagSeverity::Error);
assert_eq!(printer.error_count(), 0);
}
#[test]
fn test_counting_consumer_warnings_as_errors() {
let inner = X86TextDiagnosticPrinter::new(Vec::new());
let counter = CountingDiagnosticConsumer::new(inner).with_warnings_as_errors(true);
assert!(counter.warnings_as_errors);
assert_eq!(
counter.effective_severity(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Warning),
DiagSeverity::Error
);
}
#[test]
fn test_counting_consumer_promote() {
let inner = X86TextDiagnosticPrinter::new(Vec::new());
let mut counter = CountingDiagnosticConsumer::new(inner);
counter.promote_to_error(X86FullDiagID::SemaUnusedVariable);
assert_eq!(
counter.effective_severity(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Warning),
DiagSeverity::Error
);
}
#[test]
fn test_counting_consumer_suppress() {
let inner = X86TextDiagnosticPrinter::new(Vec::new());
let mut counter = CountingDiagnosticConsumer::new(inner);
counter.suppress(X86FullDiagID::SemaUnusedVariable);
assert_eq!(
counter.effective_severity(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Warning),
DiagSeverity::Ignored
);
}
#[test]
fn test_chained_consumer_new() {
let chain: ChainedDiagnosticConsumer<X86TextDiagnosticPrinter<Vec<u8>>> =
ChainedDiagnosticConsumer::new();
assert!(chain.is_empty());
assert_eq!(chain.len(), 0);
}
#[test]
fn test_chained_consumer_add() {
let mut chain: ChainedDiagnosticConsumer<X86TextDiagnosticPrinter<Vec<u8>>> =
ChainedDiagnosticConsumer::new();
chain.add(X86TextDiagnosticPrinter::new(Vec::new()));
chain.add(X86TextDiagnosticPrinter::new(Vec::new()));
assert_eq!(chain.len(), 2);
}
#[test]
fn test_engine_new() {
let engine = X86DiagnosticEngine::new(Vec::new());
assert!(!engine.has_errors());
assert!(!engine.has_warnings());
}
#[test]
fn test_engine_enable_disable_warning() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.enable_warning(X86FullDiagID::SemaUnusedVariable);
engine.disable_warning(X86FullDiagID::SemaUnusedVariable);
assert_eq!(
engine.get_effective_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Ignored
);
}
#[test]
fn test_engine_set_severity() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.set_severity(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Error);
assert_eq!(
engine.get_effective_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Error
);
}
#[test]
fn test_engine_enable_group() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.enable_group("format");
let sev = engine.get_effective_severity(X86FullDiagID::SecFormatString);
assert_ne!(sev, DiagSeverity::Ignored);
}
#[test]
fn test_engine_warnings_as_errors() {
let engine = X86DiagnosticEngine::new(Vec::new()).with_warnings_as_errors(true);
assert!(engine.warnings_as_errors);
}
#[test]
fn test_engine_suppress_all() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.suppress_all = true;
assert_eq!(
engine.get_effective_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Ignored
);
assert_eq!(
engine.get_effective_severity(X86FullDiagID::ParseMissingSemicolon),
DiagSeverity::Ignored
);
}
#[test]
fn test_make_x86_diagnostic_engine() {
let engine = make_x86_diagnostic_engine();
assert!(!engine.has_errors());
}
#[test]
fn test_x86_get_message() {
assert_eq!(
x86_get_message(X86FullDiagID::ParseMissingSemicolon),
"expected ';' after expression"
);
}
#[test]
fn test_x86_get_severity() {
assert_eq!(
x86_get_severity(X86FullDiagID::FatalInternalError),
DiagSeverity::Fatal
);
}
#[test]
fn test_x86_get_flag() {
assert_eq!(
x86_get_flag(X86FullDiagID::SemaUnusedVariable),
"-Wunused-variable"
);
}
#[test]
fn test_x86_get_category() {
assert_eq!(x86_get_category(X86FullDiagID::LexIllegalChar), "Lexer");
}
#[test]
fn test_render_multiple_formats() {
let renderer = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let msg = "test diagnostic";
let clang_out = renderer
.clone()
.with_format(RenderOutputFormat::Clang)
.render(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
msg,
&loc,
&[],
&[],
&[],
);
let gcc_out = renderer
.clone()
.with_format(RenderOutputFormat::GCC)
.render(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
msg,
&loc,
&[],
&[],
&[],
);
let msvc_out = renderer
.clone()
.with_format(RenderOutputFormat::MSVC)
.render(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
msg,
&loc,
&[],
&[],
&[],
);
let json_out = renderer
.clone()
.with_format(RenderOutputFormat::JSON)
.render(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
msg,
&loc,
&[],
&[],
&[],
);
let sarif_out = renderer
.clone()
.with_format(RenderOutputFormat::SARIF)
.render(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
msg,
&loc,
&[],
&[],
&[],
);
let xml_out = renderer.with_format(RenderOutputFormat::XML).render(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
msg,
&loc,
&[],
&[],
&[],
);
assert!(!clang_out.is_empty());
assert!(!gcc_out.is_empty());
assert!(!msvc_out.is_empty());
assert!(json_out.contains("ParseMissingSemicolon"));
assert!(!sarif_out.is_empty());
assert!(xml_out.contains("<diagnostic"));
}
#[test]
fn test_severity_level_ordering() {
assert!(severity_level(DiagSeverity::Fatal) > severity_level(DiagSeverity::Error));
assert!(severity_level(DiagSeverity::Error) > severity_level(DiagSeverity::Warning));
assert!(severity_level(DiagSeverity::Warning) > severity_level(DiagSeverity::Note));
assert!(severity_level(DiagSeverity::Note) > severity_level(DiagSeverity::Remark));
assert!(severity_level(DiagSeverity::Remark) > severity_level(DiagSeverity::Ignored));
}
#[test]
fn test_all_fatal_ids_have_fatal_severity() {
for id in &[
X86FullDiagID::FatalNoInputFiles,
X86FullDiagID::FatalCannotOpenFile,
X86FullDiagID::FatalOutOfMemory,
X86FullDiagID::FatalInvalidTarget,
X86FullDiagID::FatalInternalError,
X86FullDiagID::FatalLTOError,
X86FullDiagID::FatalBackendError,
] {
assert_eq!(
X86DiagnosticCatalog::default_severity(*id),
DiagSeverity::Fatal,
"Expected fatal severity for {:?}",
id
);
}
}
#[test]
fn test_all_error_ids_have_error_severity() {
let error_ids = [
X86FullDiagID::LexIllegalChar,
X86FullDiagID::PPMissingEndif,
X86FullDiagID::ParseExpectedExpression,
X86FullDiagID::SemaDivisionByZero,
X86FullDiagID::CXXAccessControlPrivate,
];
for id in &error_ids {
let sev = X86DiagnosticCatalog::default_severity(*id);
assert!(
sev == DiagSeverity::Error || sev == DiagSeverity::Fatal,
"Expected error/fatal for {:?}, got {:?}",
id,
sev
);
}
}
#[test]
fn test_message_catalog_has_no_empty_messages() {
let ids = [
X86FullDiagID::LexIllegalChar,
X86FullDiagID::PPMacroRedefined,
X86FullDiagID::ParseMissingSemicolon,
X86FullDiagID::SemaUnusedVariable,
X86FullDiagID::CXXAccessControlPrivate,
X86FullDiagID::X86FeatureSSE,
X86FullDiagID::OptInlineRemark,
X86FullDiagID::SecFormatString,
X86FullDiagID::FatalNoInputFiles,
];
for id in &ids {
let msg = X86DiagnosticCatalog::message_for(*id);
assert!(!msg.is_empty(), "Empty message for {:?}", id);
}
}
#[test]
fn test_diagnostic_engine_error_limit() {
let engine = X86DiagnosticEngine::new(Vec::new()).with_error_limit(5);
assert_eq!(engine.error_limit, Some(5));
}
#[test]
fn test_emitter_new() {
let emitter = X86DiagnosticEmitter::new(Vec::new());
assert!(!emitter.error_limit_reached());
assert_eq!(emitter.total_errors(), 0);
}
#[test]
fn test_emitter_register_source() {
let mut emitter = X86DiagnosticEmitter::new(Vec::new());
emitter.register_source("test.c", "int main() { return 0; }");
assert!(emitter.source_cache.contains_key("test.c"));
}
#[test]
fn test_emitter_warn() {
let mut emitter = X86DiagnosticEmitter::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let result = emitter.warn(X86FullDiagID::SemaUnusedVariable, &loc, "x");
assert!(result.is_ok());
}
#[test]
fn test_emitter_error() {
let mut emitter = X86DiagnosticEmitter::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let result = emitter.error(X86FullDiagID::ParseMissingSemicolon, &loc, ";");
assert!(result.is_ok());
}
#[test]
fn test_emitter_reset() {
let mut emitter = X86DiagnosticEmitter::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let _ = emitter.warn(X86FullDiagID::SemaUnusedVariable, &loc, "x");
emitter.reset();
assert_eq!(emitter.total_errors(), 0);
assert_eq!(emitter.total_warnings(), 0);
}
#[test]
fn test_emitter_error_limit() {
let mut emitter = X86DiagnosticEmitter::new(Vec::new());
emitter.max_errors = 2;
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let _ = emitter.error(X86FullDiagID::ParseMissingSemicolon, &loc, ";");
let _ = emitter.error(X86FullDiagID::ParseExpectedExpression, &loc, "expr");
assert!(emitter.error_limit_reached());
}
#[test]
fn test_emitter_note() {
let mut emitter = X86DiagnosticEmitter::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
emitter.note("previous declaration here", &loc);
}
#[test]
fn test_emitter_fixit() {
let mut emitter = X86DiagnosticEmitter::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 5 as u32);
emitter.fixit(";", &loc, true);
}
#[test]
fn test_fixit_insert_semicolon() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 10 as u32);
let fixit = X86FixItEngine::insert_semicolon(&loc);
assert!(fixit.is_insertion);
assert_eq!(fixit.code, ";");
}
#[test]
fn test_fixit_insert_brace() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 10 as u32);
let fixit = X86FixItEngine::insert_closing_brace(&loc);
assert!(fixit.is_insertion);
assert_eq!(fixit.code, "}");
}
#[test]
fn test_fixit_insert_paren() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 10 as u32);
let fixit = X86FixItEngine::insert_closing_paren(&loc);
assert!(fixit.is_insertion);
assert_eq!(fixit.code, ")");
}
#[test]
fn test_fixit_insert_bracket() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 10 as u32);
let fixit = X86FixItEngine::insert_closing_bracket(&loc);
assert!(fixit.is_insertion);
assert_eq!(fixit.code, "]");
}
#[test]
fn test_fixit_insert_include() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let fixit = X86FixItEngine::insert_include(&loc, "stdio.h");
assert!(fixit.is_insertion);
assert!(fixit.code.contains("stdio.h"));
}
#[test]
fn test_fixit_add_const() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let fixit = X86FixItEngine::add_const(&loc);
assert!(fixit.is_insertion);
assert!(fixit.code.contains("const"));
}
#[test]
fn test_fixit_add_static() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let fixit = X86FixItEngine::add_static(&loc);
assert!(fixit.is_insertion);
assert!(fixit.code.contains("static"));
}
#[test]
fn test_fixit_add_override() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let fixit = X86FixItEngine::add_override(&loc);
assert!(fixit.is_insertion);
assert!(fixit.code.contains("override"));
}
#[test]
fn test_fixit_add_cast() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let fixit = X86FixItEngine::add_cast(&loc, "int");
assert!(fixit.is_insertion);
assert_eq!(fixit.code, "(int)");
}
#[test]
fn test_fixit_add_typename() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let fixit = X86FixItEngine::add_typename(&loc);
assert!(fixit.is_insertion);
assert!(fixit.code.contains("typename"));
}
#[test]
fn test_fixit_missing_endif() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 100 as u32, 1 as u32);
let fixit = X86FixItEngine::missing_endif(&loc);
assert!(fixit.is_insertion);
assert!(fixit.code.contains("#endif"));
}
#[test]
fn test_fixit_suggest_x86_flag() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let fixit = X86FixItEngine::suggest_x86_flag(&loc, "msse2");
assert!(fixit.is_insertion);
assert!(fixit.code.contains("msse2"));
}
#[test]
fn test_fixit_suggest_alignas() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let fixit = X86FixItEngine::suggest_alignas(&loc, 16);
assert!(fixit.is_insertion);
assert!(fixit.code.contains("alignas"));
}
#[test]
fn test_suppression_new() {
let sup = X86DiagnosticSuppression::new();
assert_eq!(sup.total_rules(), 0);
}
#[test]
fn test_suppression_suppress_id() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_id(X86FullDiagID::SemaUnusedVariable);
assert!(sup.is_suppressed(X86FullDiagID::SemaUnusedVariable, "test.c", 1, false, false));
assert!(!sup.is_suppressed(
X86FullDiagID::SemaUnusedParameter,
"test.c",
1,
false,
false
));
}
#[test]
fn test_suppression_suppress_file() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_file("test.c");
assert!(sup.is_suppressed(X86FullDiagID::SemaUnusedVariable, "test.c", 1, false, false));
assert!(!sup.is_suppressed(
X86FullDiagID::SemaUnusedVariable,
"other.c",
1,
false,
false
));
}
#[test]
fn test_suppression_suppress_line() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_line("test.c", 42);
assert!(sup.is_suppressed(
X86FullDiagID::SemaUnusedVariable,
"test.c",
42,
false,
false
));
assert!(!sup.is_suppressed(
X86FullDiagID::SemaUnusedVariable,
"test.c",
43,
false,
false
));
}
#[test]
fn test_suppression_suppress_in_file() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_in_file("test.c", X86FullDiagID::SemaUnusedVariable);
assert!(sup.is_suppressed(X86FullDiagID::SemaUnusedVariable, "test.c", 1, false, false));
assert!(!sup.is_suppressed(
X86FullDiagID::SemaUnusedParameter,
"test.c",
1,
false,
false
));
assert!(!sup.is_suppressed(
X86FullDiagID::SemaUnusedVariable,
"other.c",
1,
false,
false
));
}
#[test]
fn test_suppression_on_line() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_on_line("test.c", 10, X86FullDiagID::SemaUnusedVariable);
assert!(sup.is_suppressed(
X86FullDiagID::SemaUnusedVariable,
"test.c",
10,
false,
false
));
assert!(!sup.is_suppressed(
X86FullDiagID::SemaUnusedVariable,
"test.c",
11,
false,
false
));
assert!(!sup.is_suppressed(
X86FullDiagID::SemaUnusedParameter,
"test.c",
10,
false,
false
));
}
#[test]
fn test_suppression_system_headers() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_system_headers = true;
assert!(sup.is_suppressed(X86FullDiagID::SemaUnusedVariable, "stdio.h", 1, false, true));
assert!(!sup.is_suppressed(X86FullDiagID::SemaUnusedVariable, "test.c", 1, false, false));
}
#[test]
fn test_suppression_macro_expansions() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_macro_expansions = true;
assert!(sup.is_suppressed(X86FullDiagID::SemaUnusedVariable, "test.c", 1, true, false));
assert!(!sup.is_suppressed(X86FullDiagID::SemaUnusedVariable, "test.c", 1, false, false));
}
#[test]
fn test_suppression_all_warnings() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_all_warnings = true;
assert!(sup.is_suppressed(X86FullDiagID::SemaUnusedVariable, "test.c", 1, false, false));
assert!(sup.is_suppressed(
X86FullDiagID::ParseMissingSemicolon,
"test.c",
1,
false,
false
));
}
#[test]
fn test_suppression_total_rules() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_id(X86FullDiagID::SemaUnusedVariable);
sup.suppress_file("test.c");
sup.suppress_line("test.c", 5);
assert!(sup.total_rules() >= 3);
}
#[test]
fn test_suppression_reset() {
let mut sup = X86DiagnosticSuppression::new();
sup.suppress_id(X86FullDiagID::SemaUnusedVariable);
sup.reset();
assert_eq!(sup.total_rules(), 0);
}
#[test]
fn test_stats_new() {
let stats = X86DiagnosticStats::new();
assert_eq!(stats.total, 0);
assert_eq!(stats.total_errors, 0);
assert_eq!(stats.total_warnings, 0);
}
#[test]
fn test_stats_record() {
let mut stats = X86DiagnosticStats::new();
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
assert_eq!(stats.total, 1);
assert_eq!(stats.total_warnings, 1);
}
#[test]
fn test_stats_record_multiple() {
let mut stats = X86DiagnosticStats::new();
for _ in 0..5 {
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
}
for _ in 0..3 {
stats.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"test.c",
);
}
assert_eq!(stats.total, 8);
assert_eq!(stats.total_warnings, 5);
assert_eq!(stats.total_errors, 3);
}
#[test]
fn test_stats_top_diagnostic() {
let mut stats = X86DiagnosticStats::new();
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
stats.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"test.c",
);
let top = stats.top_diagnostic();
assert!(top.is_some());
assert_eq!(top.unwrap().0, X86FullDiagID::SemaUnusedVariable);
assert_eq!(top.unwrap().1, 2);
}
#[test]
fn test_stats_top_category() {
let mut stats = X86DiagnosticStats::new();
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
stats.record(
X86FullDiagID::SemaUnusedParameter,
DiagSeverity::Warning,
"test.c",
);
stats.record(
X86FullDiagID::SemaUnusedFunction,
DiagSeverity::Warning,
"test.c",
);
let top = stats.top_category();
assert!(top.is_some());
}
#[test]
fn test_stats_top_file() {
let mut stats = X86DiagnosticStats::new();
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"bad.c",
);
stats.record(
X86FullDiagID::SemaUnusedParameter,
DiagSeverity::Warning,
"bad.c",
);
stats.record(
X86FullDiagID::SemaUnusedFunction,
DiagSeverity::Warning,
"ok.c",
);
let top = stats.top_file();
assert!(top.is_some());
assert_eq!(top.unwrap().0, "bad.c");
assert_eq!(top.unwrap().1, 2);
}
#[test]
fn test_stats_summary() {
let mut stats = X86DiagnosticStats::new();
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
let summary = stats.summary();
assert!(summary.contains("Total:"));
assert!(summary.contains("Warnings:"));
}
#[test]
fn test_stats_diagnostics_by_frequency() {
let mut stats = X86DiagnosticStats::new();
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
stats.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"test.c",
);
let freq = stats.diagnostics_by_frequency();
assert!(!freq.is_empty());
assert_eq!(freq[0].0, X86FullDiagID::SemaUnusedVariable);
}
#[test]
fn test_stats_reset() {
let mut stats = X86DiagnosticStats::new();
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
stats.reset();
assert_eq!(stats.total, 0);
assert!(stats.per_id.is_empty());
}
#[test]
fn test_stats_all_severity_counts() {
let mut stats = X86DiagnosticStats::new();
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"test.c",
);
stats.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"test.c",
);
stats.record(
X86FullDiagID::OptInlineRemark,
DiagSeverity::Remark,
"test.c",
);
stats.record(
X86FullDiagID::FatalInternalError,
DiagSeverity::Fatal,
"test.c",
);
assert_eq!(stats.total_warnings, 1);
assert_eq!(stats.total_errors, 1);
assert_eq!(stats.total_remarks, 1);
assert_eq!(stats.total_fatal, 1);
assert_eq!(stats.total, 4);
}
#[test]
fn test_preset_no_warnings() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
X86DiagnosticPreset::NoWarnings.apply(&mut engine);
assert!(engine.suppress_all);
}
#[test]
fn test_preset_warnings_as_errors() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
X86DiagnosticPreset::WarningsAsErrors.apply(&mut engine);
assert!(engine.warnings_as_errors);
}
#[test]
fn test_preset_x86_only() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
X86DiagnosticPreset::X86Only.apply(&mut engine);
let sev = engine.get_effective_severity(X86FullDiagID::X86FeatureAVX);
assert_ne!(sev, DiagSeverity::Ignored);
}
#[test]
fn test_preset_security_only() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
X86DiagnosticPreset::SecurityOnly.apply(&mut engine);
let sev = engine.get_effective_severity(X86FullDiagID::SecFormatString);
assert_ne!(sev, DiagSeverity::Ignored);
}
#[test]
fn test_preset_optimization_remarks() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
X86DiagnosticPreset::OptimizationRemarks.apply(&mut engine);
let sev = engine.get_effective_severity(X86FullDiagID::OptInlineRemark);
assert_eq!(sev, DiagSeverity::Remark);
}
#[test]
fn test_preset_names() {
assert_eq!(X86DiagnosticPreset::NoWarnings.name(), "no-warnings");
assert_eq!(X86DiagnosticPreset::All.name(), "all");
assert_eq!(X86DiagnosticPreset::Everything.name(), "everything");
assert_eq!(X86DiagnosticPreset::X86Only.name(), "x86-only");
}
#[test]
fn test_severity_map_to_str() {
assert_eq!(X86SeverityMap::to_str(DiagSeverity::Error), "error");
assert_eq!(X86SeverityMap::to_str(DiagSeverity::Warning), "warning");
assert_eq!(X86SeverityMap::to_str(DiagSeverity::Fatal), "fatal error");
assert_eq!(X86SeverityMap::to_str(DiagSeverity::Note), "note");
assert_eq!(X86SeverityMap::to_str(DiagSeverity::Remark), "remark");
assert_eq!(X86SeverityMap::to_str(DiagSeverity::Ignored), "ignored");
}
#[test]
fn test_severity_map_from_str() {
assert_eq!(X86SeverityMap::from_str("error"), Some(DiagSeverity::Error));
assert_eq!(
X86SeverityMap::from_str("warning"),
Some(DiagSeverity::Warning)
);
assert_eq!(X86SeverityMap::from_str("fatal"), Some(DiagSeverity::Fatal));
assert_eq!(X86SeverityMap::from_str("note"), Some(DiagSeverity::Note));
assert_eq!(
X86SeverityMap::from_str("remark"),
Some(DiagSeverity::Remark)
);
assert_eq!(
X86SeverityMap::from_str("ignored"),
Some(DiagSeverity::Ignored)
);
assert_eq!(X86SeverityMap::from_str("unknown"), None);
}
#[test]
fn test_severity_map_aliases() {
assert_eq!(
X86SeverityMap::from_str("warn"),
Some(DiagSeverity::Warning)
);
assert_eq!(X86SeverityMap::from_str("err"), Some(DiagSeverity::Error));
assert_eq!(X86SeverityMap::from_str("info"), Some(DiagSeverity::Remark));
assert_eq!(
X86SeverityMap::from_str("none"),
Some(DiagSeverity::Ignored)
);
}
#[test]
fn test_severity_map_flag_to_severity() {
assert_eq!(
X86SeverityMap::flag_to_severity("-Werror"),
Some(DiagSeverity::Error)
);
assert_eq!(
X86SeverityMap::flag_to_severity("-Werror=unused"),
Some(DiagSeverity::Error)
);
assert_eq!(
X86SeverityMap::flag_to_severity("-Wunused"),
Some(DiagSeverity::Warning)
);
assert_eq!(
X86SeverityMap::flag_to_severity("-w"),
Some(DiagSeverity::Ignored)
);
assert_eq!(X86SeverityMap::flag_to_severity("-O2"), None);
}
#[test]
fn test_catalog_all_ids_is_complete() {
let ids = X86DiagnosticCatalog::all_ids();
assert!(
ids.len() > 500,
"Expected >500 diagnostic IDs, got {}",
ids.len()
);
let mut seen = HashSet::new();
for id in &ids {
assert!(seen.insert(*id), "Duplicate ID in all_ids: {:?}", id);
}
}
#[test]
fn test_catalog_every_id_has_message() {
for id in X86DiagnosticCatalog::all_ids() {
let msg = X86DiagnosticCatalog::message_for(id);
assert!(!msg.is_empty(), "No message for {:?}", id);
}
}
#[test]
fn test_catalog_every_id_has_severity() {
for id in X86DiagnosticCatalog::all_ids() {
let sev = X86DiagnosticCatalog::default_severity(id);
match sev {
DiagSeverity::Ignored
| DiagSeverity::Remark
| DiagSeverity::Note
| DiagSeverity::Warning
| DiagSeverity::Error
| DiagSeverity::Fatal => {}
}
}
}
#[test]
fn test_catalog_every_id_has_category() {
for id in X86DiagnosticCatalog::all_ids() {
let cat = X86DiagnosticCatalog::category(id);
assert!(!cat.is_empty(), "No category for {:?}", id);
assert_ne!(cat, "Unknown", "Unknown category for {:?}", id);
}
}
#[test]
fn test_catalog_lexer_count() {
let lexer_ids: Vec<_> = X86DiagnosticCatalog::all_ids()
.into_iter()
.filter(|id| X86DiagnosticCatalog::is_lexer(*id))
.collect();
assert!(
lexer_ids.len() >= 50,
"Expected >= 50 lexer IDs, got {}",
lexer_ids.len()
);
}
#[test]
fn test_catalog_parser_count() {
let parser_ids: Vec<_> = X86DiagnosticCatalog::all_ids()
.into_iter()
.filter(|id| X86DiagnosticCatalog::is_parser(*id))
.collect();
assert!(
parser_ids.len() >= 80,
"Expected >= 80 parser IDs, got {}",
parser_ids.len()
);
}
#[test]
fn test_catalog_sema_count() {
let sema_ids: Vec<_> = X86DiagnosticCatalog::all_ids()
.into_iter()
.filter(|id| X86DiagnosticCatalog::is_sema(*id))
.collect();
assert!(
sema_ids.len() >= 100,
"Expected >= 100 sema IDs, got {}",
sema_ids.len()
);
}
#[test]
fn test_catalog_cxx_count() {
let cxx_ids: Vec<_> = X86DiagnosticCatalog::all_ids()
.into_iter()
.filter(|id| X86DiagnosticCatalog::is_cxx(*id))
.collect();
assert!(
cxx_ids.len() >= 150,
"Expected >= 150 C++ IDs, got {}",
cxx_ids.len()
);
}
#[test]
fn test_catalog_x86_count() {
let x86_ids: Vec<_> = X86DiagnosticCatalog::all_ids()
.into_iter()
.filter(|id| X86DiagnosticCatalog::is_x86(*id))
.collect();
assert!(
x86_ids.len() >= 80,
"Expected >= 80 X86 IDs, got {}",
x86_ids.len()
);
}
#[test]
fn test_catalog_security_count() {
let sec_ids: Vec<_> = X86DiagnosticCatalog::all_ids()
.into_iter()
.filter(|id| X86DiagnosticCatalog::is_security(*id))
.collect();
assert!(
sec_ids.len() >= 30,
"Expected >= 30 security IDs, got {}",
sec_ids.len()
);
}
#[test]
fn test_catalog_optimization_count() {
let opt_ids: Vec<_> = X86DiagnosticCatalog::all_ids()
.into_iter()
.filter(|id| X86DiagnosticCatalog::is_optimization(*id))
.collect();
assert!(
opt_ids.len() >= 40,
"Expected >= 40 optimization IDs, got {}",
opt_ids.len()
);
}
#[test]
fn test_groups_all_unused_included() {
let groups = X86DiagnosticGroups::new();
let all_members = groups.resolve_group("all");
assert!(all_members.contains(&X86FullDiagID::SemaUnusedVariable));
assert!(all_members.contains(&X86FullDiagID::SemaUnusedParameter));
}
#[test]
fn test_groups_conversion_includes_sign() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("conversion");
assert!(members.contains(&X86FullDiagID::SemaFloatToIntOverflow));
}
#[test]
fn test_groups_target_feature_covers_sse_family() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("target-feature");
assert!(members.contains(&X86FullDiagID::X86FeatureSSE));
assert!(members.contains(&X86FullDiagID::X86FeatureSSE2));
assert!(members.contains(&X86FullDiagID::X86FeatureSSE3));
assert!(members.contains(&X86FullDiagID::X86FeatureSSSE3));
assert!(members.contains(&X86FullDiagID::X86FeatureSSE41));
assert!(members.contains(&X86FullDiagID::X86FeatureSSE42));
}
#[test]
fn test_groups_target_feature_covers_avx_family() {
let groups = X86DiagnosticGroups::new();
let members = groups.resolve_group("target-feature");
assert!(members.contains(&X86FullDiagID::X86FeatureAVX));
assert!(members.contains(&X86FullDiagID::X86FeatureAVX2));
assert!(members.contains(&X86FullDiagID::X86FeatureAVX512F));
}
#[test]
fn test_groups_all_groups_have_members() {
let groups = X86DiagnosticGroups::new();
for name in groups.group_names() {
let members = groups.resolve_group(name);
assert!(!members.is_empty(), "Group '{}' has no members", name);
}
}
#[test]
fn test_groups_no_duplicate_groups() {
let groups = X86DiagnosticGroups::new();
let names: Vec<_> = groups.group_names();
let unique: HashSet<_> = names.iter().collect();
assert_eq!(names.len(), unique.len(), "Duplicate group names found");
}
#[test]
fn test_renderer_all_formats_nonempty() {
let renderer = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let msg = "test message";
let formats = [
RenderOutputFormat::Clang,
RenderOutputFormat::GCC,
RenderOutputFormat::MSVC,
RenderOutputFormat::JSON,
RenderOutputFormat::SARIF,
RenderOutputFormat::XML,
];
for fmt in &formats {
let r = renderer.clone().with_format(*fmt);
let out = r.render(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
msg,
&loc,
&[],
&[],
&[],
);
assert!(!out.is_empty(), "Empty output for format {:?}", fmt);
}
}
#[test]
fn test_renderer_is_not_line_numbered_when_invalid() {
let r = X86DiagnosticRenderer::new();
let invalid = ClangSourceLocation::invalid();
let output = r.render_clang(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"test",
&invalid,
&[],
&[],
&[],
);
assert!(output.contains("<invalid>"));
}
#[test]
fn test_escape_xml() {
assert_eq!(escape_xml("<&"), "<&");
assert_eq!(escape_xml(">\"'"), ">"'");
assert_eq!(escape_xml("hello"), "hello");
}
#[test]
fn test_location_convenience() {
let loc = x86_location("test.c", 5, 12);
assert_eq!(loc.file, "test.c");
assert_eq!(loc.line, 5);
assert_eq!(loc.column, 12);
}
#[test]
fn test_invalid_location_convenience() {
let loc = x86_invalid_location();
assert!(!loc.is_valid);
}
#[test]
fn test_fixit_engine_insertion() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 5 as u32);
let fixit = X86FixItEngine::insert_semicolon(&loc);
assert!(fixit.is_insertion);
assert_eq!(fixit.code, ";");
}
#[test]
fn test_fixit_engine_replacement() {
let begin = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let end = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 2 as u32);
let range = SourceRange::new(begin, end);
let fixit = X86FixItEngine::replace(range, "x");
assert!(!fixit.is_insertion);
assert_eq!(fixit.code, "x");
}
#[test]
fn test_fixit_engine_removal() {
let begin = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let end = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 2 as u32);
let range = SourceRange::new(begin, end);
let fixit = X86FixItEngine::remove(range);
assert!(!fixit.is_insertion);
}
#[test]
fn test_output_format_extensions() {
assert_eq!(RenderOutputFormat::JSON.extension(), "json");
assert_eq!(RenderOutputFormat::SARIF.extension(), "sarif");
assert_eq!(RenderOutputFormat::XML.extension(), "xml");
assert_eq!(RenderOutputFormat::Clang.extension(), "txt");
}
#[test]
fn test_output_format_machine_readable() {
assert!(RenderOutputFormat::JSON.is_machine_readable());
assert!(RenderOutputFormat::SARIF.is_machine_readable());
assert!(RenderOutputFormat::XML.is_machine_readable());
assert!(!RenderOutputFormat::Clang.is_machine_readable());
assert!(!RenderOutputFormat::GCC.is_machine_readable());
assert!(!RenderOutputFormat::MSVC.is_machine_readable());
}
#[test]
fn test_filtering_consumer_file_allow() {
let inner = X86TextDiagnosticPrinter::new(Vec::new());
let mut filter: FilteringDiagnosticConsumer<_, _> =
FilteringDiagnosticConsumer::new(inner, |_, _, _| true);
filter.allow_file("test.c");
assert_eq!(filter.allowed_files.len(), 1);
}
#[test]
fn test_filtering_consumer_category_block() {
let inner = X86TextDiagnosticPrinter::new(Vec::new());
let mut filter: FilteringDiagnosticConsumer<_, _> =
FilteringDiagnosticConsumer::new(inner, |_, _, _| true);
filter.block_category("Lexer");
assert_eq!(filter.blocked_categories.len(), 1);
}
#[test]
fn test_filtering_consumer_min_severity() {
let inner = X86TextDiagnosticPrinter::new(Vec::new());
let mut filter: FilteringDiagnosticConsumer<_, _> =
FilteringDiagnosticConsumer::new(inner, |_, _, _| true);
filter.set_min_severity(DiagSeverity::Error);
assert!(filter.min_severity.is_some());
}
#[test]
fn test_sarif_consumer_with_tool_info() {
let consumer = SARIFDiagnosticConsumer::new(Vec::new()).with_tool_info("my-tool", "2.0");
assert_eq!(consumer.tool_name, "my-tool");
assert_eq!(consumer.tool_version, "2.0");
}
#[test]
fn test_json_consumer_compact() {
let consumer = JSONDiagnosticConsumer::new(Vec::new()).compact(true);
assert!(consumer.compact);
}
#[test]
fn test_counting_consumer_demote() {
let inner = X86TextDiagnosticPrinter::new(Vec::new());
let mut counter = CountingDiagnosticConsumer::new(inner);
counter.demote_to_warning(X86FullDiagID::ParseMissingSemicolon);
assert_eq!(
counter.effective_severity(X86FullDiagID::ParseMissingSemicolon, DiagSeverity::Error),
DiagSeverity::Warning
);
}
#[test]
fn test_counting_consumer_error_limit() {
let inner = X86TextDiagnosticPrinter::new(Vec::new());
let counter = CountingDiagnosticConsumer::new(inner).with_error_limit(5);
assert_eq!(counter.error_limit, Some(5));
assert!(!counter.error_limit_reached());
}
#[test]
fn test_chained_consumer_propagates() {
let mut chain: ChainedDiagnosticConsumer<X86TextDiagnosticPrinter<Vec<u8>>> =
ChainedDiagnosticConsumer::new();
chain.add(X86TextDiagnosticPrinter::new(Vec::new()));
chain.add(X86TextDiagnosticPrinter::new(Vec::new()));
assert_eq!(chain.error_count(), 0);
chain.clear();
assert_eq!(chain.error_count(), 0);
}
#[test]
fn test_convenience_functions_roundtrip() {
let id = X86FullDiagID::SemaUnusedVariable;
assert_eq!(x86_get_message(id), X86DiagnosticCatalog::message_for(id));
assert_eq!(
x86_get_severity(id),
X86DiagnosticCatalog::default_severity(id)
);
assert_eq!(x86_get_flag(id), X86DiagnosticCatalog::flag_name(id));
assert_eq!(x86_get_category(id), X86DiagnosticCatalog::category(id));
}
#[test]
fn test_subset_of_ids() {
let representative = vec![
X86FullDiagID::LexIllegalChar,
X86FullDiagID::PPMacroRedefined,
X86FullDiagID::ParseExpectedToken,
X86FullDiagID::SemaTypeCheckingError,
X86FullDiagID::CXXAccessControlPrivate,
X86FullDiagID::X86FeatureSSE,
X86FullDiagID::OptInlineRemark,
X86FullDiagID::SecFormatString,
X86FullDiagID::FatalNoInputFiles,
];
for id in &representative {
let msg = X86DiagnosticCatalog::message_for(*id);
let sev = X86DiagnosticCatalog::default_severity(*id);
let cat = X86DiagnosticCatalog::category(*id);
assert!(!msg.is_empty(), "{:?} has empty message", id);
assert!(!cat.is_empty(), "{:?} has empty category", id);
match sev {
DiagSeverity::Ignored
| DiagSeverity::Remark
| DiagSeverity::Note
| DiagSeverity::Warning
| DiagSeverity::Error
| DiagSeverity::Fatal => {}
}
}
}
#[test]
fn test_x86_location_builder() {
let loc = x86_location("main.c", 42, 7);
assert_eq!(loc.filename(), "main.c");
assert!(loc.is_valid);
}
#[test]
fn test_code_map_new() {
let map = X86DiagnosticCodeMap::new();
assert!(!map.is_empty());
assert!(map.len() > 500);
}
#[test]
fn test_code_map_lookup() {
let map = X86DiagnosticCodeMap::new();
let id = map.lookup(1);
assert!(id.is_some());
}
#[test]
fn test_code_map_roundtrip() {
let map = X86DiagnosticCodeMap::new();
let id = X86FullDiagID::SemaUnusedVariable;
let code = map.code_for(id);
assert!(code.is_some());
let roundtripped = map.lookup(code.unwrap());
assert_eq!(roundtripped, Some(id));
}
#[test]
fn test_code_map_invalid_code() {
let map = X86DiagnosticCodeMap::new();
assert_eq!(map.lookup(999999), None);
}
#[test]
fn test_code_map_to_json() {
let map = X86DiagnosticCodeMap::new();
let json = map.to_json();
assert!(json.contains("code"));
assert!(json.contains("severity"));
assert!(!json.is_empty());
}
#[test]
fn test_code_map_all_codes_unique() {
let map = X86DiagnosticCodeMap::new();
let mut codes = HashSet::new();
for id in X86DiagnosticCatalog::all_ids() {
if let Some(code) = map.code_for(id) {
assert!(codes.insert(code), "Duplicate code {} for {:?}", code, id);
}
}
}
#[test]
fn test_report_new() {
let report = X86DiagnosticReport::new("Test Report");
assert_eq!(report.title, "Test Report");
assert_eq!(report.total_diagnostics, 0);
assert!(report.is_clean());
}
#[test]
fn test_report_record_error() {
let mut report = X86DiagnosticReport::new("Test");
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"expected ';'",
&loc,
);
assert_eq!(report.total_diagnostics, 1);
assert!(report.has_errors());
assert!(!report.is_clean());
}
#[test]
fn test_report_record_warning() {
let mut report = X86DiagnosticReport::new("Test");
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"unused 'x'",
&loc,
);
assert_eq!(report.warnings.len(), 1);
assert!(!report.is_clean());
}
#[test]
fn test_report_record_fatal() {
let mut report = X86DiagnosticReport::new("Test");
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::FatalInternalError,
DiagSeverity::Fatal,
"internal error",
&loc,
);
assert_eq!(report.fatals.len(), 1);
assert!(report.has_errors());
}
#[test]
fn test_report_multiple_entries() {
let mut report = X86DiagnosticReport::new("Multi");
let loc1 = ClangSourceLocation::new(std::path::Path::new("a.c"), 1 as u32, 1 as u32);
let loc2 = ClangSourceLocation::new(std::path::Path::new("b.c"), 2 as u32, 5 as u32);
report.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"e1",
&loc1,
);
report.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"w1",
&loc2,
);
report.record(
X86FullDiagID::OptInlineRemark,
DiagSeverity::Remark,
"r1",
&loc1,
);
report.record(
X86FullDiagID::FatalNoInputFiles,
DiagSeverity::Fatal,
"f1",
&loc2,
);
assert_eq!(report.total_diagnostics, 4);
assert_eq!(report.errors.len(), 1);
assert_eq!(report.warnings.len(), 1);
assert_eq!(report.remarks.len(), 1);
assert_eq!(report.fatals.len(), 1);
assert_eq!(report.files_affected.len(), 2);
}
#[test]
fn test_report_summary() {
let mut report = X86DiagnosticReport::new("Summary Test");
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"e",
&loc,
);
let summary = report.summary();
assert!(summary.contains("Summary Test"));
assert!(summary.contains("Errors"));
}
#[test]
fn test_report_to_json() {
let mut report = X86DiagnosticReport::new("JSON Test");
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"e",
&loc,
);
let json = report.to_json();
assert!(json.contains("JSON Test"));
assert!(json.contains("\"errors\": 1"));
}
#[test]
fn test_report_to_markdown() {
let mut report = X86DiagnosticReport::new("MD Test");
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"e",
&loc,
);
let md = report.to_markdown();
assert!(md.contains("# MD Test"));
assert!(md.contains("Errors"));
assert!(md.contains("ParseMissingSemicolon"));
}
#[test]
fn test_report_reset() {
let mut report = X86DiagnosticReport::new("Reset");
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"e",
&loc,
);
report.reset();
assert_eq!(report.total_diagnostics, 0);
assert!(report.is_clean());
}
#[test]
fn test_report_is_clean_only_notes() {
let mut report = X86DiagnosticReport::new("Notes Only");
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::CXXAccessControlPublic,
DiagSeverity::Note,
"public",
&loc,
);
assert!(report.is_clean()); }
#[test]
fn test_many_warnings_dont_panic() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.enable_all_warnings();
let loc = ClangSourceLocation::new(std::path::Path::new("stress.c"), 1 as u32, 1 as u32);
for _ in 0..100 {
let _ = engine.emit(
X86FullDiagID::SemaUnusedVariable,
"unused variable",
&loc,
&[],
&[],
&[],
);
}
}
#[test]
fn test_empty_source_registration() {
let mut emitter = X86DiagnosticEmitter::new(Vec::new());
emitter.register_source("empty.c", "");
assert!(emitter.source_cache.contains_key("empty.c"));
}
#[test]
fn test_all_x86_feature_ids_have_flag_names() {
for id in X86DiagnosticCatalog::all_ids() {
if X86DiagnosticCatalog::is_x86(id) {
let flag = X86DiagnosticCatalog::flag_name(id);
let _ = flag.len();
}
}
}
#[test]
fn test_no_empty_flag_names_for_warnings() {
let warning_ids: Vec<_> = X86DiagnosticCatalog::all_ids()
.into_iter()
.filter(|id| X86DiagnosticCatalog::default_severity(*id) == DiagSeverity::Warning)
.collect();
let empty_flags: Vec<_> = warning_ids
.iter()
.filter(|id| X86DiagnosticCatalog::flag_name(**id).is_empty())
.collect();
assert!(empty_flags.len() < warning_ids.len());
}
#[test]
fn test_engine_reset_preserves_config() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.warnings_as_errors = true;
engine.error_limit = Some(42);
engine.reset();
assert_eq!(engine.error_count(), 0);
assert_eq!(engine.warning_count(), 0);
}
#[test]
fn test_rendered_diagnostic_line_length() {
let renderer = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("x.c"), 1 as u32, 1 as u32);
let output = renderer.render_clang(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"test",
&loc,
&[],
&[],
&[],
);
for line in output.lines() {
assert!(line.len() < 500, "Line too long: '{}'", line);
}
}
#[test]
fn test_catalog_count_nonzero() {
assert!(X86DiagnosticCatalog::count() > 0);
}
#[test]
fn test_default_engine_state() {
let engine = X86DiagnosticEngine::new(Vec::new());
assert!(!engine.has_errors());
assert!(!engine.has_warnings());
assert!(!engine.suppress_all);
assert!(!engine.warnings_as_errors);
}
#[test]
fn test_printer_clear_after_errors() {
let mut printer = X86TextDiagnosticPrinter::new(Vec::new());
printer.begin_diagnostic(X86FullDiagID::ParseMissingSemicolon, DiagSeverity::Error);
printer.clear();
assert_eq!(printer.error_count(), 0);
assert_eq!(printer.warning_count(), 0);
}
#[test]
fn test_batch_processor_new() {
let bp = X86DiagnosticBatchProcessor::new(Vec::new());
assert!(!bp.has_errors());
assert!(bp.report.is_clean());
}
#[test]
fn test_batch_processor_add_source() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
bp.add_source("test.c", "int main() { return 0; }");
assert!(bp.sources.contains_key("test.c"));
}
#[test]
fn test_batch_processor_process_warning() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let result = bp.process(
X86FullDiagID::SemaUnusedVariable,
&loc,
false,
false,
&["x"],
);
assert!(result.is_ok());
}
#[test]
fn test_batch_processor_process_error() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let result = bp.process(
X86FullDiagID::ParseMissingSemicolon,
&loc,
false,
false,
&[],
);
assert!(result.is_ok());
assert!(bp.has_errors());
}
#[test]
fn test_batch_processor_suppression_respected() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
bp.suppression
.suppress_id(X86FullDiagID::SemaUnusedVariable);
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let _ = bp.process(
X86FullDiagID::SemaUnusedVariable,
&loc,
false,
false,
&["x"],
);
assert!(bp.report.warnings.is_empty());
}
#[test]
fn test_batch_processor_process_batch() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let batch = vec![
(
X86FullDiagID::SemaUnusedVariable,
loc.clone(),
vec!["x".to_string()],
),
(
X86FullDiagID::SemaUnusedParameter,
loc.clone(),
vec!["y".to_string()],
),
];
let result = bp.process_batch(&batch, false, false);
assert!(result.is_ok());
}
#[test]
fn test_batch_processor_finalize() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let _ = bp.process(
X86FullDiagID::SemaUnusedVariable,
&loc,
false,
false,
&["x"],
);
let report = bp.finalize();
assert_eq!(report.total_diagnostics, 1);
}
#[test]
fn test_batch_processor_per_file_limit() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
bp.per_file_error_limit = Some(2);
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let _ = bp.process(
X86FullDiagID::ParseMissingSemicolon,
&loc,
false,
false,
&[],
);
let _ = bp.process(
X86FullDiagID::ParseExpectedExpression,
&loc,
false,
false,
&[],
);
let result = bp.process(
X86FullDiagID::ParseExpectedToken,
&loc,
false,
false,
&["x"],
);
assert!(result.is_ok());
}
#[test]
fn test_context_new() {
let ctx = X86DiagnosticContext::new();
assert!(ctx.is_empty());
assert_eq!(ctx.len(), 0);
}
#[test]
fn test_context_add() {
let mut ctx = X86DiagnosticContext::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
);
assert_eq!(ctx.len(), 1);
}
#[test]
fn test_context_add_with_note() {
let mut ctx = X86DiagnosticContext::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
ctx.add_with_note(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
"declared here",
);
let entries = ctx.entries();
assert_eq!(entries.len(), 1);
assert_eq!(entries[0].notes.len(), 1);
}
#[test]
fn test_context_deduplicate() {
let mut ctx = X86DiagnosticContext::new();
ctx.set_deduplicate(true);
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
);
let entries = ctx.entries();
assert_eq!(entries.len(), 1);
}
#[test]
fn test_context_sort() {
let mut ctx = X86DiagnosticContext::new();
ctx.set_sort_by_location(true);
ctx.set_deduplicate(false);
let loc1 = ClangSourceLocation::new(std::path::Path::new("test.c"), 10 as u32, 1 as u32);
let loc2 = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"a",
&loc1,
);
ctx.add(
X86FullDiagID::SemaUnusedParameter,
DiagSeverity::Warning,
"b",
&loc2,
);
let entries = ctx.entries();
assert_eq!(entries[0].message, "b");
assert_eq!(entries[1].message, "a");
}
#[test]
fn test_context_errors() {
let mut ctx = X86DiagnosticContext::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"w",
&loc,
);
ctx.add(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"e",
&loc,
);
let errors = ctx.errors();
assert_eq!(errors.len(), 1);
assert_eq!(errors[0].message, "e");
}
#[test]
fn test_context_for_file() {
let mut ctx = X86DiagnosticContext::new();
let loc_a = ClangSourceLocation::new(std::path::Path::new("a.c"), 1 as u32, 1 as u32);
let loc_b = ClangSourceLocation::new(std::path::Path::new("b.c"), 1 as u32, 1 as u32);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc_a,
);
ctx.add(
X86FullDiagID::SemaUnusedParameter,
DiagSeverity::Warning,
"y",
&loc_b,
);
assert_eq!(ctx.for_file("a.c").len(), 1);
assert_eq!(ctx.for_file("b.c").len(), 1);
assert_eq!(ctx.for_file("c.c").len(), 0);
}
#[test]
fn test_context_clear() {
let mut ctx = X86DiagnosticContext::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
);
ctx.clear();
assert!(ctx.is_empty());
}
#[test]
fn test_context_emit_all() {
let mut ctx = X86DiagnosticContext::new();
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
);
let mut engine = X86DiagnosticEngine::new(Vec::new());
let result = ctx.emit_all(&mut engine);
assert!(result.is_ok());
}
#[test]
fn test_context_set_deduplicate() {
let mut ctx = X86DiagnosticContext::new();
ctx.set_deduplicate(false);
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
);
assert_eq!(ctx.entries().len(), 2);
}
#[test]
fn test_threshold_new() {
let t = X86DiagnosticThreshold::new();
assert!(t.meets_threshold(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Warning));
assert!(t.meets_threshold(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Error));
assert!(!t.meets_threshold(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Remark));
}
#[test]
fn test_threshold_category_specific() {
let mut t = X86DiagnosticThreshold::new();
t.set_category_threshold("Lexer", DiagSeverity::Error);
assert!(!t.meets_threshold(X86FullDiagID::LexMissingNewlineAtEOF, DiagSeverity::Warning));
assert!(t.meets_threshold(X86FullDiagID::LexMissingNewlineAtEOF, DiagSeverity::Error));
assert!(t.meets_threshold(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Warning));
}
#[test]
fn test_threshold_change_default() {
let mut t = X86DiagnosticThreshold::new();
t.set_default_threshold(DiagSeverity::Error);
assert!(!t.meets_threshold(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Warning));
assert!(t.meets_threshold(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Error));
}
#[test]
fn test_threshold_all_thresholds() {
let mut t = X86DiagnosticThreshold::new();
t.set_category_threshold("Lexer", DiagSeverity::Error);
t.set_category_threshold("X86 Target", DiagSeverity::Warning);
let all = t.all_thresholds();
assert_eq!(all.len(), 2);
}
#[test]
fn test_threshold_remove() {
let mut t = X86DiagnosticThreshold::new();
t.set_category_threshold("Lexer", DiagSeverity::Error);
t.remove_category_threshold("Lexer");
let all = t.all_thresholds();
assert!(all.is_empty());
}
#[test]
fn test_threshold_reset() {
let mut t = X86DiagnosticThreshold::new();
t.set_category_threshold("Lexer", DiagSeverity::Error);
t.set_default_threshold(DiagSeverity::Note);
t.reset();
assert!(t.all_thresholds().is_empty());
assert!(t.meets_threshold(X86FullDiagID::LexMissingNewlineAtEOF, DiagSeverity::Warning));
}
#[test]
fn test_entry_new() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let entry = X86DiagnosticEntry::new(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
);
assert_eq!(entry.id, X86FullDiagID::SemaUnusedVariable);
assert_eq!(entry.severity, DiagSeverity::Warning);
assert_eq!(entry.message, "x");
}
#[test]
fn test_entry_with_note() {
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let entry = X86DiagnosticEntry::new(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
)
.with_note("note1")
.with_note("note2");
assert_eq!(entry.notes.len(), 2);
}
#[test]
fn test_flag_parsing_wall() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.enable_group("all");
assert_ne!(
engine.get_effective_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Ignored
);
}
#[test]
fn test_flag_parsing_werror() {
let engine = X86DiagnosticEngine::new(Vec::new()).with_warnings_as_errors(true);
assert!(engine.warnings_as_errors);
}
#[test]
fn test_flag_parsing_wno_unused() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.disable_warning(X86FullDiagID::SemaUnusedVariable);
assert_eq!(
engine.get_effective_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Ignored
);
}
#[test]
fn test_flag_parsing_werror_specific() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.set_severity(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Error);
assert_eq!(
engine.get_effective_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Error
);
}
#[test]
fn test_lexer_all_ids_have_messages() {
for id in X86DiagnosticCatalog::all_ids() {
if X86DiagnosticCatalog::is_lexer(id) {
assert!(!X86DiagnosticCatalog::message_for(id).is_empty());
}
}
}
#[test]
fn test_preprocessor_error_severities() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::PPMissingEndif),
DiagSeverity::Error
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::PPInvalidDirective),
DiagSeverity::Error
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::PPHeaderNotFound),
DiagSeverity::Error
);
}
#[test]
fn test_parser_error_severities() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::ParseMissingSemicolon),
DiagSeverity::Error
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::ParseMissingClosingBrace),
DiagSeverity::Error
);
}
#[test]
fn test_cxx_error_severities() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::CXXAccessControlPrivate),
DiagSeverity::Error
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::CXXAbstractClass),
DiagSeverity::Error
);
}
#[test]
fn test_x86_feature_severities() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::X86FeatureSSE),
DiagSeverity::Warning
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::X86FeatureAVX),
DiagSeverity::Warning
);
}
#[test]
fn test_security_severities() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::SecFormatString),
DiagSeverity::Warning
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::SecBufferOverflow),
DiagSeverity::Warning
);
}
#[test]
fn test_optimization_remark_severities() {
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::OptInlineRemark),
DiagSeverity::Remark
);
assert_eq!(
X86DiagnosticCatalog::default_severity(X86FullDiagID::OptVectorizationRemark),
DiagSeverity::Remark
);
}
#[test]
fn test_json_output_structure() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("f.c"), 1 as u32, 1 as u32);
let json = r.render_json(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"x",
&loc,
&[],
&[],
&[],
);
assert!(json.starts_with('{'));
assert!(json.ends_with("}\n"));
}
#[test]
fn test_sarif_output_required_fields() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("f.c"), 1 as u32, 1 as u32);
let sarif = r.render_sarif(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"x",
&loc,
&[],
&[],
&[],
);
assert!(sarif.contains("ruleId"));
assert!(sarif.contains("level"));
}
#[test]
fn test_xml_output_structure() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("f.c"), 1 as u32, 1 as u32);
let xml = r.render_xml(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"x",
&loc,
&[],
&[],
&[],
);
assert!(xml.starts_with("<diagnostic"));
assert!(xml.ends_with("</diagnostic>\n"));
}
#[test]
fn test_gcc_output_format() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("file.c"), 10 as u32, 5 as u32);
let gcc = r.render_gcc(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"msg",
&loc,
);
assert!(gcc.starts_with("file.c:10:"));
assert!(gcc.contains("warning"));
}
#[test]
fn test_msvc_output_format() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("file.c"), 10 as u32, 5 as u32);
let msvc = r.render_msvc(
DiagSeverity::Error,
"msg",
&loc,
X86FullDiagID::ParseMissingSemicolon,
);
assert!(msvc.contains("file.c(10,5)"));
assert!(msvc.contains("error"));
}
#[test]
fn test_report_empty_has_no_errors() {
let report = X86DiagnosticReport::new("Empty");
assert!(!report.has_errors());
assert!(report.is_clean());
}
#[test]
fn test_report_markdown_has_table() {
let mut report = X86DiagnosticReport::new("MD");
let loc = ClangSourceLocation::new(std::path::Path::new("m.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"x",
&loc,
);
let md = report.to_markdown();
assert!(md.contains("| Errors |"));
assert!(md.contains("| **Total**|"));
}
#[test]
fn test_batch_processor_suppress_macros() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
bp.suppression.suppress_macro_expansions = true;
let loc = ClangSourceLocation::new(std::path::Path::new("t.c"), 1 as u32, 1 as u32);
let r = bp.process(X86FullDiagID::SemaUnusedVariable, &loc, true, false, &["x"]);
assert!(r.is_ok());
}
#[test]
fn test_batch_processor_suppress_sysheaders() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
bp.suppression.suppress_system_headers = true;
let loc = ClangSourceLocation::new(std::path::Path::new("stdio.h"), 1 as u32, 1 as u32);
let r = bp.process(X86FullDiagID::SemaUnusedVariable, &loc, false, true, &["x"]);
assert!(r.is_ok());
}
#[test]
fn test_context_sort_file_then_line() {
let mut ctx = X86DiagnosticContext::new();
ctx.set_deduplicate(false);
let l1 = ClangSourceLocation::new(std::path::Path::new("a.c"), 5 as u32, 1 as u32);
let l2 = ClangSourceLocation::new(std::path::Path::new("a.c"), 1 as u32, 1 as u32);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"a5",
&l1,
);
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"a1",
&l2,
);
let entries = ctx.entries();
assert_eq!(entries[0].message, "a1");
assert_eq!(entries[1].message, "a5");
}
#[test]
fn test_threshold_fatal_always_passes() {
let mut t = X86DiagnosticThreshold::new();
t.set_default_threshold(DiagSeverity::Error);
assert!(t.meets_threshold(X86FullDiagID::FatalInternalError, DiagSeverity::Fatal));
}
#[test]
fn test_threshold_ignored_never_passes() {
let t = X86DiagnosticThreshold::new();
assert!(!t.meets_threshold(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Ignored));
}
#[test]
fn test_code_map_all_ids_have_codes() {
let map = X86DiagnosticCodeMap::new();
for id in X86DiagnosticCatalog::all_ids() {
assert!(map.code_for(id).is_some());
}
}
#[test]
fn test_code_map_consistency() {
let map = X86DiagnosticCodeMap::new();
for (id, code) in &map.id_to_code {
assert_eq!(map.lookup(*code), Some(*id));
}
}
#[test]
fn test_engine_emit_with_range() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("t.c"), 1 as u32, 1 as u32);
let r = engine.emit(
X86FullDiagID::ParseMissingSemicolon,
"x",
&loc,
&[SourceRange::point(loc.clone())],
&[],
&[],
);
assert!(r.is_ok());
}
#[test]
fn test_engine_emit_with_fixit() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("t.c"), 1 as u32, 1 as u32);
let fixit = X86FixItEngine::insert_semicolon(&loc);
let r = engine.emit(
X86FullDiagID::ParseMissingSemicolon,
"x",
&loc,
&[],
&[fixit],
&[],
);
assert!(r.is_ok());
}
#[test]
fn test_engine_emit_with_notes() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("t.c"), 1 as u32, 1 as u32);
let r = engine.emit(
X86FullDiagID::ParseMissingSemicolon,
"x",
&loc,
&[],
&[],
&["note".to_string()],
);
assert!(r.is_ok());
}
#[test]
fn test_full_pipeline_error_to_report() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 10 as u32, 5 as u32);
let _ = bp.process(
X86FullDiagID::ParseMissingSemicolon,
&loc,
false,
false,
&[";"],
);
let _ = bp.process(
X86FullDiagID::SemaUnusedVariable,
&loc,
false,
false,
&["x"],
);
let report = bp.finalize();
assert_eq!(report.total_diagnostics, 2);
assert!(report.has_errors());
assert!(!report.is_clean());
}
#[test]
fn test_full_pipeline_suppress_category() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
for id in X86DiagnosticCatalog::all_ids() {
if X86DiagnosticCatalog::is_sema(id) {
bp.suppression.suppress_id(id);
}
}
let loc = ClangSourceLocation::new(std::path::Path::new("test.c"), 1 as u32, 1 as u32);
let _ = bp.process(
X86FullDiagID::SemaUnusedVariable,
&loc,
false,
false,
&["x"],
);
assert!(bp.report.warnings.is_empty());
}
#[test]
fn test_full_pipeline_emit_all_formats() {
let renderer = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::new(std::path::Path::new("all.c"), 1 as u32, 1 as u32);
let id = X86FullDiagID::ParseMissingSemicolon;
let formats = [
RenderOutputFormat::Clang,
RenderOutputFormat::GCC,
RenderOutputFormat::MSVC,
RenderOutputFormat::JSON,
RenderOutputFormat::SARIF,
RenderOutputFormat::XML,
];
for fmt in &formats {
let r = renderer.clone().with_format(*fmt);
let out = r.render(id, DiagSeverity::Error, "test", &loc, &[], &[], &[]);
assert!(!out.is_empty(), "Empty output for format {:?}", fmt);
}
}
#[test]
fn test_full_pipeline_multiple_files() {
let mut bp = X86DiagnosticBatchProcessor::new(Vec::new());
let la = ClangSourceLocation::new(std::path::Path::new("a.c"), 1 as u32, 1 as u32);
let lb = ClangSourceLocation::new(std::path::Path::new("b.c"), 1 as u32, 1 as u32);
let lc = ClangSourceLocation::new(std::path::Path::new("c.c"), 1 as u32, 1 as u32);
let _ = bp.process(X86FullDiagID::ParseMissingSemicolon, &la, false, false, &[]);
let _ = bp.process(X86FullDiagID::SemaUnusedVariable, &lb, false, false, &["x"]);
let _ = bp.process(
X86FullDiagID::SemaUnusedParameter,
&lc,
false,
false,
&["y"],
);
let report = bp.finalize();
assert_eq!(report.files_affected.len(), 3);
}
#[test]
fn test_full_pipeline_deduplication_context() {
let mut ctx = X86DiagnosticContext::new();
let loc = ClangSourceLocation::new(std::path::Path::new("dup.c"), 1 as u32, 1 as u32);
for _ in 0..10 {
ctx.add(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"x",
&loc,
);
}
assert_eq!(ctx.entries().len(), 1);
}
#[test]
fn test_full_pipeline_threshold_filtering() {
let mut t = X86DiagnosticThreshold::new();
t.set_default_threshold(DiagSeverity::Error);
assert!(!t.meets_threshold(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Warning));
assert!(t.meets_threshold(X86FullDiagID::ParseMissingSemicolon, DiagSeverity::Error));
}
#[test]
fn test_full_pipeline_preset_chain() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
X86DiagnosticPreset::AllExtra.apply(&mut engine);
engine.enable_group("target-feature");
assert_ne!(
engine.get_effective_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Ignored
);
assert_ne!(
engine.get_effective_severity(X86FullDiagID::X86FeatureSSE),
DiagSeverity::Ignored
);
}
#[test]
fn test_full_pipeline_loc_rendering() {
let mut r = X86DiagnosticRenderer::new();
r.register_source("render.c", "int main() {\n return x;\n}\n");
let loc = ClangSourceLocation::new(std::path::Path::new("render.c"), 2 as u32, 10 as u32);
let out = r.render_clang(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"unused",
&loc,
&[],
&[],
&[],
);
assert!(out.contains("render.c"));
assert!(out.contains("warning"));
}
#[test]
fn test_full_pipeline_fixit_chain() {
let loc = ClangSourceLocation::new(std::path::Path::new("fix.c"), 5 as u32, 1 as u32);
let f1 = X86FixItEngine::insert_semicolon(&loc);
let f2 = X86FixItEngine::add_const(&loc);
let mut engine = X86DiagnosticEngine::new(Vec::new());
let _ = engine.emit(
X86FullDiagID::ParseMissingSemicolon,
"test",
&loc,
&[],
&[f1, f2],
&[],
);
}
#[test]
fn test_full_pipeline_chained_consumers() {
let mut chain: ChainedDiagnosticConsumer<X86TextDiagnosticPrinter<Vec<u8>>> =
ChainedDiagnosticConsumer::new();
chain.add(X86TextDiagnosticPrinter::new(Vec::new()));
chain.add(X86TextDiagnosticPrinter::new(Vec::new()));
chain.add(X86TextDiagnosticPrinter::new(Vec::new()));
assert_eq!(chain.len(), 3);
chain.clear();
assert_eq!(chain.error_count(), 0);
}
#[test]
fn test_full_pipeline_counting_consumer() {
let p1 = X86TextDiagnosticPrinter::new(Vec::new());
let p2 = CountingDiagnosticConsumer::new(p1).with_warnings_as_errors(true);
assert!(p2.warnings_as_errors);
assert!(!p2.error_limit_reached());
}
#[test]
fn test_full_pipeline_filtering_consumer() {
let inner = X86TextDiagnosticPrinter::new(Vec::new());
let mut filter: FilteringDiagnosticConsumer<_, _> =
FilteringDiagnosticConsumer::new(inner, |_, _, _| true);
filter.allow_file("myfile.c");
filter.block_category("Security");
filter.set_min_severity(DiagSeverity::Warning);
assert_eq!(filter.allowed_files.len(), 1);
assert_eq!(filter.blocked_categories.len(), 1);
}
#[test]
fn test_full_pipeline_sarif_consumer_full() {
let mut consumer = SARIFDiagnosticConsumer::new(Vec::new());
consumer.with_tool_info("clang-x86", "2.1.0");
consumer.add_result("{\"ruleId\":\"test\"}".to_string());
assert_eq!(consumer.results.len(), 1);
}
#[test]
fn test_full_pipeline_json_consumer_full() {
let consumer = JSONDiagnosticConsumer::new(Vec::new()).compact(true);
assert!(consumer.compact);
}
#[test]
fn test_full_pipeline_stats_accumulation() {
let mut stats = X86DiagnosticStats::new();
for _ in 0..10 {
stats.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"w.c",
);
}
for _ in 0..5 {
stats.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"e.c",
);
}
for _ in 0..3 {
stats.record(
X86FullDiagID::FatalInternalError,
DiagSeverity::Fatal,
"f.c",
);
}
assert_eq!(stats.total, 18);
let top = stats.top_diagnostic().unwrap();
assert_eq!(top.0, X86FullDiagID::SemaUnusedVariable);
}
#[test]
fn test_full_pipeline_report_json_export() {
let mut report = X86DiagnosticReport::new("CI Report");
let loc = ClangSourceLocation::new(std::path::Path::new("src/main.c"), 42 as u32, 7 as u32);
report.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"missing ;",
&loc,
);
report.record(
X86FullDiagID::SemaUnusedVariable,
DiagSeverity::Warning,
"unused x",
&loc,
);
let json = report.to_json();
assert!(json.contains("\"total\": 2"));
}
#[test]
fn test_full_pipeline_code_map_json() {
let map = X86DiagnosticCodeMap::new();
let json = map.to_json();
assert!(json.contains("\"code\""));
assert!(json.contains("\"severity\""));
}
#[test]
fn test_full_pipeline_no_panic() {
let ids = X86DiagnosticCatalog::all_ids();
for id in ids {
let _ = X86DiagnosticCatalog::message_for(id);
let _ = X86DiagnosticCatalog::default_severity(id);
let _ = X86DiagnosticCatalog::category(id);
let _ = X86DiagnosticCatalog::flag_name(id);
}
}
#[test]
fn test_full_pipeline_cross_category() {
for id in X86DiagnosticCatalog::all_ids() {
let cat = X86DiagnosticCatalog::category(id);
let is_lex = X86DiagnosticCatalog::is_lexer(id);
let is_pp = X86DiagnosticCatalog::is_preprocessor(id);
let is_parse = X86DiagnosticCatalog::is_parser(id);
let is_sema = X86DiagnosticCatalog::is_sema(id);
let is_cxx = X86DiagnosticCatalog::is_cxx(id);
let is_x86 = X86DiagnosticCatalog::is_x86(id);
let is_opt = X86DiagnosticCatalog::is_optimization(id);
let is_sec = X86DiagnosticCatalog::is_security(id);
let is_fatal = X86DiagnosticCatalog::is_fatal(id);
let count = is_lex as u8
+ is_pp as u8
+ is_parse as u8
+ is_sema as u8
+ is_cxx as u8
+ is_x86 as u8
+ is_opt as u8
+ is_sec as u8
+ is_fatal as u8;
assert!(count <= 1, "{:?} in {} categories: {}", id, count, cat);
}
}
#[test]
fn test_edge_empty_engine_has_no_errors() {
let engine = X86DiagnosticEngine::new(Vec::new());
assert!(!engine.has_errors());
assert!(!engine.has_warnings());
assert_eq!(engine.error_count(), 0);
assert_eq!(engine.warning_count(), 0);
}
#[test]
fn test_edge_reset_clears_everything() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.enable_all_warnings();
engine.set_severity(X86FullDiagID::SemaUnusedVariable, DiagSeverity::Error);
engine.reset();
assert_eq!(engine.error_count(), 0);
}
#[test]
fn test_edge_suppress_all_ignores_everything() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.suppress_all = true;
let sev = engine.get_effective_severity(X86FullDiagID::ParseMissingSemicolon);
assert_eq!(sev, DiagSeverity::Ignored);
}
#[test]
fn test_edge_invalid_location_rendering() {
let r = X86DiagnosticRenderer::new();
let loc = ClangSourceLocation::invalid();
let out = r.render_clang(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"msg",
&loc,
&[],
&[],
&[],
);
assert!(out.contains("<invalid>"));
}
#[test]
fn test_edge_zero_length_source() {
let mut r = X86DiagnosticRenderer::new();
r.register_source("empty.c", "");
let loc = ClangSourceLocation::new(std::path::Path::new("empty.c"), 1 as u32, 1 as u32);
let out = r.render_clang(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"msg",
&loc,
&[],
&[],
&[],
);
assert!(!out.is_empty());
}
#[test]
fn test_edge_no_colors_monochrome() {
let r = X86DiagnosticRenderer::new().with_colors(false);
let loc = ClangSourceLocation::new(std::path::Path::new("t.c"), 1 as u32, 1 as u32);
let out = r.render_clang(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"msg",
&loc,
&[],
&[],
&[],
);
assert!(!out.contains("\x1b["));
}
#[test]
fn test_edge_engine_disable_enable_cycle() {
let mut engine = X86DiagnosticEngine::new(Vec::new());
engine.disable_warning(X86FullDiagID::SemaUnusedVariable);
assert_eq!(
engine.get_effective_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Ignored
);
engine.enable_warning(X86FullDiagID::SemaUnusedVariable);
assert_ne!(
engine.get_effective_severity(X86FullDiagID::SemaUnusedVariable),
DiagSeverity::Ignored
);
}
#[test]
fn test_edge_all_presets_have_names() {
let presets = [
X86DiagnosticPreset::NoWarnings,
X86DiagnosticPreset::Default,
X86DiagnosticPreset::All,
X86DiagnosticPreset::AllExtra,
X86DiagnosticPreset::Pedantic,
X86DiagnosticPreset::Everything,
X86DiagnosticPreset::WarningsAsErrors,
X86DiagnosticPreset::X86Only,
X86DiagnosticPreset::SecurityOnly,
X86DiagnosticPreset::OptimizationRemarks,
];
for preset in &presets {
assert!(!preset.name().is_empty());
}
}
#[test]
fn test_edge_severity_map_all_roundtrip() {
let severities = [
DiagSeverity::Ignored,
DiagSeverity::Remark,
DiagSeverity::Note,
DiagSeverity::Warning,
DiagSeverity::Error,
DiagSeverity::Fatal,
];
for &sev in &severities {
let s = X86SeverityMap::to_str(sev);
assert!(!s.is_empty());
}
}
#[test]
fn test_edge_fixit_engine_all_methods() {
let loc = ClangSourceLocation::new(std::path::Path::new("e.c"), 1 as u32, 1 as u32);
let _ = X86FixItEngine::insert_semicolon(&loc);
let _ = X86FixItEngine::insert_closing_brace(&loc);
let _ = X86FixItEngine::insert_closing_paren(&loc);
let _ = X86FixItEngine::insert_closing_bracket(&loc);
let _ = X86FixItEngine::insert_include(&loc, "stdio.h");
let _ = X86FixItEngine::add_const(&loc);
let _ = X86FixItEngine::add_static(&loc);
let _ = X86FixItEngine::add_override(&loc);
let _ = X86FixItEngine::add_cast(&loc, "int");
let _ = X86FixItEngine::add_typename(&loc);
let _ = X86FixItEngine::suggest_x86_flag(&loc, "msse2");
let _ = X86FixItEngine::suggest_alignas(&loc, 16);
let _ = X86FixItEngine::missing_endif(&loc);
}
#[test]
fn test_edge_report_all_export_formats() {
let mut report = X86DiagnosticReport::new("All Formats");
let loc = ClangSourceLocation::new(std::path::Path::new("all.c"), 1 as u32, 1 as u32);
report.record(
X86FullDiagID::ParseMissingSemicolon,
DiagSeverity::Error,
"err",
&loc,
);
let _ = report.summary();
let _ = report.to_json();
let _ = report.to_markdown();
}
}