1 //===- DelayedDiagnostic.cpp - Delayed declarator diagnostics -------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines the DelayedDiagnostic class implementation, which
10 // is used to record diagnostics that are being conditionally produced
11 // during declarator parsing.
13 // This file also defines AccessedEntity.
15 //===----------------------------------------------------------------------===//
17 #include "clang/Sema/DelayedDiagnostic.h"
20 using namespace clang;
24 DelayedDiagnostic::makeAvailability(AvailabilityResult AR,
25 ArrayRef<SourceLocation> Locs,
26 const NamedDecl *ReferringDecl,
27 const NamedDecl *OffendingDecl,
28 const ObjCInterfaceDecl *UnknownObjCClass,
29 const ObjCPropertyDecl *ObjCProperty,
31 bool ObjCPropertyAccess) {
32 assert(!Locs.empty());
34 DD.Kind = Availability;
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;
43 MessageData = new char [Msg.size()];
44 memcpy(MessageData, Msg.data(), Msg.size());
46 DD.AvailabilityData.Message = MessageData;
47 DD.AvailabilityData.MessageLen = Msg.size();
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();
54 DD.AvailabilityData.AR = AR;
55 DD.AvailabilityData.ObjCPropertyAccess = ObjCPropertyAccess;
59 void DelayedDiagnostic::Destroy() {
62 getAccessData().~AccessedEntity();
66 delete[] AvailabilityData.Message;
67 delete[] AvailabilityData.SelectorLocs;