]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/tools/clang/lib/Sema/DelayedDiagnostic.cpp
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / tools / clang / lib / Sema / DelayedDiagnostic.cpp
1 //===--- 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>
19 using namespace clang;
20 using namespace sema;
21
22 DelayedDiagnostic DelayedDiagnostic::makeDeprecation(SourceLocation Loc,
23                                     const NamedDecl *D,
24                                     const ObjCInterfaceDecl *UnknownObjCClass,
25                                     const ObjCPropertyDecl  *ObjCProperty,
26                                     StringRef Msg) {
27   DelayedDiagnostic DD;
28   DD.Kind = Deprecation;
29   DD.Triggered = false;
30   DD.Loc = Loc;
31   DD.DeprecationData.Decl = D;
32   DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
33   DD.DeprecationData.ObjCProperty = ObjCProperty;
34   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
45 void DelayedDiagnostic::Destroy() {
46   switch (Kind) {
47   case Access: 
48     getAccessData().~AccessedEntity(); 
49     break;
50
51   case Deprecation: 
52     delete [] DeprecationData.Message;
53     break;
54
55   case ForbiddenType:
56     break;
57   }
58 }