clang  3.7.0
DelayedDiagnostic.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
18 #include <string.h>
19 using namespace clang;
20 using namespace sema;
21 
24  SourceLocation Loc,
25  const NamedDecl *D,
26  const ObjCInterfaceDecl *UnknownObjCClass,
27  const ObjCPropertyDecl *ObjCProperty,
28  StringRef Msg,
29  bool ObjCPropertyAccess) {
31  switch (AD) {
33  DD.Kind = Deprecation;
34  break;
36  DD.Kind = Unavailable;
37  break;
38  case Sema::AD_Partial:
39  llvm_unreachable("AD_Partial diags should not be delayed");
40  }
41  DD.Triggered = false;
42  DD.Loc = Loc;
43  DD.DeprecationData.Decl = D;
44  DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
45  DD.DeprecationData.ObjCProperty = ObjCProperty;
46  char *MessageData = nullptr;
47  if (Msg.size()) {
48  MessageData = new char [Msg.size()];
49  memcpy(MessageData, Msg.data(), Msg.size());
50  }
51 
52  DD.DeprecationData.Message = MessageData;
53  DD.DeprecationData.MessageLen = Msg.size();
54  DD.DeprecationData.ObjCPropertyAccess = ObjCPropertyAccess;
55  return DD;
56 }
57 
59  switch (static_cast<DDKind>(Kind)) {
60  case Access:
61  getAccessData().~AccessedEntity();
62  break;
63 
64  case Deprecation:
65  case Unavailable:
66  delete [] DeprecationData.Message;
67  break;
68 
69  case ForbiddenType:
70  break;
71  }
72 }
Represents an ObjC class declaration.
Definition: DeclObjC.h:851
struct DD DeprecationData
Deprecation.
static DelayedDiagnostic makeAvailability(Sema::AvailabilityDiagnostic AD, SourceLocation Loc, const NamedDecl *D, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Kind
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
AvailabilityDiagnostic
Definition: Sema.h:3476
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:2424