clang  7.0.0svn
DelayedDiagnostic.cpp
Go to the documentation of this file.
1 //===- DelayedDiagnostic.cpp - Delayed declarator diagnostics -------------===//
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 
19 #include <cstring>
20 
21 using namespace clang;
22 using namespace sema;
23 
26  SourceLocation Loc,
27  const NamedDecl *ReferringDecl,
28  const NamedDecl *OffendingDecl,
29  const ObjCInterfaceDecl *UnknownObjCClass,
30  const ObjCPropertyDecl *ObjCProperty,
31  StringRef Msg,
32  bool ObjCPropertyAccess) {
34  DD.Kind = Availability;
35  DD.Triggered = false;
36  DD.Loc = Loc;
37  DD.AvailabilityData.ReferringDecl = ReferringDecl;
38  DD.AvailabilityData.OffendingDecl = OffendingDecl;
39  DD.AvailabilityData.UnknownObjCClass = UnknownObjCClass;
40  DD.AvailabilityData.ObjCProperty = ObjCProperty;
41  char *MessageData = nullptr;
42  if (!Msg.empty()) {
43  MessageData = new char [Msg.size()];
44  memcpy(MessageData, Msg.data(), Msg.size());
45  }
46 
47  DD.AvailabilityData.Message = MessageData;
48  DD.AvailabilityData.MessageLen = Msg.size();
49  DD.AvailabilityData.AR = AR;
50  DD.AvailabilityData.ObjCPropertyAccess = ObjCPropertyAccess;
51  return DD;
52 }
53 
55  switch (Kind) {
56  case Access:
57  getAccessData().~AccessedEntity();
58  break;
59 
60  case Availability:
61  delete[] AvailabilityData.Message;
62  break;
63 
64  case ForbiddenType:
65  break;
66  }
67 }
static DelayedDiagnostic makeAvailability(AvailabilityResult AR, SourceLocation Loc, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
Represents an ObjC class declaration.
Definition: DeclObjC.h:1191
AvailabilityResult
Captures the result of checking the availability of a declaration.
Definition: DeclBase.h:72
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Kind
Encodes a location in the source.
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:746
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Dataflow Directional Tag Classes.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
This represents a decl that may have a name.
Definition: Decl.h:248