Fixes <rdar://problem/15584219> and <rdar://problem/12241361>. This change looks large, but all it does is reuse and consolidate the delayed diagnostic logic for deprecation warnings with unavailability warnings. By doing so, it showed various inconsistencies between the diagnostics, which were close, but not consistent. It also revealed some missing "note:"'s in the deprecated diagnostics that were showing up in the unavailable diagnostics, etc. This change also changes the wording of the core deprecation diagnostics. Instead of saying "function has been explicitly marked deprecated" we now saw "'X' has been been explicitly marked deprecated". It turns out providing a bit more context is useful, and often we got the actual term wrong or it was not very precise (e.g., "function" instead of "destructor"). By just saying the name of the thing that is deprecated/deleted/unavailable we define this issue away. This diagnostic can likely be further wordsmithed to be shorter. llvm-svn: 197627
68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
//===--- DelayedDiagnostic.cpp - Delayed declarator diagnostics -*- C++ -*-===//
|
|
//
|
|
// 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.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
#include "clang/Sema/DelayedDiagnostic.h"
|
|
#include <string.h>
|
|
using namespace clang;
|
|
using namespace sema;
|
|
|
|
DelayedDiagnostic
|
|
DelayedDiagnostic::makeAvailability(Sema::AvailabilityDiagnostic AD,
|
|
SourceLocation Loc,
|
|
const NamedDecl *D,
|
|
const ObjCInterfaceDecl *UnknownObjCClass,
|
|
const ObjCPropertyDecl *ObjCProperty,
|
|
StringRef Msg) {
|
|
DelayedDiagnostic DD;
|
|
switch (AD) {
|
|
case Sema::AD_Deprecation:
|
|
DD.Kind = Deprecation;
|
|
break;
|
|
case Sema::AD_Unavailable:
|
|
DD.Kind = Unavailable;
|
|
break;
|
|
}
|
|
DD.Triggered = false;
|
|
DD.Loc = Loc;
|
|
DD.DeprecationData.Decl = D;
|
|
DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
|
|
DD.DeprecationData.ObjCProperty = ObjCProperty;
|
|
char *MessageData = 0;
|
|
if (Msg.size()) {
|
|
MessageData = new char [Msg.size()];
|
|
memcpy(MessageData, Msg.data(), Msg.size());
|
|
}
|
|
|
|
DD.DeprecationData.Message = MessageData;
|
|
DD.DeprecationData.MessageLen = Msg.size();
|
|
return DD;
|
|
}
|
|
|
|
void DelayedDiagnostic::Destroy() {
|
|
switch (Kind) {
|
|
case Access:
|
|
getAccessData().~AccessedEntity();
|
|
break;
|
|
|
|
case Deprecation:
|
|
delete [] DeprecationData.Message;
|
|
break;
|
|
|
|
case ForbiddenType:
|
|
break;
|
|
}
|
|
}
|