DxilValidation.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilValidation.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // This file provides support for validating DXIL shaders. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include <memory>
  13. #include "dxc/Support/Global.h"
  14. #include "dxc/HLSL/DxilConstants.h"
  15. #include "dxc/Support/WinAdapter.h"
  16. namespace llvm {
  17. class Module;
  18. class LLVMContext;
  19. class raw_ostream;
  20. class DiagnosticPrinter;
  21. class DiagnosticInfo;
  22. }
  23. namespace hlsl {
  24. /* <py::lines('VALRULE-ENUM')>hctdb_instrhelp.get_valrule_enum()</py>*/
  25. // VALRULE-ENUM:BEGIN
  26. // Known validation rules
  27. enum class ValidationRule : unsigned {
  28. // Bitcode
  29. BitcodeValid, // TODO - Module must be bitcode-valid
  30. // Container
  31. ContainerPartInvalid, // DXIL Container must not contain unknown parts
  32. ContainerPartMatches, // DXIL Container Parts must match Module
  33. ContainerPartMissing, // DXIL Container requires certain parts, corresponding to module
  34. ContainerPartRepeated, // DXIL Container must have only one of each part type
  35. ContainerRootSignatureIncompatible, // Root Signature in DXIL Container must be compatible with shader
  36. // Declaration
  37. DeclAttrStruct, // Attributes parameter must be struct type
  38. DeclDxilFnExtern, // External function must be a DXIL function
  39. DeclDxilNsReserved, // The DXIL reserved prefixes must only be used by built-in functions and types
  40. DeclExtraArgs, // Extra arguments not allowed for shader functions
  41. DeclFnAttribute, // Functions should only contain known function attributes
  42. DeclFnFlattenParam, // Function parameters must not use struct types
  43. DeclFnIsCalled, // Functions can only be used by call instructions
  44. DeclNotUsedExternal, // External declaration should not be used
  45. DeclParamStruct, // Callable function parameter must be struct type
  46. DeclPayloadStruct, // Payload parameter must be struct type
  47. DeclResourceInFnSig, // Resources not allowed in function signatures
  48. DeclShaderMissingArg, // payload/params/attributes parameter is required for certain shader types
  49. DeclShaderReturnVoid, // Shader functions must return void
  50. DeclUsedExternalFunction, // External function must be used
  51. DeclUsedInternal, // Internal declaration must be used
  52. // Instruction
  53. InstrAllowed, // Instructions must be of an allowed type
  54. InstrAttributeAtVertexNoInterpolation, // Attribute %0 must have nointerpolation mode in order to use GetAttributeAtVertex function.
  55. InstrBarrierModeForNonCS, // sync in a non-Compute Shader must only sync UAV (sync_uglobal)
  56. InstrBarrierModeNoMemory, // sync must include some form of memory barrier - _u (UAV) and/or _g (Thread Group Shared Memory). Only _t (thread group sync) is optional.
  57. InstrBarrierModeUselessUGroup, // sync can't specify both _ugroup and _uglobal. If both are needed, just specify _uglobal.
  58. InstrBufferUpdateCounterOnResHasCounter, // BufferUpdateCounter valid only when HasCounter is true
  59. InstrBufferUpdateCounterOnUAV, // BufferUpdateCounter valid only on UAV
  60. InstrCBufferClassForCBufferHandle, // Expect Cbuffer for CBufferLoad handle
  61. InstrCBufferOutOfBound, // Cbuffer access out of bound
  62. InstrCallOload, // Call to DXIL intrinsic must match overload signature
  63. InstrCannotPullPosition, // pull-model evaluation of position disallowed
  64. InstrCheckAccessFullyMapped, // CheckAccessFullyMapped should only used on resource status
  65. InstrCoordinateCountForRawTypedBuf, // raw/typed buffer don't need 2 coordinates
  66. InstrCoordinateCountForStructBuf, // structured buffer require 2 coordinates
  67. InstrCreateHandleImmRangeID, // Local resource must map to global resource.
  68. InstrDxilStructUser, // Dxil struct types should only used by ExtractValue
  69. InstrDxilStructUserOutOfBound, // Index out of bound when extract value from dxil struct types
  70. InstrEvalInterpolationMode, // Interpolation mode on %0 used with eval_* instruction must be linear, linear_centroid, linear_noperspective, linear_noperspective_centroid, linear_sample or linear_noperspective_sample
  71. InstrExtractValue, // ExtractValue should only be used on dxil struct types and cmpxchg
  72. InstrFailToResloveTGSMPointer, // TGSM pointers must originate from an unambiguous TGSM global variable.
  73. InstrHandleNotFromCreateHandle, // Resource handle should returned by createHandle
  74. InstrImmBiasForSampleB, // bias amount for sample_b must be in the range [%0,%1], but %2 was specified as an immediate
  75. InstrInBoundsAccess, // Access to out-of-bounds memory is disallowed
  76. InstrMinPrecisionNotPrecise, // Instructions marked precise may not refer to minprecision values
  77. InstrMinPrecisonBitCast, // Bitcast on minprecison types is not allowed
  78. InstrMipLevelForGetDimension, // Use mip level on buffer when GetDimensions
  79. InstrMipOnUAVLoad, // uav load don't support mipLevel/sampleIndex
  80. InstrNoGenericPtrAddrSpaceCast, // Address space cast between pointer types must have one part to be generic address space
  81. InstrNoIDivByZero, // No signed integer division by zero
  82. InstrNoIndefiniteAcos, // No indefinite arccosine
  83. InstrNoIndefiniteAsin, // No indefinite arcsine
  84. InstrNoIndefiniteDsxy, // No indefinite derivative calculation
  85. InstrNoIndefiniteLog, // No indefinite logarithm
  86. InstrNoReadingUninitialized, // Instructions should not read uninitialized value
  87. InstrNoUDivByZero, // No unsigned integer division by zero
  88. InstrOffsetOnUAVLoad, // uav load don't support offset
  89. InstrOload, // DXIL intrinsic overload must be valid
  90. InstrOnlyOneAllocConsume, // RWStructuredBuffers may increment or decrement their counters, but not both.
  91. InstrOpCodeReserved, // Instructions must not reference reserved opcodes
  92. InstrOpConst, // DXIL intrinsic requires an immediate constant operand
  93. InstrOpConstRange, // Constant values must be in-range for operation
  94. InstrOperandRange, // DXIL intrinsic operand must be within defined range
  95. InstrPtrBitCast, // Pointer type bitcast must be have same size
  96. InstrResourceClassForLoad, // load can only run on UAV/SRV resource
  97. InstrResourceClassForSamplerGather, // sample, lod and gather should on srv resource.
  98. InstrResourceClassForUAVStore, // store should on uav resource.
  99. InstrResourceCoordinateMiss, // coord uninitialized
  100. InstrResourceCoordinateTooMany, // out of bound coord must be undef
  101. InstrResourceKindForBufferLoadStore, // buffer load/store only works on Raw/Typed/StructuredBuffer
  102. InstrResourceKindForCalcLOD, // lod requires resource declared as texture1D/2D/3D/Cube/CubeArray/1DArray/2DArray
  103. InstrResourceKindForGather, // gather requires resource declared as texture/2D/Cube/2DArray/CubeArray
  104. InstrResourceKindForGetDim, // Invalid resource kind on GetDimensions
  105. InstrResourceKindForSample, // sample/_l/_d requires resource declared as texture1D/2D/3D/Cube/1DArray/2DArray/CubeArray
  106. InstrResourceKindForSampleC, // samplec requires resource declared as texture1D/2D/Cube/1DArray/2DArray/CubeArray
  107. InstrResourceKindForTextureLoad, // texture load only works on Texture1D/1DArray/2D/2DArray/3D/MS2D/MS2DArray
  108. InstrResourceKindForTextureStore, // texture store only works on Texture1D/1DArray/2D/2DArray/3D
  109. InstrResourceKindForTraceRay, // TraceRay should only use RTAccelerationStructure
  110. InstrResourceMapToSingleEntry, // Fail to map resource to resource table
  111. InstrResourceOffsetMiss, // offset uninitialized
  112. InstrResourceOffsetTooMany, // out of bound offset must be undef
  113. InstrResourceUser, // Resource should only used by Load/GEP/Call
  114. InstrSampleCompType, // sample_* instructions require resource to be declared to return UNORM, SNORM or FLOAT.
  115. InstrSampleIndexForLoad2DMS, // load on Texture2DMS/2DMSArray require sampleIndex
  116. InstrSamplerModeForLOD, // lod instruction requires sampler declared in default mode
  117. InstrSamplerModeForSample, // sample/_l/_d/_cl_s/gather instruction requires sampler declared in default mode
  118. InstrSamplerModeForSampleC, // sample_c_*/gather_c instructions require sampler declared in comparison mode
  119. InstrSignatureOperationNotInEntry, // Dxil operation for input output signature must be in entryPoints.
  120. InstrStatus, // Resource status should only used by CheckAccessFullyMapped
  121. InstrStructBitCast, // Bitcast on struct types is not allowed
  122. InstrTGSMRaceCond, // Race condition writing to shared memory detected, consider making this write conditional
  123. InstrTextureOffset, // offset texture instructions must take offset which can resolve to integer literal in the range -8 to 7
  124. InstrUndefResultForGetDimension, // GetDimensions used undef dimension %0 on %1
  125. InstrWriteMaskForTypedUAVStore, // store on typed uav must write to all four components of the UAV
  126. InstrWriteMaskMatchValueForUAVStore, // uav store write mask must match store value mask, write mask is %0 and store value mask is %1
  127. // Metadata
  128. MetaBarycentricsFloat3, // only 'float3' type is allowed for SV_Barycentrics.
  129. MetaBarycentricsInterpolation, // SV_Barycentrics cannot be used with 'nointerpolation' type
  130. MetaBarycentricsTwoPerspectives, // There can only be up to two input attributes of SV_Barycentrics with different perspective interpolation mode.
  131. MetaBranchFlatten, // Can't use branch and flatten attributes together
  132. MetaClipCullMaxComponents, // Combined elements of SV_ClipDistance and SV_CullDistance must fit in 8 components
  133. MetaClipCullMaxRows, // Combined elements of SV_ClipDistance and SV_CullDistance must fit in two rows.
  134. MetaControlFlowHintNotOnControlFlow, // Control flow hint only works on control flow inst
  135. MetaDenseResIDs, // Resource identifiers must be zero-based and dense
  136. MetaDuplicateSysValue, // System value may only appear once in signature
  137. MetaEntryFunction, // entrypoint not found
  138. MetaFlagsUsage, // Flags must match usage
  139. MetaForceCaseOnSwitch, // Attribute forcecase only works for switch
  140. MetaFunctionAnnotation, // Cannot find function annotation for %0
  141. MetaGlcNotOnAppendConsume, // globallycoherent cannot be used with append/consume buffers
  142. MetaIntegerInterpMode, // Interpolation mode on integer must be Constant
  143. MetaInterpModeInOneRow, // Interpolation mode must be identical for all elements packed into the same row.
  144. MetaInterpModeValid, // Interpolation mode must be valid
  145. MetaInvalidControlFlowHint, // Invalid control flow hint
  146. MetaKnown, // Named metadata should be known
  147. MetaMaxTessFactor, // Hull Shader MaxTessFactor must be [%0..%1]. %2 specified
  148. MetaNoEntryPropsForEntry, // EntryPoints must have entry properties.
  149. MetaNoSemanticOverlap, // Semantics must not overlap
  150. MetaRequired, // TODO - Required metadata missing
  151. MetaSemaKindMatchesName, // Semantic name must match system value, when defined.
  152. MetaSemaKindValid, // Semantic kind must be valid
  153. MetaSemanticCompType, // %0 must be %1
  154. MetaSemanticIndexMax, // System value semantics have a maximum valid semantic index
  155. MetaSemanticLen, // Semantic length must be at least 1 and at most 64
  156. MetaSemanticShouldBeAllocated, // Semantic should have a valid packing location
  157. MetaSemanticShouldNotBeAllocated, // Semantic should have a packing location of -1
  158. MetaSignatureCompType, // signature %0 specifies unrecognized or invalid component type
  159. MetaSignatureDataWidth, // Data width must be identical for all elements packed into the same row.
  160. MetaSignatureIllegalComponentOrder, // Component ordering for packed elements must be: arbitrary < system value < system generated value
  161. MetaSignatureIndexConflict, // Only elements with compatible indexing rules may be packed together
  162. MetaSignatureOutOfRange, // Signature elements must fit within maximum signature size
  163. MetaSignatureOverlap, // Signature elements may not overlap in packing location.
  164. MetaStructBufAlignment, // StructuredBuffer stride not aligned
  165. MetaStructBufAlignmentOutOfBound, // StructuredBuffer stride out of bounds
  166. MetaSystemValueRows, // System value may only have 1 row
  167. MetaTarget, // Target triple must be 'dxil-ms-dx'
  168. MetaTessellatorOutputPrimitive, // Invalid Tessellator Output Primitive specified. Must be point, line, triangleCW or triangleCCW.
  169. MetaTessellatorPartition, // Invalid Tessellator Partitioning specified. Must be integer, pow2, fractional_odd or fractional_even.
  170. MetaTextureType, // elements of typed buffers and textures must fit in four 32-bit quantities
  171. MetaUsed, // All metadata must be used by dxil
  172. MetaValidSamplerMode, // Invalid sampler mode on sampler
  173. MetaValueRange, // Metadata value must be within range
  174. MetaWellFormed, // TODO - Metadata must be well-formed in operand count and types
  175. // Program flow
  176. FlowDeadLoop, // Loop must have break
  177. FlowFunctionCall, // Function with parameter is not permitted
  178. FlowNoRecusion, // Recursion is not permitted
  179. FlowReducible, // Execution flow must be reducible
  180. // Shader model
  181. Sm64bitRawBufferLoadStore, // i64/f64 rawBufferLoad/Store overloads are allowed after SM 6.3
  182. SmAppendAndConsumeOnSameUAV, // BufferUpdateCounter inc and dec on a given UAV (%d) cannot both be in the same shader for shader model less than 5.1.
  183. SmCBufferElementOverflow, // CBuffer elements must not overflow
  184. SmCBufferOffsetOverlap, // CBuffer offsets must not overlap
  185. SmCBufferTemplateTypeMustBeStruct, // D3D12 constant/texture buffer template element can only be a struct
  186. SmCSNoSignatures, // Compute shaders must not have shader signatures.
  187. SmCompletePosition, // Not all elements of SV_Position were written
  188. SmCounterOnlyOnStructBuf, // BufferUpdateCounter valid only on structured buffers
  189. SmDSInputControlPointCountRange, // DS input control point count must be [0..%0]. %1 specified
  190. SmDomainLocationIdxOOB, // DomainLocation component index out of bounds for the domain.
  191. SmDxilVersion, // Target shader model requires specific Dxil Version
  192. SmGSInstanceCountRange, // GS instance count must be [1..%0]. %1 specified
  193. SmGSOutputVertexCountRange, // GS output vertex count must be [0..%0]. %1 specified
  194. SmGSTotalOutputVertexDataRange, // Declared output vertex count (%0) multiplied by the total number of declared scalar components of output data (%1) equals %2. This value cannot be greater than %3
  195. SmGSValidInputPrimitive, // GS input primitive unrecognized
  196. SmGSValidOutputPrimitiveTopology, // GS output primitive topology unrecognized
  197. SmHSInputControlPointCountRange, // HS input control point count must be [0..%0]. %1 specified
  198. SmHullPassThruControlPointCountMatch, // For pass thru hull shader, input control point count must match output control point count
  199. SmInsideTessFactorSizeMatchDomain, // InsideTessFactor rows, columns (%0, %1) invalid for domain %2. Expected %3 rows and 1 column.
  200. SmInvalidResourceCompType, // Invalid resource return type
  201. SmInvalidResourceKind, // Invalid resources kind
  202. SmInvalidTextureKindOnUAV, // Texture2DMS[Array] or TextureCube[Array] resources are not supported with UAVs
  203. SmIsoLineOutputPrimitiveMismatch, // Hull Shader declared with IsoLine Domain must specify output primitive point or line. Triangle_cw or triangle_ccw output are not compatible with the IsoLine Domain.
  204. SmMaxTGSMSize, // Total Thread Group Shared Memory storage is %0, exceeded %1
  205. SmMaxTheadGroup, // Declared Thread Group Count %0 (X*Y*Z) is beyond the valid maximum of %1
  206. SmMultiStreamMustBePoint, // When multiple GS output streams are used they must be pointlists
  207. SmName, // Target shader model name must be known
  208. SmNoInterpMode, // Interpolation mode must be undefined for VS input/PS output/patch constant.
  209. SmNoPSOutputIdx, // Pixel shader output registers are not indexable.
  210. SmOpcode, // Opcode must be defined in target shader model
  211. SmOpcodeInInvalidFunction, // Invalid DXIL opcode usage like StorePatchConstant in patch constant function
  212. SmOperand, // Operand must be defined in target shader model
  213. SmOutputControlPointCountRange, // output control point count must be [0..%0]. %1 specified
  214. SmOutputControlPointsTotalScalars, // Total number of scalars across all HS output control points must not exceed
  215. SmPSConsistentInterp, // Interpolation mode for PS input position must be linear_noperspective_centroid or linear_noperspective_sample when outputting oDepthGE or oDepthLE and not running at sample frequency (which is forced by inputting SV_SampleIndex or declaring an input linear_sample or linear_noperspective_sample)
  216. SmPSCoverageAndInnerCoverage, // InnerCoverage and Coverage are mutually exclusive.
  217. SmPSMultipleDepthSemantic, // Pixel Shader only allows one type of depth semantic to be declared
  218. SmPSOutputSemantic, // Pixel Shader allows output semantics to be SV_Target, SV_Depth, SV_DepthGreaterEqual, SV_DepthLessEqual, SV_Coverage or SV_StencilRef, %0 found
  219. SmPSTargetCol0, // SV_Target packed location must start at column 0
  220. SmPSTargetIndexMatchesRow, // SV_Target semantic index must match packed row location
  221. SmPatchConstantOnlyForHSDS, // patch constant signature only valid in HS and DS
  222. SmROVOnlyInPS, // RasterizerOrdered objects are only allowed in 5.0+ pixel shaders
  223. SmRayShaderPayloadSize, // For shader '%0', %1 size is smaller than argument's allocation size
  224. SmRayShaderSignatures, // Ray tracing shader '%0' should not have any shader signatures
  225. SmResourceRangeOverlap, // Resource ranges must not overlap
  226. SmSampleCountOnlyOn2DMS, // Only Texture2DMS/2DMSArray could has sample count
  227. SmSemantic, // Semantic must be defined in target shader model
  228. SmStreamIndexRange, // Stream index (%0) must between 0 and %1
  229. SmTessFactorForDomain, // Required TessFactor for domain not found declared anywhere in Patch Constant data
  230. SmTessFactorSizeMatchDomain, // TessFactor rows, columns (%0, %1) invalid for domain %2. Expected %3 rows and 1 column.
  231. SmThreadGroupChannelRange, // Declared Thread Group %0 size %1 outside valid range [%2..%3]
  232. SmTriOutputPrimitiveMismatch, // Hull Shader declared with Tri Domain must specify output primitive point, triangle_cw or triangle_ccw. Line output is not compatible with the Tri domain
  233. SmUndefinedOutput, // Not all elements of output %0 were written
  234. SmValidDomain, // Invalid Tessellator Domain specified. Must be isoline, tri or quad
  235. SmViewIDNeedsSlot, // ViewID requires compatible space in pixel shader input signature
  236. SmZeroHSInputControlPointWithInput, // When HS input control point count is 0, no input signature should exist
  237. // Type system
  238. TypesDefined, // Type must be defined based on DXIL primitives
  239. TypesI8, // I8 can only used as immediate value for intrinsic
  240. TypesIntWidth, // Int type must be of valid width
  241. TypesNoMultiDim, // Only one dimension allowed for array type
  242. TypesNoVector, // Vector types must not be present
  243. // Uniform analysis
  244. UniNoWaveSensitiveGradient, // Gradient operations are not affected by wave-sensitive data or control flow.
  245. };
  246. // VALRULE-ENUM:END
  247. const char *GetValidationRuleText(ValidationRule value);
  248. void GetValidationVersion(_Out_ unsigned *pMajor, _Out_ unsigned *pMinor);
  249. HRESULT ValidateDxilModule(_In_ llvm::Module *pModule,
  250. _In_opt_ llvm::Module *pDebugModule);
  251. // DXIL Container Verification Functions (return false on failure)
  252. bool VerifySignatureMatches(_In_ llvm::Module *pModule,
  253. hlsl::DXIL::SignatureKind SigKind,
  254. _In_reads_bytes_(SigSize) const void *pSigData,
  255. _In_ uint32_t SigSize);
  256. // PSV = data for Pipeline State Validation
  257. bool VerifyPSVMatches(_In_ llvm::Module *pModule,
  258. _In_reads_bytes_(PSVSize) const void *pPSVData,
  259. _In_ uint32_t PSVSize);
  260. // PSV = data for Pipeline State Validation
  261. bool VerifyRDATMatches(_In_ llvm::Module *pModule,
  262. _In_reads_bytes_(RDATSize) const void *pRDATData,
  263. _In_ uint32_t RDATSize);
  264. bool VerifyFeatureInfoMatches(_In_ llvm::Module *pModule,
  265. _In_reads_bytes_(FeatureInfoSize) const void *pFeatureInfoData,
  266. _In_ uint32_t FeatureInfoSize);
  267. // Validate the container parts, assuming supplied module is valid, loaded from the container provided
  268. struct DxilContainerHeader;
  269. HRESULT ValidateDxilContainerParts(_In_ llvm::Module *pModule,
  270. _In_opt_ llvm::Module *pDebugModule,
  271. _In_reads_bytes_(ContainerSize) const DxilContainerHeader *pContainer,
  272. _In_ uint32_t ContainerSize);
  273. // Loads module, validating load, but not module.
  274. HRESULT ValidateLoadModule(_In_reads_bytes_(ILLength) const char *pIL,
  275. _In_ uint32_t ILLength,
  276. _In_ std::unique_ptr<llvm::Module> &pModule,
  277. _In_ llvm::LLVMContext &Ctx,
  278. _In_ llvm::raw_ostream &DiagStream,
  279. _In_ unsigned bLazyLoad);
  280. // Loads module from container, validating load, but not module.
  281. HRESULT ValidateLoadModuleFromContainer(
  282. _In_reads_bytes_(ContainerSize) const void *pContainer,
  283. _In_ uint32_t ContainerSize, _In_ std::unique_ptr<llvm::Module> &pModule,
  284. _In_ std::unique_ptr<llvm::Module> &pDebugModule,
  285. _In_ llvm::LLVMContext &Ctx, llvm::LLVMContext &DbgCtx,
  286. _In_ llvm::raw_ostream &DiagStream);
  287. // Lazy loads module from container, validating load, but not module.
  288. HRESULT ValidateLoadModuleFromContainerLazy(
  289. _In_reads_bytes_(ContainerSize) const void *pContainer,
  290. _In_ uint32_t ContainerSize, _In_ std::unique_ptr<llvm::Module> &pModule,
  291. _In_ std::unique_ptr<llvm::Module> &pDebugModule,
  292. _In_ llvm::LLVMContext &Ctx, llvm::LLVMContext &DbgCtx,
  293. _In_ llvm::raw_ostream &DiagStream);
  294. // Load and validate Dxil module from bitcode.
  295. HRESULT ValidateDxilBitcode(_In_reads_bytes_(ILLength) const char *pIL,
  296. _In_ uint32_t ILLength,
  297. _In_ llvm::raw_ostream &DiagStream);
  298. // Full container validation, including ValidateDxilModule
  299. HRESULT ValidateDxilContainer(_In_reads_bytes_(ContainerSize) const void *pContainer,
  300. _In_ uint32_t ContainerSize,
  301. _In_ llvm::raw_ostream &DiagStream);
  302. class PrintDiagnosticContext {
  303. private:
  304. llvm::DiagnosticPrinter &m_Printer;
  305. bool m_errorsFound;
  306. bool m_warningsFound;
  307. public:
  308. PrintDiagnosticContext(llvm::DiagnosticPrinter &printer);
  309. bool HasErrors() const;
  310. bool HasWarnings() const;
  311. void Handle(const llvm::DiagnosticInfo &DI);
  312. static void PrintDiagnosticHandler(const llvm::DiagnosticInfo &DI,
  313. void *Context);
  314. };
  315. }