Coverage Report

Created: 2021-01-19 06:58

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