clang  6.0.0svn
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 *ReferringDecl,
26  const NamedDecl *OffendingDecl,
27  const ObjCInterfaceDecl *UnknownObjCClass,
28  const ObjCPropertyDecl *ObjCProperty,
29  StringRef Msg,
30  bool ObjCPropertyAccess) {
32  DD.Kind = Availability;
33  DD.Triggered = false;
34  DD.Loc = Loc;
35  DD.AvailabilityData.ReferringDecl = ReferringDecl;
36  DD.AvailabilityData.OffendingDecl = OffendingDecl;
37  DD.AvailabilityData.UnknownObjCClass = UnknownObjCClass;
38  DD.AvailabilityData.ObjCProperty = ObjCProperty;
39  char *MessageData = nullptr;
40  if (Msg.size()) {
41  MessageData = new char [Msg.size()];
42  memcpy(MessageData, Msg.data(), Msg.size());
43  }
44 
45  DD.AvailabilityData.Message = MessageData;
46  DD.AvailabilityData.MessageLen = Msg.size();
47  DD.AvailabilityData.AR = AR;
48  DD.AvailabilityData.ObjCPropertyAccess = ObjCPropertyAccess;
49  return DD;
50 }
51 
53  switch (Kind) {
54  case Access:
55  getAccessData().~AccessedEntity();
56  break;
57 
58  case Availability:
59  delete[] AvailabilityData.Message;
60  break;
61 
62  case ForbiddenType:
63  break;
64  }
65 }
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
Dataflow Directional Tag Classes.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
NamedDecl - This represents a decl with a name.
Definition: Decl.h:245