Coverage Report

Created: 2021-08-24 07:12

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