Coverage Report

Created: 2022-05-17 06:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Sema/DelayedDiagnostic.cpp
Line
Count
Source (jump to first uncovered line)
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
259k
                                    bool ObjCPropertyAccess) {
32
259k
  assert(!Locs.empty());
33
0
  DelayedDiagnostic DD;
34
259k
  DD.Kind = Availability;
35
259k
  DD.Triggered = false;
36
259k
  DD.Loc = Locs.front();
37
259k
  DD.AvailabilityData.ReferringDecl = ReferringDecl;
38
259k
  DD.AvailabilityData.OffendingDecl = OffendingDecl;
39
259k
  DD.AvailabilityData.UnknownObjCClass = UnknownObjCClass;
40
259k
  DD.AvailabilityData.ObjCProperty = ObjCProperty;
41
259k
  char *MessageData = nullptr;
42
259k
  if (!Msg.empty()) {
43
259k
    MessageData = new char [Msg.size()];
44
259k
    memcpy(MessageData, Msg.data(), Msg.size());
45
259k
  }
46
259k
  DD.AvailabilityData.Message = MessageData;
47
259k
  DD.AvailabilityData.MessageLen = Msg.size();
48
49
259k
  DD.AvailabilityData.SelectorLocs = new SourceLocation[Locs.size()];
50
259k
  memcpy(DD.AvailabilityData.SelectorLocs, Locs.data(),
51
259k
         sizeof(SourceLocation) * Locs.size());
52
259k
  DD.AvailabilityData.NumSelectorLocs = Locs.size();
53
54
259k
  DD.AvailabilityData.AR = AR;
55
259k
  DD.AvailabilityData.ObjCPropertyAccess = ObjCPropertyAccess;
56
259k
  return DD;
57
259k
}
58
59
501k
void DelayedDiagnostic::Destroy() {
60
501k
  switch (Kind) {
61
241k
  case Access:
62
241k
    getAccessData().~AccessedEntity();
63
241k
    break;
64
65
259k
  case Availability:
66
259k
    delete[] AvailabilityData.Message;
67
259k
    delete[] AvailabilityData.SelectorLocs;
68
259k
    break;
69
70
61
  case ForbiddenType:
71
61
    break;
72
501k
  }
73
501k
}