clang API Documentation

DelayedDiagnostic.cpp
Go to the documentation of this file.
00001 //===--- DelayedDiagnostic.cpp - Delayed declarator diagnostics -*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines the DelayedDiagnostic class implementation, which
00011 // is used to record diagnostics that are being conditionally produced
00012 // during declarator parsing.
00013 //
00014 // This file also defines AccessedEntity.
00015 //
00016 //===----------------------------------------------------------------------===//
00017 #include "clang/Sema/DelayedDiagnostic.h"
00018 #include <string.h>
00019 using namespace clang;
00020 using namespace sema;
00021 
00022 DelayedDiagnostic DelayedDiagnostic::makeDeprecation(SourceLocation Loc,
00023                                     const NamedDecl *D,
00024                                     const ObjCInterfaceDecl *UnknownObjCClass,
00025                                     StringRef Msg) {
00026   DelayedDiagnostic DD;
00027   DD.Kind = Deprecation;
00028   DD.Triggered = false;
00029   DD.Loc = Loc;
00030   DD.DeprecationData.Decl = D;
00031   DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
00032   char *MessageData = 0;
00033   if (Msg.size()) {
00034     MessageData = new char [Msg.size()];
00035     memcpy(MessageData, Msg.data(), Msg.size());
00036   }
00037 
00038   DD.DeprecationData.Message = MessageData;
00039   DD.DeprecationData.MessageLen = Msg.size();
00040   return DD;
00041 }
00042 
00043 void DelayedDiagnostic::Destroy() {
00044   switch (Kind) {
00045   case Access: 
00046     getAccessData().~AccessedEntity(); 
00047     break;
00048 
00049   case Deprecation: 
00050     delete [] DeprecationData.Message;
00051     break;
00052 
00053   case ForbiddenType:
00054     break;
00055   }
00056 }