Coverage Report

Created: 2019-07-24 05:18

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