Coverage Report

Created: 2020-02-25 14:32

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