blob: 876f9d7a95458efa299ec947e1cefe7126385a74 [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,
25 StringRef Msg) {
Douglas Gregor29233802011-03-23 15:13:44 +000026 DelayedDiagnostic DD;
27 DD.Kind = Deprecation;
28 DD.Triggered = false;
29 DD.Loc = Loc;
30 DD.DeprecationData.Decl = D;
Fariborz Jahanianb0a66152012-03-02 21:50:02 +000031 DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
Douglas Gregor29233802011-03-23 15:13:44 +000032 char *MessageData = 0;
33 if (Msg.size()) {
34 MessageData = new char [Msg.size()];
35 memcpy(MessageData, Msg.data(), Msg.size());
36 }
37
38 DD.DeprecationData.Message = MessageData;
39 DD.DeprecationData.MessageLen = Msg.size();
40 return DD;
41}
42
43void DelayedDiagnostic::Destroy() {
44 switch (Kind) {
45 case Access:
46 getAccessData().~AccessedEntity();
47 break;
48
49 case Deprecation:
50 delete [] DeprecationData.Message;
51 break;
John McCallf85e1932011-06-15 23:02:42 +000052
53 case ForbiddenType:
54 break;
Douglas Gregor29233802011-03-23 15:13:44 +000055 }
56}