clang 20.0.0git
DelayedDiagnostic.cpp
Go to the documentation of this file.
1//===- DelayedDiagnostic.cpp - Delayed declarator diagnostics -------------===//
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// This file defines the DelayedDiagnostic class implementation, which
10// is used to record diagnostics that are being conditionally produced
11// during declarator parsing.
12//
13// This file also defines AccessedEntity.
14//
15//===----------------------------------------------------------------------===//
16
18#include <cstring>
19
20using namespace clang;
21using namespace sema;
22
26 const NamedDecl *ReferringDecl,
27 const NamedDecl *OffendingDecl,
28 const ObjCInterfaceDecl *UnknownObjCClass,
29 const ObjCPropertyDecl *ObjCProperty,
30 StringRef Msg,
31 bool ObjCPropertyAccess) {
32 assert(!Locs.empty());
34 DD.Kind = Availability;
35 DD.Triggered = false;
36 DD.Loc = Locs.front();
37 DD.AvailabilityData.ReferringDecl = ReferringDecl;
38 DD.AvailabilityData.OffendingDecl = OffendingDecl;
39 DD.AvailabilityData.UnknownObjCClass = UnknownObjCClass;
40 DD.AvailabilityData.ObjCProperty = ObjCProperty;
41 char *MessageData = nullptr;
42 if (!Msg.empty()) {
43 MessageData = new char [Msg.size()];
44 memcpy(MessageData, Msg.data(), Msg.size());
45 }
46 DD.AvailabilityData.Message = MessageData;
47 DD.AvailabilityData.MessageLen = Msg.size();
48
49 DD.AvailabilityData.SelectorLocs = new SourceLocation[Locs.size()];
50 memcpy(DD.AvailabilityData.SelectorLocs, Locs.data(),
51 sizeof(SourceLocation) * Locs.size());
52 DD.AvailabilityData.NumSelectorLocs = Locs.size();
53
54 DD.AvailabilityData.AR = AR;
55 DD.AvailabilityData.ObjCPropertyAccess = ObjCPropertyAccess;
56 return DD;
57}
58
60 switch (Kind) {
61 case Access:
62 getAccessData().~AccessedEntity();
63 break;
64
65 case Availability:
66 delete[] AvailabilityData.Message;
67 delete[] AvailabilityData.SelectorLocs;
68 break;
69
70 case ForbiddenType:
71 break;
72 }
73}
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
This represents a decl that may have a name.
Definition: Decl.h:249
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:730
Encodes a location in the source.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
static DelayedDiagnostic makeAvailability(AvailabilityResult AR, ArrayRef< SourceLocation > Locs, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
The JSON file list parser is used to communicate input to InstallAPI.
AvailabilityResult
Captures the result of checking the availability of a declaration.
Definition: DeclBase.h:72