blob: d6c1ad13a854a78064d96b07293db4edc9a12450 [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,
23 const NamedDecl *D,
Chris Lattner5f9e2722011-07-23 10:55:15 +000024 StringRef Msg) {
Douglas Gregor29233802011-03-23 15:13:44 +000025 DelayedDiagnostic DD;
26 DD.Kind = Deprecation;
27 DD.Triggered = false;
28 DD.Loc = Loc;
29 DD.DeprecationData.Decl = D;
30 char *MessageData = 0;
31 if (Msg.size()) {
32 MessageData = new char [Msg.size()];
33 memcpy(MessageData, Msg.data(), Msg.size());
34 }
35
36 DD.DeprecationData.Message = MessageData;
37 DD.DeprecationData.MessageLen = Msg.size();
38 return DD;
39}
40
41void DelayedDiagnostic::Destroy() {
42 switch (Kind) {
43 case Access:
44 getAccessData().~AccessedEntity();
45 break;
46
47 case Deprecation:
48 delete [] DeprecationData.Message;
49 break;
John McCallf85e1932011-06-15 23:02:42 +000050
51 case ForbiddenType:
52 break;
Douglas Gregor29233802011-03-23 15:13:44 +000053 }
54}