1 //===--- DelayedDiagnostic.cpp - Delayed declarator diagnostics -*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file defines the DelayedDiagnostic class implementation, which 11 // is used to record diagnostics that are being conditionally produced 12 // during declarator parsing. 13 // 14 // This file also defines AccessedEntity. 15 // 16 //===----------------------------------------------------------------------===// 17 #include "clang/Sema/DelayedDiagnostic.h" 18 #include <string.h> 19 using namespace clang; 20 using namespace sema; 21 makeDeprecation(SourceLocation Loc,const NamedDecl * D,const ObjCInterfaceDecl * UnknownObjCClass,StringRef Msg)22DelayedDiagnostic DelayedDiagnostic::makeDeprecation(SourceLocation Loc, 23 const NamedDecl *D, 24 const ObjCInterfaceDecl *UnknownObjCClass, 25 StringRef Msg) { 26 DelayedDiagnostic DD; 27 DD.Kind = Deprecation; 28 DD.Triggered = false; 29 DD.Loc = Loc; 30 DD.DeprecationData.Decl = D; 31 DD.DeprecationData.UnknownObjCClass = UnknownObjCClass; 32 char *MessageData = 0; 33 if (Msg.size()) { 34 MessageData = new char [Msg.size()]; 35 memcpy(MessageData, Msg.data(), Msg.size()); 36 } 37 38 DD.DeprecationData.Message = MessageData; 39 DD.DeprecationData.MessageLen = Msg.size(); 40 return DD; 41 } 42 Destroy()43void DelayedDiagnostic::Destroy() { 44 switch (Kind) { 45 case Access: 46 getAccessData().~AccessedEntity(); 47 break; 48 49 case Deprecation: 50 delete [] DeprecationData.Message; 51 break; 52 53 case ForbiddenType: 54 break; 55 } 56 } 57