clang  8.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 
27  const NamedDecl *ReferringDecl,
28  const NamedDecl *OffendingDecl,
29  const ObjCInterfaceDecl *UnknownObjCClass,
30  const ObjCPropertyDecl *ObjCProperty,
31  StringRef Msg,
32  bool ObjCPropertyAccess) {
33  assert(!Locs.empty());
35  DD.Kind = Availability;
36  DD.Triggered = false;
37  DD.Loc = Locs.front();
38  DD.AvailabilityData.ReferringDecl = ReferringDecl;
39  DD.AvailabilityData.OffendingDecl = OffendingDecl;
40  DD.AvailabilityData.UnknownObjCClass = UnknownObjCClass;
41  DD.AvailabilityData.ObjCProperty = ObjCProperty;
42  char *MessageData = nullptr;
43  if (!Msg.empty()) {
44  MessageData = new char [Msg.size()];
45  memcpy(MessageData, Msg.data(), Msg.size());
46  }
47  DD.AvailabilityData.Message = MessageData;
48  DD.AvailabilityData.MessageLen = Msg.size();
49 
50  DD.AvailabilityData.SelectorLocs = new SourceLocation[Locs.size()];
51  memcpy(DD.AvailabilityData.SelectorLocs, Locs.data(),
52  sizeof(SourceLocation) * Locs.size());
53  DD.AvailabilityData.NumSelectorLocs = Locs.size();
54 
55  DD.AvailabilityData.AR = AR;
56  DD.AvailabilityData.ObjCPropertyAccess = ObjCPropertyAccess;
57  return DD;
58 }
59 
61  switch (Kind) {
62  case Access:
63  getAccessData().~AccessedEntity();
64  break;
65 
66  case Availability:
67  delete[] AvailabilityData.Message;
68  delete[] AvailabilityData.SelectorLocs;
69  break;
70 
71  case ForbiddenType:
72  break;
73  }
74 }
Represents an ObjC class declaration.
Definition: DeclObjC.h:1164
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:721
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
static DelayedDiagnostic makeAvailability(AvailabilityResult AR, ArrayRef< SourceLocation > Locs, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
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