summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-10-09 15:49:00 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-10-09 15:49:00 +0000
commitbfac7dcda04015dca46616fcbf3fc095e02f446d (patch)
tree4f4e8c3bc0228213d7950ec8643c4b7b3d1be008 /clang/lib
parent9cc3fcc8ecbc3a990c9e0adf75ed49ae1092df17 (diff)
downloadbcm5719-llvm-bfac7dcda04015dca46616fcbf3fc095e02f446d.tar.gz
bcm5719-llvm-bfac7dcda04015dca46616fcbf3fc095e02f446d.zip
Don't rely on a StringRef being null-terminated (it's not) for deprecation messages.
Store pointer and length of the message in DelayedDiagnostic and hide the gory union details. llvm-svn: 116153
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp12
-rw-r--r--clang/lib/Sema/SemaExpr.cpp9
2 files changed, 9 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e9ee50fe75c..d5bd4f8944a 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2566,16 +2566,16 @@ void Sema::HandleDelayedDeprecationCheck(DelayedDiagnostic &DD,
return;
DD.Triggered = true;
- if (DD.DeprecationData.Message)
+ if (!DD.getDeprecationMessage().empty())
Diag(DD.Loc, diag::warn_deprecated_message)
- << DD.DeprecationData.Decl->getDeclName()
- << DD.DeprecationData.Message;
+ << DD.getDeprecationDecl()->getDeclName()
+ << DD.getDeprecationMessage();
else
Diag(DD.Loc, diag::warn_deprecated)
- << DD.DeprecationData.Decl->getDeclName();
+ << DD.getDeprecationDecl()->getDeclName();
}
-void Sema::EmitDeprecationWarning(NamedDecl *D, const char * Message,
+void Sema::EmitDeprecationWarning(NamedDecl *D, llvm::StringRef Message,
SourceLocation Loc) {
// Delay if we're currently parsing a declaration.
if (ParsingDeclDepth) {
@@ -2587,7 +2587,7 @@ void Sema::EmitDeprecationWarning(NamedDecl *D, const char * Message,
// Otherwise, don't warn if our current context is deprecated.
if (isDeclDeprecated(cast<Decl>(CurContext)))
return;
- if (Message)
+ if (!Message.empty())
Diag(Loc, diag::warn_deprecated_message) << D->getDeclName()
<< Message;
else
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e35b6c24551..38287e49295 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -57,11 +57,8 @@ using namespace sema;
///
bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) {
// See if the decl is deprecated.
- if (const DeprecatedAttr *DA = D->getAttr<DeprecatedAttr>()) {
- const char *Message =
- DA->getMessage().empty() ? 0 : DA->getMessage().data();
- EmitDeprecationWarning(D, Message, Loc);
- }
+ if (const DeprecatedAttr *DA = D->getAttr<DeprecatedAttr>())
+ EmitDeprecationWarning(D, DA->getMessage(), Loc);
// See if the decl is unavailable
if (const UnavailableAttr *UA = D->getAttr<UnavailableAttr>()) {
@@ -69,7 +66,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) {
Diag(Loc, diag::err_unavailable) << D->getDeclName();
else
Diag(Loc, diag::err_unavailable_message)
- << D->getDeclName() << UA->getMessage().data();
+ << D->getDeclName() << UA->getMessage();
Diag(D->getLocation(), diag::note_unavailable_here) << 0;
}
OpenPOWER on IntegriCloud