1 //===--- DelayedDiagnostic.cpp - Delayed declarator diagnostics -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the DelayedDiagnostic class implementation, which
11 // is used to record diagnostics that are being conditionally produced
12 // during declarator parsing.
14 // This file also defines AccessedEntity.
16 //===----------------------------------------------------------------------===//
17 #include "clang/Sema/DelayedDiagnostic.h"
19 using namespace clang;
23 DelayedDiagnostic::makeAvailability(Sema::AvailabilityDiagnostic AD,
26 const ObjCInterfaceDecl *UnknownObjCClass,
27 const ObjCPropertyDecl *ObjCProperty,
29 bool ObjCPropertyAccess) {
32 case Sema::AD_Deprecation:
33 DD.Kind = Deprecation;
35 case Sema::AD_Unavailable:
36 DD.Kind = Unavailable;
38 case Sema::AD_Partial:
39 llvm_unreachable("AD_Partial diags should not be delayed");
43 DD.DeprecationData.Decl = D;
44 DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
45 DD.DeprecationData.ObjCProperty = ObjCProperty;
46 char *MessageData = nullptr;
48 MessageData = new char [Msg.size()];
49 memcpy(MessageData, Msg.data(), Msg.size());
52 DD.DeprecationData.Message = MessageData;
53 DD.DeprecationData.MessageLen = Msg.size();
54 DD.DeprecationData.ObjCPropertyAccess = ObjCPropertyAccess;
58 void DelayedDiagnostic::Destroy() {
59 switch (static_cast<DDKind>(Kind)) {
61 getAccessData().~AccessedEntity();
66 delete [] DeprecationData.Message;