Douglas Gregor | 2923380 | 2011-03-23 15:13:44 +0000 | [diff] [blame] | 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 | |
| 22 | DelayedDiagnostic DelayedDiagnostic::makeDeprecation(SourceLocation Loc, |
Fariborz Jahanian | b0a6615 | 2012-03-02 21:50:02 +0000 | [diff] [blame] | 23 | const NamedDecl *D, |
| 24 | const ObjCInterfaceDecl *UnknownObjCClass, |
Fariborz Jahanian | fd09088 | 2012-09-21 20:46:37 +0000 | [diff] [blame] | 25 | const ObjCPropertyDecl *ObjCProperty, |
Fariborz Jahanian | b0a6615 | 2012-03-02 21:50:02 +0000 | [diff] [blame] | 26 | StringRef Msg) { |
Douglas Gregor | 2923380 | 2011-03-23 15:13:44 +0000 | [diff] [blame] | 27 | DelayedDiagnostic DD; |
| 28 | DD.Kind = Deprecation; |
| 29 | DD.Triggered = false; |
| 30 | DD.Loc = Loc; |
| 31 | DD.DeprecationData.Decl = D; |
Fariborz Jahanian | b0a6615 | 2012-03-02 21:50:02 +0000 | [diff] [blame] | 32 | DD.DeprecationData.UnknownObjCClass = UnknownObjCClass; |
Fariborz Jahanian | fd09088 | 2012-09-21 20:46:37 +0000 | [diff] [blame] | 33 | DD.DeprecationData.ObjCProperty = ObjCProperty; |
Douglas Gregor | 2923380 | 2011-03-23 15:13:44 +0000 | [diff] [blame] | 34 | char *MessageData = 0; |
| 35 | if (Msg.size()) { |
| 36 | MessageData = new char [Msg.size()]; |
| 37 | memcpy(MessageData, Msg.data(), Msg.size()); |
| 38 | } |
| 39 | |
| 40 | DD.DeprecationData.Message = MessageData; |
| 41 | DD.DeprecationData.MessageLen = Msg.size(); |
| 42 | return DD; |
| 43 | } |
| 44 | |
| 45 | void DelayedDiagnostic::Destroy() { |
| 46 | switch (Kind) { |
| 47 | case Access: |
| 48 | getAccessData().~AccessedEntity(); |
| 49 | break; |
| 50 | |
| 51 | case Deprecation: |
| 52 | delete [] DeprecationData.Message; |
| 53 | break; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 54 | |
| 55 | case ForbiddenType: |
| 56 | break; |
Douglas Gregor | 2923380 | 2011-03-23 15:13:44 +0000 | [diff] [blame] | 57 | } |
| 58 | } |