clang 8.0.0

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
18 #include "clang/Sema/DelayedDiagnostic.h"
19 #include <cstring>
20
21 using namespace clang;
22 using namespace sema;
23
24 DelayedDiagnostic
25 DelayedDiagnostic::makeAvailability(AvailabilityResult AR,
26 ArrayRef<SourceLocation> Locs,
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());
34 DelayedDiagnostic DD;
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
60 void DelayedDiagnostic::Destroy() {
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 }
clang::sema::DelayedDiagnostic::Kind
DDKind Kind
Definition: DelayedDiagnostic.h:134
clang::sema::DelayedDiagnostic::getAccessData
AccessedEntity & getAccessData()
Definition: DelayedDiagnostic.h:174
clang::sema::DelayedDiagnostic::ForbiddenType
Definition: DelayedDiagnostic.h:132
clang::sema::DelayedDiagnostic::Availability
Definition: DelayedDiagnostic.h:132
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1172
llvm::ArrayRef
Definition: LLVM.h:32
clang::AvailabilityResult
AvailabilityResult
Captures the result of checking the availability of a declaration.
Definition: DeclBase.h:73
clang::sema::DelayedDiagnostic::AvailabilityData
struct AD AvailabilityData
Definition: DelayedDiagnostic.h:260
DelayedDiagnostic.h
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
clang::sema::DelayedDiagnostic::Destroy
void Destroy()
Definition: DelayedDiagnostic.cpp:60
Kind
Kind
Definition: ChrootChecker.cpp:29
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::ObjCPropertyDecl
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:729
memcpy
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Definition: __clang_cuda_device_functions.h:1612
clang::sema::DelayedDiagnostic::makeAvailability
static DelayedDiagnostic makeAvailability(AvailabilityResult AR, ArrayRef< SourceLocation > Locs, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
Definition: DelayedDiagnostic.cpp:25
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::sema::DelayedDiagnostic
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
Definition: DelayedDiagnostic.h:130
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:249
clang::sema::DelayedDiagnostic::Access
Definition: DelayedDiagnostic.h:132