clang 10.0.0git

DelayedDiagnostic.cpp
Go to the documentation of this file.
1 //===- DelayedDiagnostic.cpp - Delayed declarator diagnostics -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the DelayedDiagnostic class implementation, which
10 // is used to record diagnostics that are being conditionally produced
11 // during declarator parsing.
12 //
13 // This file also defines AccessedEntity.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #include "clang/Sema/DelayedDiagnostic.h"
18 #include <cstring>
19
20 using namespace clang;
21 using namespace sema;
22
23 DelayedDiagnostic
24 DelayedDiagnostic::makeAvailability(AvailabilityResult AR,
25 ArrayRef<SourceLocation> Locs,
26 const NamedDecl *ReferringDecl,
27 const NamedDecl *OffendingDecl,
28 const ObjCInterfaceDecl *UnknownObjCClass,
29 const ObjCPropertyDecl *ObjCProperty,
30 StringRef Msg,
31 bool ObjCPropertyAccess) {
32 assert(!Locs.empty());
33 DelayedDiagnostic DD;
34 DD.Kind = Availability;
35 DD.Triggered = false;
36 DD.Loc = Locs.front();
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 DD.AvailabilityData.Message = MessageData;
47 DD.AvailabilityData.MessageLen = Msg.size();
48
49 DD.AvailabilityData.SelectorLocs = new SourceLocation[Locs.size()];
50 memcpy(DD.AvailabilityData.SelectorLocs, Locs.data(),
51 sizeof(SourceLocation) * Locs.size());
52 DD.AvailabilityData.NumSelectorLocs = Locs.size();
53
54 DD.AvailabilityData.AR = AR;
55 DD.AvailabilityData.ObjCPropertyAccess = ObjCPropertyAccess;
56 return DD;
57 }
58
59 void DelayedDiagnostic::Destroy() {
60 switch (Kind) {
61 case Access:
62 getAccessData().~AccessedEntity();
63 break;
64
65 case Availability:
66 delete[] AvailabilityData.Message;
67 delete[] AvailabilityData.SelectorLocs;
68 break;
69
70 case ForbiddenType:
71 break;
72 }
73 }
clang::sema::DelayedDiagnostic::Kind
DDKind Kind
Definition: DelayedDiagnostic.h:133
clang::sema::DelayedDiagnostic::getAccessData
AccessedEntity & getAccessData()
Definition: DelayedDiagnostic.h:173
clang::sema::DelayedDiagnostic::ForbiddenType
Definition: DelayedDiagnostic.h:131
clang::sema::DelayedDiagnostic::Availability
Definition: DelayedDiagnostic.h:131
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1186
llvm::ArrayRef
Definition: LLVM.h:31
clang::AvailabilityResult
AvailabilityResult
Captures the result of checking the availability of a declaration.
Definition: DeclBase.h:74
clang::sema::DelayedDiagnostic::AvailabilityData
struct AD AvailabilityData
Definition: DelayedDiagnostic.h:259
DelayedDiagnostic.h
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
clang::sema::DelayedDiagnostic::Destroy
void Destroy()
Definition: DelayedDiagnostic.cpp:59
Kind
Kind
Definition: ChrootChecker.cpp:29
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::ObjCPropertyDecl
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:741
memcpy
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Definition: __clang_cuda_device_functions.h:1632
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:24
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::sema::DelayedDiagnostic
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
Definition: DelayedDiagnostic.h:129
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:223
clang::sema::DelayedDiagnostic::Access
Definition: DelayedDiagnostic.h:131