[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / lib / APINotes / APINotesYAMLCompiler.cpp
blob647455111214c59b8fd8c9a2cbcf28999601070b
1 //===-- APINotesYAMLCompiler.cpp - API Notes YAML Format Reader -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // The types defined locally are designed to represent the YAML state, which
10 // adds an additional bit of state: e.g. a tri-state boolean attribute (yes, no,
11 // not applied) becomes a tri-state boolean + present. As a result, while these
12 // enumerations appear to be redefining constants from the attributes table
13 // data, they are distinct.
16 #include "clang/APINotes/APINotesYAMLCompiler.h"
17 #include "clang/APINotes/Types.h"
18 #include "clang/Basic/LLVM.h"
19 #include "clang/Basic/Specifiers.h"
20 #include "llvm/Support/VersionTuple.h"
21 #include "llvm/Support/YAMLParser.h"
22 #include "llvm/Support/YAMLTraits.h"
23 #include <optional>
24 #include <vector>
25 using namespace clang;
26 using namespace api_notes;
28 namespace {
29 enum class APIAvailability {
30 Available = 0,
31 None,
32 NonSwift,
34 } // namespace
36 namespace llvm {
37 namespace yaml {
38 template <> struct ScalarEnumerationTraits<APIAvailability> {
39 static void enumeration(IO &IO, APIAvailability &AA) {
40 IO.enumCase(AA, "none", APIAvailability::None);
41 IO.enumCase(AA, "nonswift", APIAvailability::NonSwift);
42 IO.enumCase(AA, "available", APIAvailability::Available);
45 } // namespace yaml
46 } // namespace llvm
48 namespace {
49 enum class MethodKind {
50 Class,
51 Instance,
53 } // namespace
55 namespace llvm {
56 namespace yaml {
57 template <> struct ScalarEnumerationTraits<MethodKind> {
58 static void enumeration(IO &IO, MethodKind &MK) {
59 IO.enumCase(MK, "Class", MethodKind::Class);
60 IO.enumCase(MK, "Instance", MethodKind::Instance);
63 } // namespace yaml
64 } // namespace llvm
66 namespace {
67 struct Param {
68 unsigned Position;
69 std::optional<bool> NoEscape = false;
70 std::optional<NullabilityKind> Nullability;
71 std::optional<RetainCountConventionKind> RetainCountConvention;
72 StringRef Type;
75 typedef std::vector<Param> ParamsSeq;
76 } // namespace
78 LLVM_YAML_IS_SEQUENCE_VECTOR(Param)
79 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(NullabilityKind)
81 namespace llvm {
82 namespace yaml {
83 template <> struct ScalarEnumerationTraits<NullabilityKind> {
84 static void enumeration(IO &IO, NullabilityKind &NK) {
85 IO.enumCase(NK, "Nonnull", NullabilityKind::NonNull);
86 IO.enumCase(NK, "Optional", NullabilityKind::Nullable);
87 IO.enumCase(NK, "Unspecified", NullabilityKind::Unspecified);
88 IO.enumCase(NK, "NullableResult", NullabilityKind::NullableResult);
89 // TODO: Mapping this to it's own value would allow for better cross
90 // checking. Also the default should be Unknown.
91 IO.enumCase(NK, "Scalar", NullabilityKind::Unspecified);
93 // Aliases for compatibility with existing APINotes.
94 IO.enumCase(NK, "N", NullabilityKind::NonNull);
95 IO.enumCase(NK, "O", NullabilityKind::Nullable);
96 IO.enumCase(NK, "U", NullabilityKind::Unspecified);
97 IO.enumCase(NK, "S", NullabilityKind::Unspecified);
101 template <> struct ScalarEnumerationTraits<RetainCountConventionKind> {
102 static void enumeration(IO &IO, RetainCountConventionKind &RCCK) {
103 IO.enumCase(RCCK, "none", RetainCountConventionKind::None);
104 IO.enumCase(RCCK, "CFReturnsRetained",
105 RetainCountConventionKind::CFReturnsRetained);
106 IO.enumCase(RCCK, "CFReturnsNotRetained",
107 RetainCountConventionKind::CFReturnsNotRetained);
108 IO.enumCase(RCCK, "NSReturnsRetained",
109 RetainCountConventionKind::NSReturnsRetained);
110 IO.enumCase(RCCK, "NSReturnsNotRetained",
111 RetainCountConventionKind::NSReturnsNotRetained);
115 template <> struct MappingTraits<Param> {
116 static void mapping(IO &IO, Param &P) {
117 IO.mapRequired("Position", P.Position);
118 IO.mapOptional("Nullability", P.Nullability, std::nullopt);
119 IO.mapOptional("RetainCountConvention", P.RetainCountConvention);
120 IO.mapOptional("NoEscape", P.NoEscape);
121 IO.mapOptional("Type", P.Type, StringRef(""));
124 } // namespace yaml
125 } // namespace llvm
127 namespace {
128 typedef std::vector<NullabilityKind> NullabilitySeq;
130 struct AvailabilityItem {
131 APIAvailability Mode = APIAvailability::Available;
132 StringRef Msg;
135 /// Old attribute deprecated in favor of SwiftName.
136 enum class FactoryAsInitKind {
137 /// Infer based on name and type (the default).
138 Infer,
139 /// Treat as a class method.
140 AsClassMethod,
141 /// Treat as an initializer.
142 AsInitializer,
145 struct Method {
146 StringRef Selector;
147 MethodKind Kind;
148 ParamsSeq Params;
149 NullabilitySeq Nullability;
150 std::optional<NullabilityKind> NullabilityOfRet;
151 std::optional<RetainCountConventionKind> RetainCountConvention;
152 AvailabilityItem Availability;
153 std::optional<bool> SwiftPrivate;
154 StringRef SwiftName;
155 FactoryAsInitKind FactoryAsInit = FactoryAsInitKind::Infer;
156 bool DesignatedInit = false;
157 bool Required = false;
158 StringRef ResultType;
161 typedef std::vector<Method> MethodsSeq;
162 } // namespace
164 LLVM_YAML_IS_SEQUENCE_VECTOR(Method)
166 namespace llvm {
167 namespace yaml {
168 template <> struct ScalarEnumerationTraits<FactoryAsInitKind> {
169 static void enumeration(IO &IO, FactoryAsInitKind &FIK) {
170 IO.enumCase(FIK, "A", FactoryAsInitKind::Infer);
171 IO.enumCase(FIK, "C", FactoryAsInitKind::AsClassMethod);
172 IO.enumCase(FIK, "I", FactoryAsInitKind::AsInitializer);
176 template <> struct MappingTraits<Method> {
177 static void mapping(IO &IO, Method &M) {
178 IO.mapRequired("Selector", M.Selector);
179 IO.mapRequired("MethodKind", M.Kind);
180 IO.mapOptional("Parameters", M.Params);
181 IO.mapOptional("Nullability", M.Nullability);
182 IO.mapOptional("NullabilityOfRet", M.NullabilityOfRet, std::nullopt);
183 IO.mapOptional("RetainCountConvention", M.RetainCountConvention);
184 IO.mapOptional("Availability", M.Availability.Mode,
185 APIAvailability::Available);
186 IO.mapOptional("AvailabilityMsg", M.Availability.Msg, StringRef(""));
187 IO.mapOptional("SwiftPrivate", M.SwiftPrivate);
188 IO.mapOptional("SwiftName", M.SwiftName, StringRef(""));
189 IO.mapOptional("FactoryAsInit", M.FactoryAsInit, FactoryAsInitKind::Infer);
190 IO.mapOptional("DesignatedInit", M.DesignatedInit, false);
191 IO.mapOptional("Required", M.Required, false);
192 IO.mapOptional("ResultType", M.ResultType, StringRef(""));
195 } // namespace yaml
196 } // namespace llvm
198 namespace {
199 struct Property {
200 StringRef Name;
201 std::optional<MethodKind> Kind;
202 std::optional<NullabilityKind> Nullability;
203 AvailabilityItem Availability;
204 std::optional<bool> SwiftPrivate;
205 StringRef SwiftName;
206 std::optional<bool> SwiftImportAsAccessors;
207 StringRef Type;
210 typedef std::vector<Property> PropertiesSeq;
211 } // namespace
213 LLVM_YAML_IS_SEQUENCE_VECTOR(Property)
215 namespace llvm {
216 namespace yaml {
217 template <> struct MappingTraits<Property> {
218 static void mapping(IO &IO, Property &P) {
219 IO.mapRequired("Name", P.Name);
220 IO.mapOptional("PropertyKind", P.Kind);
221 IO.mapOptional("Nullability", P.Nullability, std::nullopt);
222 IO.mapOptional("Availability", P.Availability.Mode,
223 APIAvailability::Available);
224 IO.mapOptional("AvailabilityMsg", P.Availability.Msg, StringRef(""));
225 IO.mapOptional("SwiftPrivate", P.SwiftPrivate);
226 IO.mapOptional("SwiftName", P.SwiftName, StringRef(""));
227 IO.mapOptional("SwiftImportAsAccessors", P.SwiftImportAsAccessors);
228 IO.mapOptional("Type", P.Type, StringRef(""));
231 } // namespace yaml
232 } // namespace llvm
234 namespace {
235 struct Class {
236 StringRef Name;
237 bool AuditedForNullability = false;
238 AvailabilityItem Availability;
239 std::optional<bool> SwiftPrivate;
240 StringRef SwiftName;
241 std::optional<StringRef> SwiftBridge;
242 std::optional<StringRef> NSErrorDomain;
243 std::optional<bool> SwiftImportAsNonGeneric;
244 std::optional<bool> SwiftObjCMembers;
245 MethodsSeq Methods;
246 PropertiesSeq Properties;
249 typedef std::vector<Class> ClassesSeq;
250 } // namespace
252 LLVM_YAML_IS_SEQUENCE_VECTOR(Class)
254 namespace llvm {
255 namespace yaml {
256 template <> struct MappingTraits<Class> {
257 static void mapping(IO &IO, Class &C) {
258 IO.mapRequired("Name", C.Name);
259 IO.mapOptional("AuditedForNullability", C.AuditedForNullability, false);
260 IO.mapOptional("Availability", C.Availability.Mode,
261 APIAvailability::Available);
262 IO.mapOptional("AvailabilityMsg", C.Availability.Msg, StringRef(""));
263 IO.mapOptional("SwiftPrivate", C.SwiftPrivate);
264 IO.mapOptional("SwiftName", C.SwiftName, StringRef(""));
265 IO.mapOptional("SwiftBridge", C.SwiftBridge);
266 IO.mapOptional("NSErrorDomain", C.NSErrorDomain);
267 IO.mapOptional("SwiftImportAsNonGeneric", C.SwiftImportAsNonGeneric);
268 IO.mapOptional("SwiftObjCMembers", C.SwiftObjCMembers);
269 IO.mapOptional("Methods", C.Methods);
270 IO.mapOptional("Properties", C.Properties);
273 } // namespace yaml
274 } // namespace llvm
276 namespace {
277 struct Function {
278 StringRef Name;
279 ParamsSeq Params;
280 NullabilitySeq Nullability;
281 std::optional<NullabilityKind> NullabilityOfRet;
282 std::optional<api_notes::RetainCountConventionKind> RetainCountConvention;
283 AvailabilityItem Availability;
284 std::optional<bool> SwiftPrivate;
285 StringRef SwiftName;
286 StringRef Type;
287 StringRef ResultType;
290 typedef std::vector<Function> FunctionsSeq;
291 } // namespace
293 LLVM_YAML_IS_SEQUENCE_VECTOR(Function)
295 namespace llvm {
296 namespace yaml {
297 template <> struct MappingTraits<Function> {
298 static void mapping(IO &IO, Function &F) {
299 IO.mapRequired("Name", F.Name);
300 IO.mapOptional("Parameters", F.Params);
301 IO.mapOptional("Nullability", F.Nullability);
302 IO.mapOptional("NullabilityOfRet", F.NullabilityOfRet, std::nullopt);
303 IO.mapOptional("RetainCountConvention", F.RetainCountConvention);
304 IO.mapOptional("Availability", F.Availability.Mode,
305 APIAvailability::Available);
306 IO.mapOptional("AvailabilityMsg", F.Availability.Msg, StringRef(""));
307 IO.mapOptional("SwiftPrivate", F.SwiftPrivate);
308 IO.mapOptional("SwiftName", F.SwiftName, StringRef(""));
309 IO.mapOptional("ResultType", F.ResultType, StringRef(""));
312 } // namespace yaml
313 } // namespace llvm
315 namespace {
316 struct GlobalVariable {
317 StringRef Name;
318 std::optional<NullabilityKind> Nullability;
319 AvailabilityItem Availability;
320 std::optional<bool> SwiftPrivate;
321 StringRef SwiftName;
322 StringRef Type;
325 typedef std::vector<GlobalVariable> GlobalVariablesSeq;
326 } // namespace
328 LLVM_YAML_IS_SEQUENCE_VECTOR(GlobalVariable)
330 namespace llvm {
331 namespace yaml {
332 template <> struct MappingTraits<GlobalVariable> {
333 static void mapping(IO &IO, GlobalVariable &GV) {
334 IO.mapRequired("Name", GV.Name);
335 IO.mapOptional("Nullability", GV.Nullability, std::nullopt);
336 IO.mapOptional("Availability", GV.Availability.Mode,
337 APIAvailability::Available);
338 IO.mapOptional("AvailabilityMsg", GV.Availability.Msg, StringRef(""));
339 IO.mapOptional("SwiftPrivate", GV.SwiftPrivate);
340 IO.mapOptional("SwiftName", GV.SwiftName, StringRef(""));
341 IO.mapOptional("Type", GV.Type, StringRef(""));
344 } // namespace yaml
345 } // namespace llvm
347 namespace {
348 struct EnumConstant {
349 StringRef Name;
350 AvailabilityItem Availability;
351 std::optional<bool> SwiftPrivate;
352 StringRef SwiftName;
355 typedef std::vector<EnumConstant> EnumConstantsSeq;
356 } // namespace
358 LLVM_YAML_IS_SEQUENCE_VECTOR(EnumConstant)
360 namespace llvm {
361 namespace yaml {
362 template <> struct MappingTraits<EnumConstant> {
363 static void mapping(IO &IO, EnumConstant &EC) {
364 IO.mapRequired("Name", EC.Name);
365 IO.mapOptional("Availability", EC.Availability.Mode,
366 APIAvailability::Available);
367 IO.mapOptional("AvailabilityMsg", EC.Availability.Msg, StringRef(""));
368 IO.mapOptional("SwiftPrivate", EC.SwiftPrivate);
369 IO.mapOptional("SwiftName", EC.SwiftName, StringRef(""));
372 } // namespace yaml
373 } // namespace llvm
375 namespace {
376 /// Syntactic sugar for EnumExtensibility and FlagEnum
377 enum class EnumConvenienceAliasKind {
378 /// EnumExtensibility: none, FlagEnum: false
379 None,
380 /// EnumExtensibility: open, FlagEnum: false
381 CFEnum,
382 /// EnumExtensibility: open, FlagEnum: true
383 CFOptions,
384 /// EnumExtensibility: closed, FlagEnum: false
385 CFClosedEnum
387 } // namespace
389 namespace llvm {
390 namespace yaml {
391 template <> struct ScalarEnumerationTraits<EnumConvenienceAliasKind> {
392 static void enumeration(IO &IO, EnumConvenienceAliasKind &ECAK) {
393 IO.enumCase(ECAK, "none", EnumConvenienceAliasKind::None);
394 IO.enumCase(ECAK, "CFEnum", EnumConvenienceAliasKind::CFEnum);
395 IO.enumCase(ECAK, "NSEnum", EnumConvenienceAliasKind::CFEnum);
396 IO.enumCase(ECAK, "CFOptions", EnumConvenienceAliasKind::CFOptions);
397 IO.enumCase(ECAK, "NSOptions", EnumConvenienceAliasKind::CFOptions);
398 IO.enumCase(ECAK, "CFClosedEnum", EnumConvenienceAliasKind::CFClosedEnum);
399 IO.enumCase(ECAK, "NSClosedEnum", EnumConvenienceAliasKind::CFClosedEnum);
402 } // namespace yaml
403 } // namespace llvm
405 namespace {
406 struct Tag {
407 StringRef Name;
408 AvailabilityItem Availability;
409 StringRef SwiftName;
410 std::optional<bool> SwiftPrivate;
411 std::optional<StringRef> SwiftBridge;
412 std::optional<StringRef> NSErrorDomain;
413 std::optional<std::string> SwiftImportAs;
414 std::optional<std::string> SwiftRetainOp;
415 std::optional<std::string> SwiftReleaseOp;
416 std::optional<EnumExtensibilityKind> EnumExtensibility;
417 std::optional<bool> FlagEnum;
418 std::optional<EnumConvenienceAliasKind> EnumConvenienceKind;
421 typedef std::vector<Tag> TagsSeq;
422 } // namespace
424 LLVM_YAML_IS_SEQUENCE_VECTOR(Tag)
426 namespace llvm {
427 namespace yaml {
428 template <> struct ScalarEnumerationTraits<EnumExtensibilityKind> {
429 static void enumeration(IO &IO, EnumExtensibilityKind &EEK) {
430 IO.enumCase(EEK, "none", EnumExtensibilityKind::None);
431 IO.enumCase(EEK, "open", EnumExtensibilityKind::Open);
432 IO.enumCase(EEK, "closed", EnumExtensibilityKind::Closed);
436 template <> struct MappingTraits<Tag> {
437 static void mapping(IO &IO, Tag &T) {
438 IO.mapRequired("Name", T.Name);
439 IO.mapOptional("Availability", T.Availability.Mode,
440 APIAvailability::Available);
441 IO.mapOptional("AvailabilityMsg", T.Availability.Msg, StringRef(""));
442 IO.mapOptional("SwiftPrivate", T.SwiftPrivate);
443 IO.mapOptional("SwiftName", T.SwiftName, StringRef(""));
444 IO.mapOptional("SwiftBridge", T.SwiftBridge);
445 IO.mapOptional("NSErrorDomain", T.NSErrorDomain);
446 IO.mapOptional("SwiftImportAs", T.SwiftImportAs);
447 IO.mapOptional("SwiftReleaseOp", T.SwiftReleaseOp);
448 IO.mapOptional("SwiftRetainOp", T.SwiftRetainOp);
449 IO.mapOptional("EnumExtensibility", T.EnumExtensibility);
450 IO.mapOptional("FlagEnum", T.FlagEnum);
451 IO.mapOptional("EnumKind", T.EnumConvenienceKind);
454 } // namespace yaml
455 } // namespace llvm
457 namespace {
458 struct Typedef {
459 StringRef Name;
460 AvailabilityItem Availability;
461 StringRef SwiftName;
462 std::optional<bool> SwiftPrivate;
463 std::optional<StringRef> SwiftBridge;
464 std::optional<StringRef> NSErrorDomain;
465 std::optional<SwiftNewTypeKind> SwiftType;
468 typedef std::vector<Typedef> TypedefsSeq;
469 } // namespace
471 LLVM_YAML_IS_SEQUENCE_VECTOR(Typedef)
473 namespace llvm {
474 namespace yaml {
475 template <> struct ScalarEnumerationTraits<SwiftNewTypeKind> {
476 static void enumeration(IO &IO, SwiftNewTypeKind &SWK) {
477 IO.enumCase(SWK, "none", SwiftNewTypeKind::None);
478 IO.enumCase(SWK, "struct", SwiftNewTypeKind::Struct);
479 IO.enumCase(SWK, "enum", SwiftNewTypeKind::Enum);
483 template <> struct MappingTraits<Typedef> {
484 static void mapping(IO &IO, Typedef &T) {
485 IO.mapRequired("Name", T.Name);
486 IO.mapOptional("Availability", T.Availability.Mode,
487 APIAvailability::Available);
488 IO.mapOptional("AvailabilityMsg", T.Availability.Msg, StringRef(""));
489 IO.mapOptional("SwiftPrivate", T.SwiftPrivate);
490 IO.mapOptional("SwiftName", T.SwiftName, StringRef(""));
491 IO.mapOptional("SwiftBridge", T.SwiftBridge);
492 IO.mapOptional("NSErrorDomain", T.NSErrorDomain);
493 IO.mapOptional("SwiftWrapper", T.SwiftType);
496 } // namespace yaml
497 } // namespace llvm
499 namespace {
500 struct Namespace;
501 typedef std::vector<Namespace> NamespacesSeq;
503 struct TopLevelItems {
504 ClassesSeq Classes;
505 ClassesSeq Protocols;
506 FunctionsSeq Functions;
507 GlobalVariablesSeq Globals;
508 EnumConstantsSeq EnumConstants;
509 TagsSeq Tags;
510 TypedefsSeq Typedefs;
511 NamespacesSeq Namespaces;
513 } // namespace
515 namespace llvm {
516 namespace yaml {
517 static void mapTopLevelItems(IO &IO, TopLevelItems &TLI) {
518 IO.mapOptional("Classes", TLI.Classes);
519 IO.mapOptional("Protocols", TLI.Protocols);
520 IO.mapOptional("Functions", TLI.Functions);
521 IO.mapOptional("Globals", TLI.Globals);
522 IO.mapOptional("Enumerators", TLI.EnumConstants);
523 IO.mapOptional("Tags", TLI.Tags);
524 IO.mapOptional("Typedefs", TLI.Typedefs);
525 IO.mapOptional("Namespaces", TLI.Namespaces);
527 } // namespace yaml
528 } // namespace llvm
530 namespace {
531 struct Namespace {
532 StringRef Name;
533 AvailabilityItem Availability;
534 StringRef SwiftName;
535 std::optional<bool> SwiftPrivate;
536 TopLevelItems Items;
538 } // namespace
540 LLVM_YAML_IS_SEQUENCE_VECTOR(Namespace)
542 namespace llvm {
543 namespace yaml {
544 template <> struct MappingTraits<Namespace> {
545 static void mapping(IO &IO, Namespace &T) {
546 IO.mapRequired("Name", T.Name);
547 IO.mapOptional("Availability", T.Availability.Mode,
548 APIAvailability::Available);
549 IO.mapOptional("AvailabilityMsg", T.Availability.Msg, StringRef(""));
550 IO.mapOptional("SwiftPrivate", T.SwiftPrivate);
551 IO.mapOptional("SwiftName", T.SwiftName, StringRef(""));
552 mapTopLevelItems(IO, T.Items);
555 } // namespace yaml
556 } // namespace llvm
558 namespace {
559 struct Versioned {
560 VersionTuple Version;
561 TopLevelItems Items;
564 typedef std::vector<Versioned> VersionedSeq;
565 } // namespace
567 LLVM_YAML_IS_SEQUENCE_VECTOR(Versioned)
569 namespace llvm {
570 namespace yaml {
571 template <> struct MappingTraits<Versioned> {
572 static void mapping(IO &IO, Versioned &V) {
573 IO.mapRequired("Version", V.Version);
574 mapTopLevelItems(IO, V.Items);
577 } // namespace yaml
578 } // namespace llvm
580 namespace {
581 struct Module {
582 StringRef Name;
583 AvailabilityItem Availability;
584 TopLevelItems TopLevel;
585 VersionedSeq SwiftVersions;
587 std::optional<bool> SwiftInferImportAsMember;
589 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
590 LLVM_DUMP_METHOD void dump() /*const*/;
591 #endif
593 } // namespace
595 namespace llvm {
596 namespace yaml {
597 template <> struct MappingTraits<Module> {
598 static void mapping(IO &IO, Module &M) {
599 IO.mapRequired("Name", M.Name);
600 IO.mapOptional("Availability", M.Availability.Mode,
601 APIAvailability::Available);
602 IO.mapOptional("AvailabilityMsg", M.Availability.Msg, StringRef(""));
603 IO.mapOptional("SwiftInferImportAsMember", M.SwiftInferImportAsMember);
604 mapTopLevelItems(IO, M.TopLevel);
605 IO.mapOptional("SwiftVersions", M.SwiftVersions);
608 } // namespace yaml
609 } // namespace llvm
611 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
612 LLVM_DUMP_METHOD void Module::dump() {
613 llvm::yaml::Output OS(llvm::errs());
614 OS << *this;
616 #endif
618 namespace {
619 bool parseAPINotes(StringRef YI, Module &M, llvm::SourceMgr::DiagHandlerTy Diag,
620 void *DiagContext) {
621 llvm::yaml::Input IS(YI, nullptr, Diag, DiagContext);
622 IS >> M;
623 return static_cast<bool>(IS.error());
625 } // namespace
627 bool clang::api_notes::parseAndDumpAPINotes(StringRef YI,
628 llvm::raw_ostream &OS) {
629 Module M;
630 if (parseAPINotes(YI, M, nullptr, nullptr))
631 return true;
633 llvm::yaml::Output YOS(OS);
634 YOS << M;
636 return false;