Coverage Report

Created: 2022-07-16 07:03

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