diff options
author | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
commit | 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df (patch) | |
tree | a9243275843fbeaa590afc07ee888e006b8d54ea /include/clang/Sema/DelayedDiagnostic.h | |
parent | 69b4eca4a4255ba43baa5c1d9bbdec3ec17f479e (diff) | |
download | FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.zip FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.tar.gz |
Vendor import of clang trunk r126079:
http://llvm.org/svn/llvm-project/cfe/trunk@126079
Diffstat (limited to 'include/clang/Sema/DelayedDiagnostic.h')
-rw-r--r-- | include/clang/Sema/DelayedDiagnostic.h | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/include/clang/Sema/DelayedDiagnostic.h b/include/clang/Sema/DelayedDiagnostic.h index 6a9a1bf..6e808de 100644 --- a/include/clang/Sema/DelayedDiagnostic.h +++ b/include/clang/Sema/DelayedDiagnostic.h @@ -101,7 +101,7 @@ public: private: unsigned Access : 2; - bool IsMember; + unsigned IsMember : 1; NamedDecl *Target; CXXRecordDecl *NamingClass; QualType BaseObjectType; @@ -119,14 +119,6 @@ public: SourceLocation Loc; - union { - /// Deprecation. - struct { NamedDecl *Decl; } DeprecationData; - - /// Access control. - char AccessData[sizeof(AccessedEntity)]; - }; - void destroy() { switch (Kind) { case Access: getAccessData().~AccessedEntity(); break; @@ -135,12 +127,15 @@ public: } static DelayedDiagnostic makeDeprecation(SourceLocation Loc, - NamedDecl *D) { + const NamedDecl *D, + llvm::StringRef Msg) { DelayedDiagnostic DD; DD.Kind = Deprecation; DD.Triggered = false; DD.Loc = Loc; DD.DeprecationData.Decl = D; + DD.DeprecationData.Message = Msg.data(); + DD.DeprecationData.MessageLen = Msg.size(); return DD; } @@ -155,11 +150,37 @@ public: } AccessedEntity &getAccessData() { + assert(Kind == Access && "Not an access diagnostic."); return *reinterpret_cast<AccessedEntity*>(AccessData); } const AccessedEntity &getAccessData() const { + assert(Kind == Access && "Not an access diagnostic."); return *reinterpret_cast<const AccessedEntity*>(AccessData); } + + const NamedDecl *getDeprecationDecl() const { + assert(Kind == Deprecation && "Not a deprecation diagnostic."); + return DeprecationData.Decl; + } + + llvm::StringRef getDeprecationMessage() const { + assert(Kind == Deprecation && "Not a deprecation diagnostic."); + return llvm::StringRef(DeprecationData.Message, + DeprecationData.MessageLen); + } + +private: + union { + /// Deprecation. + struct { + const NamedDecl *Decl; + const char *Message; + size_t MessageLen; + } DeprecationData; + + /// Access control. + char AccessData[sizeof(AccessedEntity)]; + }; }; } |