blob: 31004328855407e33c4353c6d574756f34527a25 [file] [log] [blame]
Douglas Gregor29233802011-03-23 15:13:44 +00001//===--- DelayedDiagnostic.cpp - Delayed declarator diagnostics -*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the DelayedDiagnostic class implementation, which
11// is used to record diagnostics that are being conditionally produced
12// during declarator parsing.
13//
14// This file also defines AccessedEntity.
15//
16//===----------------------------------------------------------------------===//
17#include "clang/Sema/DelayedDiagnostic.h"
18#include <string.h>
19using namespace clang;
20using namespace sema;
21
22DelayedDiagnostic DelayedDiagnostic::makeDeprecation(SourceLocation Loc,
Fariborz Jahanianb0a66152012-03-02 21:50:02 +000023 const NamedDecl *D,
24 const ObjCInterfaceDecl *UnknownObjCClass,
Fariborz Jahanianfd090882012-09-21 20:46:37 +000025 const ObjCPropertyDecl *ObjCProperty,
Fariborz Jahanianb0a66152012-03-02 21:50:02 +000026 StringRef Msg) {
Douglas Gregor29233802011-03-23 15:13:44 +000027 DelayedDiagnostic DD;
28 DD.Kind = Deprecation;
29 DD.Triggered = false;
30 DD.Loc = Loc;
31 DD.DeprecationData.Decl = D;
Fariborz Jahanianb0a66152012-03-02 21:50:02 +000032 DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
Fariborz Jahanianfd090882012-09-21 20:46:37 +000033 DD.DeprecationData.ObjCProperty = ObjCProperty;
Douglas Gregor29233802011-03-23 15:13:44 +000034 char *MessageData = 0;
35 if (Msg.size()) {
36 MessageData = new char [Msg.size()];
37 memcpy(MessageData, Msg.data(), Msg.size());
38 }
39
40 DD.DeprecationData.Message = MessageData;
41 DD.DeprecationData.MessageLen = Msg.size();
42 return DD;
43}
44
45void DelayedDiagnostic::Destroy() {
46 switch (Kind) {
47 case Access:
48 getAccessData().~AccessedEntity();
49 break;
50
51 case Deprecation:
52 delete [] DeprecationData.Message;
53 break;
John McCallf85e1932011-06-15 23:02:42 +000054
55 case ForbiddenType:
56 break;
Douglas Gregor29233802011-03-23 15:13:44 +000057 }
58}