]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/Sema/DelayedDiagnostic.cpp
Merge clang 3.5.0 release from ^/vendor/clang/dist, resolve conflicts,
[FreeBSD/FreeBSD.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
23 DelayedDiagnostic::makeAvailability(Sema::AvailabilityDiagnostic AD,
24                                     SourceLocation Loc,
25                                     const NamedDecl *D,
26                                     const ObjCInterfaceDecl *UnknownObjCClass,
27                                     const ObjCPropertyDecl  *ObjCProperty,
28                                     StringRef Msg,
29                                     bool ObjCPropertyAccess) {
30   DelayedDiagnostic DD;
31   switch (AD) {
32     case Sema::AD_Deprecation:
33       DD.Kind = Deprecation;
34       break;
35     case Sema::AD_Unavailable:
36       DD.Kind = Unavailable;
37       break;
38   }
39   DD.Triggered = false;
40   DD.Loc = Loc;
41   DD.DeprecationData.Decl = D;
42   DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
43   DD.DeprecationData.ObjCProperty = ObjCProperty;
44   char *MessageData = nullptr;
45   if (Msg.size()) {
46     MessageData = new char [Msg.size()];
47     memcpy(MessageData, Msg.data(), Msg.size());
48   }
49
50   DD.DeprecationData.Message = MessageData;
51   DD.DeprecationData.MessageLen = Msg.size();
52   DD.DeprecationData.ObjCPropertyAccess = ObjCPropertyAccess;
53   return DD;
54 }
55
56 void DelayedDiagnostic::Destroy() {
57   switch (static_cast<DDKind>(Kind)) {
58   case Access: 
59     getAccessData().~AccessedEntity(); 
60     break;
61
62   case Deprecation:
63   case Unavailable:
64     delete [] DeprecationData.Message;
65     break;
66
67   case ForbiddenType:
68     break;
69   }
70 }