2018-02-21 09:45:26 +08:00
|
|
|
//===- DelayedDiagnostic.cpp - Delayed declarator diagnostics -------------===//
|
2011-03-23 23:13:44 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the DelayedDiagnostic class implementation, which
|
|
|
|
// is used to record diagnostics that are being conditionally produced
|
|
|
|
// during declarator parsing.
|
|
|
|
//
|
|
|
|
// This file also defines AccessedEntity.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2018-02-21 09:45:26 +08:00
|
|
|
|
2011-03-23 23:13:44 +08:00
|
|
|
#include "clang/Sema/DelayedDiagnostic.h"
|
2018-02-21 09:45:26 +08:00
|
|
|
#include <cstring>
|
|
|
|
|
2011-03-23 23:13:44 +08:00
|
|
|
using namespace clang;
|
|
|
|
using namespace sema;
|
|
|
|
|
2013-12-19 07:30:06 +08:00
|
|
|
DelayedDiagnostic
|
2016-10-29 05:39:27 +08:00
|
|
|
DelayedDiagnostic::makeAvailability(AvailabilityResult AR,
|
2018-03-30 01:34:09 +08:00
|
|
|
ArrayRef<SourceLocation> Locs,
|
2017-07-06 01:08:56 +08:00
|
|
|
const NamedDecl *ReferringDecl,
|
|
|
|
const NamedDecl *OffendingDecl,
|
2012-03-03 05:50:02 +08:00
|
|
|
const ObjCInterfaceDecl *UnknownObjCClass,
|
2012-09-22 04:46:37 +08:00
|
|
|
const ObjCPropertyDecl *ObjCProperty,
|
2014-06-17 01:25:41 +08:00
|
|
|
StringRef Msg,
|
|
|
|
bool ObjCPropertyAccess) {
|
2018-03-30 01:34:09 +08:00
|
|
|
assert(!Locs.empty());
|
2011-03-23 23:13:44 +08:00
|
|
|
DelayedDiagnostic DD;
|
2016-10-29 05:39:27 +08:00
|
|
|
DD.Kind = Availability;
|
2011-03-23 23:13:44 +08:00
|
|
|
DD.Triggered = false;
|
2018-03-30 01:34:09 +08:00
|
|
|
DD.Loc = Locs.front();
|
2017-07-06 01:08:56 +08:00
|
|
|
DD.AvailabilityData.ReferringDecl = ReferringDecl;
|
|
|
|
DD.AvailabilityData.OffendingDecl = OffendingDecl;
|
2016-10-29 05:39:27 +08:00
|
|
|
DD.AvailabilityData.UnknownObjCClass = UnknownObjCClass;
|
|
|
|
DD.AvailabilityData.ObjCProperty = ObjCProperty;
|
2014-05-26 14:22:03 +08:00
|
|
|
char *MessageData = nullptr;
|
2018-02-21 09:45:26 +08:00
|
|
|
if (!Msg.empty()) {
|
2011-03-23 23:13:44 +08:00
|
|
|
MessageData = new char [Msg.size()];
|
|
|
|
memcpy(MessageData, Msg.data(), Msg.size());
|
|
|
|
}
|
2016-10-29 05:39:27 +08:00
|
|
|
DD.AvailabilityData.Message = MessageData;
|
|
|
|
DD.AvailabilityData.MessageLen = Msg.size();
|
2018-03-30 01:34:09 +08:00
|
|
|
|
|
|
|
DD.AvailabilityData.SelectorLocs = new SourceLocation[Locs.size()];
|
|
|
|
memcpy(DD.AvailabilityData.SelectorLocs, Locs.data(),
|
|
|
|
sizeof(SourceLocation) * Locs.size());
|
|
|
|
DD.AvailabilityData.NumSelectorLocs = Locs.size();
|
|
|
|
|
2016-10-29 05:39:27 +08:00
|
|
|
DD.AvailabilityData.AR = AR;
|
|
|
|
DD.AvailabilityData.ObjCPropertyAccess = ObjCPropertyAccess;
|
2011-03-23 23:13:44 +08:00
|
|
|
return DD;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DelayedDiagnostic::Destroy() {
|
2016-10-29 05:39:27 +08:00
|
|
|
switch (Kind) {
|
2011-03-23 23:13:44 +08:00
|
|
|
case Access:
|
|
|
|
getAccessData().~AccessedEntity();
|
|
|
|
break;
|
|
|
|
|
2016-10-29 05:39:27 +08:00
|
|
|
case Availability:
|
|
|
|
delete[] AvailabilityData.Message;
|
2018-03-30 01:34:09 +08:00
|
|
|
delete[] AvailabilityData.SelectorLocs;
|
2011-03-23 23:13:44 +08:00
|
|
|
break;
|
2011-06-16 07:02:42 +08:00
|
|
|
|
|
|
|
case ForbiddenType:
|
|
|
|
break;
|
2011-03-23 23:13:44 +08:00
|
|
|
}
|
|
|
|
}
|